mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
WIP - very basic grammar
This commit is contained in:
parent
d585121bdb
commit
8084d80d64
55
src/diagrams/gitGraph/parser/gitGraph.jison
Normal file
55
src/diagrams/gitGraph/parser/gitGraph.jison
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
/*
|
||||
* Parse following
|
||||
* gitGraph:
|
||||
* commit
|
||||
* commit
|
||||
* branch
|
||||
*/
|
||||
%lex
|
||||
|
||||
%options case-insensitive
|
||||
|
||||
%%
|
||||
|
||||
[\n]+ return 'NL';
|
||||
\s+ /* skip all whitespace */
|
||||
\#[^\n]* /* skip comments */
|
||||
\%%[^\n]* /* skip comments */
|
||||
"gitGraph" return 'GG';
|
||||
"commit" return 'COMMIT';
|
||||
"branch" return 'BRANCH';
|
||||
"merge" return 'MERGE';
|
||||
"reset" return 'RESET';
|
||||
":" return ':';
|
||||
[a-zA-Z][a-zA-Z0-9_]+ return 'ID';
|
||||
<<EOF>> return 'EOF';
|
||||
|
||||
/lex
|
||||
|
||||
%left '^'
|
||||
|
||||
%start start
|
||||
|
||||
%% /* language grammar */
|
||||
|
||||
start
|
||||
: GG ':' document EOF{ return $3; }
|
||||
;
|
||||
|
||||
document
|
||||
: /* empty */ {$$ =[]}
|
||||
| document line {$1.push($2); $$ = $1}
|
||||
;
|
||||
|
||||
line
|
||||
: statement {$$ =$1}
|
||||
| NL
|
||||
;
|
||||
|
||||
statement
|
||||
: COMMIT
|
||||
| BRANCH ID
|
||||
| MERGE ID
|
||||
;
|
||||
|
Loading…
x
Reference in New Issue
Block a user