Giter Club home page Giter Club logo

Comments (5)

bafolts avatar bafolts commented on August 23, 2024

Can you provide an example of what is in your input file?

from plantcode.

huyz avatar huyz commented on August 23, 2024

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.

jean avatar jean commented on August 23, 2024

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.

fuhrmanator avatar fuhrmanator commented on August 23, 2024

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?):

  1. B -|> A (make the line horizontal)
  2. A <|- B
  3. B --|> A (make the line vertical)
  4. A <|-- B
  5. 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.

bafolts avatar bafolts commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.