Comments (5)
Can you provide an example of what is in your input file?
from plantcode.
Oh actually, only some of the examples are broken.
If I take examples 3-6 under Class Diagrams at https://www.planttext.com/ and try to convert to Java, I get a similar error; examples 1-2 work.
Example 3:
@startuml
title Types - Class Diagram
skinparam componentStyle uml2
abstract class AbstractList {
}
class Test << general >> {
}
class System << (S,#FF7700) Singleton >>
class Date << (D,orchid) >>
class Foo1<Generics tag> {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName() : String
+ getAddress() : Address
.. Some setter ..
+ setName() : String
__ private data __
-int age
-- crypted --
-String password
}
enum TimeUnit {
DAYS
HOURS
MINUTES
}
interface List {
}
annotation SuppressWarnings
class Object << general >>
Object <|--- ArrayList
@enduml
from plantcode.
This creates a diagram, but the generator chokes:
@startuml
MemberCompany *-- DocumentFolder
DocumentFolder *-- "*" Document
Region *-- City
City "*" <-- MemberCompany
Contact "*" <-- MemberCompany
interface Address
Address <|-- MemberCompany
Address <|-- Contact
@enduml
Error output:
Error parsing input file:
/home/ubuntu/bin/PlantCode/Log/2019-10-7-10-24-00-coffeescript.txt
{ message: 'Expected "*", "--", "---", "-down-", "-left-", "-right-", "-up-", "..", "<|", "o", [ \\t], [-] or [.] but "<" found.',
expected:
[ { type: 'literal', value: '*', description: '"*"' },
{ type: 'literal', value: '--', description: '"--"' },
{ type: 'literal', value: '---', description: '"---"' },
{ type: 'literal', value: '-down-', description: '"-down-"' },
{ type: 'literal', value: '-left-', description: '"-left-"' },
{ type: 'literal', value: '-right-', description: '"-right-"' },
{ type: 'literal', value: '-up-', description: '"-up-"' },
{ type: 'literal', value: '..', description: '".."' },
{ type: 'literal', value: '<|', description: '"<|"' },
{ type: 'literal', value: 'o', description: '"o"' },
{ type: 'class', value: '[ \\t]', description: '[ \\t]' },
{ type: 'class', value: '[-]', description: '[-]' },
{ type: 'class', value: '[.]', description: '[.]' } ],
found: '<',
location:
{ start: { offset: 103, line: 6, column: 10 },
end: { offset: 104, line: 6, column: 11 } },
name: 'SyntaxError' }
from plantcode.
I looked at the grammar, and I see it's not expecting the traditional UML format of a field with a <access> <name> : <type>
but rather <access> <type> <name>
as in Java. Many of the examples on PlantText.com use that traditional syntax, as does the highlighting of the very popular PlantUML extension in VSCode (albeit with regexes rather than with PEG.js).
Below is an example.
@startuml
class User {
-name : String
+getName() : String
}
@enduml
That example crashes the PEG.js here because obviously it's not expecting a ":" in fields.
As for the relationships between classes, it's complex (PlantUML is super flexible, since it tries to allow you to control how things are drawn as well as how things are related). I didn't grok the whole PEG.js grammar you defined yet, but I know PlantUML can state B
is a subclass of A
in at least in these ways (maybe more?):
B -|> A
(make the line horizontal)A <|- B
B --|> A
(make the line vertical)A <|-- B
class B extends A
When you consider associations, there are more cases.
A grammar to try to support all these would be (overly) complicated, at least for a start, and I think you've done right to be conservative.
If a format isn't supported, it's not a bug (but a limitation of the current grammar). I did a PEG.js grammar for GIFT format and automated the tests with Mocha/Chai. It might be useful to do that here.
I did a lot of hacking with the online PEG.js editor, which isn't smart enough to include require
stuff, but I think you could write something like I did here to test with the compiled parser from the grammar. The left side would be the PlantUML code, and the right side would be a display of the intermediate (parsed) information.
If I can find some time, I would like to work on your project. It's something I've wanted to do for a while, and my students are using TypeScript and PlantUML in one of my courses.
from plantcode.
Somehow I lost track of this important issue. Thanks for bringing it back to my attention @fuhrmanator ! It does seem there are a few bugs with the current grammar. Including the optional colon character should be a straight forward fix. The relationship between classes will be more complex. I will focus on the addition of the optional colon first. I created this project as a proof of concept a few years back and since then PlantUML seems to be getting more popular. There was another issue filed at some point and I believe planttext.com is forced to run this tool server side to generate the output. Having a separate github page like yours would be a great addition. I have no association with the planttext.com tool but the author was kind enough to include me on their tool.
from plantcode.
Related Issues (20)
- Parser doesn't support interfaces or headers HOT 5
- Opposite Way HOT 6
- Suggestion: create XMI output to open the way to use other tools
- [Feature request] Add support for Python
- npx not working due to missing dependencies HOT 2
- "end class" isn't valid plantuml?
- Cannot find module './Aggregation' HOT 3
- Class Properties are Not Converted HOT 2
- AccessType is not working in templates HOT 3
- Package is an unknown type HOT 2
- Implements is not supported HOT 1
- Extends does not work if right hand side of connection is not present
- Property name and type are reversed in Typescript HOT 2
- Create example for running the converter client side instead of from node. HOT 3
- Move from PEG.js to Peggy.js HOT 1
- Failed on skinparam HOT 2
- Does dot accept numbers on field/method names HOT 2
- plantuml-code-generator can't handle comments HOT 3
- Add support for plantuml notes HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plantcode.