sequence-parser
v0.8.8
Published
Parse sequence diagram DSL to an Abstract Syntax Tree
Downloads
38
Readme
Sequence Parser
Sequence parser is used to parse ZenUML DSL into an abstract syntax tree (AST). It also exposes a few utility methods.
Run cucumber test
We use the cucumber test to generate the specification for the ZenUML DSL. Make sure that the test is written clearly.
Run test
$ yarn run cucumber-js -f json:report/cucumber_report.json
# or use watch
$ watch 'yarn run cucumber-js -f json:report/cucumber_report.json' featuresTo ignore a folder from watch use
--ignoreDirectoryPattern /report/g
Convert the report to HTML
$ node report/index.js
# or use watch
$ watch 'node report/index.js' reportIf you are using Intellij Idea, you can use the "Live Edit" plugin to load the generated HTML automatically. Right click the HTML file (in editor) and choose "Debug". Or use CTRL+SHIFT+F9.
Patch the cucumber HTML reporter
The default cucumber-html-reporter does not show the \n character in the generated HTML.
Patch the tempates/simple/features.html file with step.name && step.name.replace('\n', '\\n').
Usage of the parser
The latest public / stable version of this parser is published to npm under name sequence-parser
(defined in package.json) To use this parser, just import seqParser from 'sequence-parser'.
Exported module
This project generate a UMD library. The exported library name is sequenceParser (defined in
webpack.config.js). This, however, does NOT mean you need to name the module as sequenceParser
when it is imported or required.
RootContext
Purpose: Get the prog antlr4 context from the given ZenUML DSL
Type: function
Arguments: code the DSL provided in a string
Result: An antlr4 context of theprog node (see sequenceParser.g4 for the definition of prog)
Participants
Purpose: Get all the participants from the given antlr4 context
Type: function
Arguments: ctx the antlr4 context
Depth
Purpose: Get how many levels fragments (alt / loop) are within the given context
Type: function
Arguments: ctx the antlr4 context
Development
Build
yarn build runs three yarn commands:
generategenerates the lexer (sequenceLexer.js) and parser (sequenceParser.js);jestrun all the tests in the test folder;webpackto pack up the library and put it indist/main.js.I am not able to test the rule with 'ANTLR Preview'? Run
yarn generateto re-generate the lexer and parser.A token is highlighted in the lexer with a warning that it is not recognised. Close the editor and re-open it.
yarn buildfailed
