123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891 |
- start: sccd;
- sccd: diagram INDENT (top)? element+ (bottom)? DEDENT;
- @element: (inport | outport | class);
- inport: INPORT LPAR nameattr RPAR NEWLINE;
- outport: OUTPORT LPAR nameattr RPAR NEWLINE;
- nameattr: NAMEATTR ASSIGN string;
- defaultattr: DEFAULTATTR ASSIGN boolean;
- classattr: CLASSATTR ASSIGN string;
- class: CLASS LPAR classdefattrs RPAR
- ( (COLON NEWLINE INDENT classelement+ DEDENT) | NEWLINE);
- classdefattrs: classdefattr (COMMA classdefattr)*;
- classdefattr: nameattr | defaultattr;
- @classelement: inport | outport | association | inheritance | aggregation | composition |
- attribute | constructor | destructor | method | statemachine;
- aggregation: AGGREGATION LPAR aggregattrs RPAR NEWLINE;
- aggregattrs: relattr (COMMA relattr)*;
- composition: COMPOSITION LPAR compattrs RPAR NEWLINE;
- compattrs: relattr (COMMA relattr)*;
- @relattr: classattr | minattr | maxattr;
- minattr: MIN ASSIGN integer;
- maxattr: MAX ASSIGN integer;
- association: ASSOCIATION LPAR assocattrs RPAR NEWLINE;
- assocattrs: assocattr (COMMA assocattr)*;
- assocattr: nameattr | relattr;
- inheritance: INHERITANCE LPAR inherattrs RPAR NEWLINE;
- inherattrs: inherattr (COMMA inherattr)*;
- inherattr: priorityattr | classattr;
- priorityattr: PRIORITYATTR ASSIGN integer;
- attribute: ATTRIBUTE LPAR attributeattrs RPAR NEWLINE;
- attributeattrs: attributeattr (COMMA attributeattr)*;
- attributeattr: nameattr | defaultvalueattr | typenameattr;
- defaultvalueattr: DEFAULTATTR ASSIGN string;
- typenameattr: TYPEATTR ASSIGN string;
- diagram: DIAGRAM (NEWLINE)+;
- DIAGRAM: 'Diagram\([^\)]*\):'
- {
- start: 'Diagram\(' attrs '\)' ':';
- @attr: (attrname|attrauthor|attrdescription);
- @attrs: attr (',' attr)*;
- attrname: ATTRNAME '=' string;
- attrauthor: ATTRAUTHOR '=' string;
- attrdescription: ATTRDESCRIPTION '=' string;
- ATTRNAME: 'name';
- ATTRAUTHOR: 'author';
- ATTRDESCRIPTION: 'description';
- string: (STRVALUE|LONG_STRVALUE) string? ;
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- WS: '[\t \f\n]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- top: TOP BODY NEWLINE;
- bottom: BOTTOM BODY;
- constructor: CONSTRUCTOR body NEWLINE;
- destructor: DESTRUCTOR body NEWLINE;
- method: METHOD body NEWLINE;
- statemachine: STATEMACHINE (NEWLINE |
- (COLON NEWLINE INDENT (state | orthogonal | pseudostate | transition)+ DEDENT));
- @state_element: state | orthogonal | pseudostate | transition | onenter | onexit;
- onenter: ONENTER BODY NEWLINE;
- onexit: ONEXIT BODY NEWLINE;
- state: STATE LPAR statename RPAR (NEWLINE |
- (COLON NEWLINE INDENT state_element+ DEDENT));
- orthogonal: ORTHOGONAL LPAR statename RPAR (NEWLINE |
- (COLON NEWLINE INDENT state_element+ DEDENT));
- @pseudostate: (initial | final | history) NEWLINE;
- initial: INITIAL ASSIGN statename;
- final: FINAL ASSIGN statename;
- history: HISTORY ASSIGN statename;
- statename: string;
- transition: TRANSITION LPAR transitionattrs RPAR (NEWLINE |
- (COLON NEWLINE INDENT event? guard? raise* actions? DEDENT));
- transitionattrs: transitionattr (COMMA transitionattr)*;
- transitionattr: (portattr | targetattr | afterattr);
- portattr: PORTATTR ASSIGN string;
- targetattr: TARGETATTR ASSIGN string;
- afterattr: AFTERATTR;
- AFTERATTR: 'after\(.+\)'
- {
- start: AFTER LPAR expression RPAR;
- funccall_expr: (expression '->')? functionname LPAR arguments? RPAR;
- functionname: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- arguments: argument (COMMA argument)*;
- argument: (argumentname ASSIGN)? expression;
- argumentname: name;
- expression: nav_expr | atomvalue | tuple | vector | dict |
- unopexpr | binopexpr | funccall_expr | selection;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- @unopexpr: parexpr | notexpr | minusexpr;
- parexpr: LPAR expression RPAR;
- notexpr: NOT expression;
- minusexpr: MINUS expression;
- @binopexpr: selection | andexpr | orexpr | lthanexpr | leqthanexpr |
- gthanexpr | geqthanexpr | equalsexpr | nequalsexpr |
- multexpr | divexpr | modexpr | subtractionexpr | sumexpr;
- dict: LSQBR NEWLINE? dictitems NEWLINE? RSQBR;
- dictitems: dictitem (COMMA NEWLINE? dictitem)*;
- dictitem: expression COLON expression;
- vector: LSQBR NEWLINE? (vectoritems NEWLINE?)? RSQBR;
- vectoritems: vectoritem (COMMA NEWLINE? vectoritem)*;
- vectoritem: expression;
- tuple: LPAR tuplearg (COMMA tuplearg)+ RPAR;
- tuplearg: expression;
- selection: expression LSQBR expression RSQBR;
- andexpr: expression LAND expression;
- orexpr: expression LOR expression;
- lthanexpr: expression LTHAN expression;
- leqthanexpr: expression LEQTHAN expression;
- gthanexpr: expression GTHAN expression;
- geqthanexpr: expression GEQTHAN expression;
- equalsexpr: expression EQUALS expression;
- nequalsexpr: expression NEQUALS expression;
- subtractionexpr: expression MINUS expression;
- sumexpr: expression PLUS expression;
- multexpr: expression MULT expression;
- divexpr: expression DIV expression;
- modexpr: expression MOD expression;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- NOT: 'not';
- TRUE: 'True';
- FALSE: 'False';
- LAND: 'and';
- LOR: 'or';
- AFTER: 'after';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
-
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- MULT: '\*';
- DIV: '/';
- POTENCY: '@\d';
- LTHAN: '<';
- LEQTHAN: '<=';
- GTHAN: '>';
- GEQTHAN: '>=';
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- EQUALS: '==';
- NEQUALS: '!=';
- PLUS: '\+';
- MINUS: '-';
- MOD: '%';
- LSQBR: '\[';
- RSQBR: '\]';
- LBR: '\{';
- RBR: '\}';
- NEWLINE: '(\r?\n[\t ]*)+'
- (%newline)
- ;
- WS: '[\t \f]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- event: EVENT NEWLINE;
- EVENT: 'event\ =\ [^\(]+\([^\)]*\)'
- {
- start: EVENT ASSIGN namevalue LPAR formalparameters? RPAR;
- formalparameters: formalparameter (COMMA formalparameter)*;
- formalparameter: namevalue COLON nav_expr (ASSIGN defaultvalue)?;
- namevalue: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- defaultvalue: atomvalue;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9\-]*(?!r?"|r?\')'
- (%unless
- EVENT: 'event';
- TRUE: 'True';
- FALSE: 'False';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- WS: '[\t \f\n]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- guard: GUARD NEWLINE;
- GUARD: 'guard\ =\ \{[^\}]*\}'
- {
- start: GUARD ASSIGN LBR expression RBR;
- funccall_expr: (expression '->')? functionname LPAR arguments? RPAR;
- functionname: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- arguments: argument (COMMA argument)*;
- argument: (argumentname ASSIGN)? expression;
- argumentname: name;
- expression: nav_expr | atomvalue | tuple | vector | dict |
- unopexpr | binopexpr | funccall_expr | selection;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- @unopexpr: parexpr | notexpr | minusexpr;
- parexpr: LPAR expression RPAR;
- notexpr: NOT expression;
- minusexpr: MINUS expression;
- @binopexpr: selection | andexpr | orexpr | lthanexpr | leqthanexpr |
- gthanexpr | geqthanexpr | equalsexpr | nequalsexpr |
- multexpr | divexpr | modexpr | subtractionexpr | sumexpr;
- dict: LSQBR NEWLINE? dictitems NEWLINE? RSQBR;
- dictitems: dictitem (COMMA NEWLINE? dictitem)*;
- dictitem: expression COLON expression;
- vector: LSQBR NEWLINE? (vectoritems NEWLINE?)? RSQBR;
- vectoritems: vectoritem (COMMA NEWLINE? vectoritem)*;
- vectoritem: expression;
- tuple: LPAR tuplearg (COMMA tuplearg)+ RPAR;
- tuplearg: expression;
- selection: expression LSQBR expression RSQBR;
- andexpr: expression LAND expression;
- orexpr: expression LOR expression;
- lthanexpr: expression LTHAN expression;
- leqthanexpr: expression LEQTHAN expression;
- gthanexpr: expression GTHAN expression;
- geqthanexpr: expression GEQTHAN expression;
- equalsexpr: expression EQUALS expression;
- nequalsexpr: expression NEQUALS expression;
- subtractionexpr: expression MINUS expression;
- sumexpr: expression PLUS expression;
- multexpr: expression MULT expression;
- divexpr: expression DIV expression;
- modexpr: expression MOD expression;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- NOT: 'not';
- TRUE: 'True';
- FALSE: 'False';
- LAND: 'and';
- LOR: 'or';
- GUARD: 'guard';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
-
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- MULT: '\*';
- DIV: '/';
- POTENCY: '@\d';
- LTHAN: '<';
- LEQTHAN: '<=';
- GTHAN: '>';
- GEQTHAN: '>=';
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- EQUALS: '==';
- NEQUALS: '!=';
- PLUS: '\+';
- MINUS: '-';
- MOD: '%';
- LSQBR: '\[';
- RSQBR: '\]';
- LBR: '\{';
- RBR: '\}';
- NEWLINE: '(\r?\n[\t ]*)+'
- (%newline)
- ;
- WS: '[\t \f]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- raise: RAISE NEWLINE;
- RAISE: 'raise\ \+=\ \{[^\}]*\}'
- {
- start: RAISE PLUS ASSIGN LBR scopeattr? targetattr? funccall_expr RBR;
- scopeattr: SCOPE ASSIGN expression COMMA;
- targetattr: TARGET ASSIGN expression COMMA;
- funccall_expr: functionname LPAR arguments? RPAR;
- functionname: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- arguments: argument (COMMA argument)*;
- argument: (argumentname ASSIGN)? expression;
- argumentname: name;
- expression: nav_expr | atomvalue | tuple | vector | dict |
- unopexpr | binopexpr | funccall_expr | selection;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- @unopexpr: parexpr | notexpr | minusexpr;
- parexpr: LPAR expression RPAR;
- notexpr: NOT expression;
- minusexpr: MINUS expression;
- @binopexpr: selection | andexpr | orexpr | lthanexpr | leqthanexpr |
- gthanexpr | geqthanexpr | equalsexpr | nequalsexpr |
- multexpr | divexpr | modexpr | subtractionexpr | sumexpr;
- dict: LSQBR NEWLINE? dictitems NEWLINE? RSQBR;
- dictitems: dictitem (COMMA NEWLINE? dictitem)*;
- dictitem: expression COLON expression;
- vector: LSQBR NEWLINE? (vectoritems NEWLINE?)? RSQBR;
- vectoritems: vectoritem (COMMA NEWLINE? vectoritem)*;
- vectoritem: expression;
- tuple: LPAR tuplearg (COMMA tuplearg)+ RPAR;
- tuplearg: expression;
- selection: expression LSQBR expression RSQBR;
- andexpr: expression LAND expression;
- orexpr: expression LOR expression;
- lthanexpr: expression LTHAN expression;
- leqthanexpr: expression LEQTHAN expression;
- gthanexpr: expression GTHAN expression;
- geqthanexpr: expression GEQTHAN expression;
- equalsexpr: expression EQUALS expression;
- nequalsexpr: expression NEQUALS expression;
- subtractionexpr: expression MINUS expression;
- sumexpr: expression PLUS expression;
- multexpr: expression MULT expression;
- divexpr: expression DIV expression;
- modexpr: expression MOD expression;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- NOT: 'not';
- TRUE: 'True';
- FALSE: 'False';
- LAND: 'and';
- LOR: 'or';
- RAISE: 'raise';
- SCOPE: 'scope';
- TARGET: 'target';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
-
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- MULT: '\*';
- DIV: '/';
- POTENCY: '@\d';
- LTHAN: '<';
- LEQTHAN: '<=';
- GTHAN: '>';
- GEQTHAN: '>=';
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- EQUALS: '==';
- NEQUALS: '!=';
- PLUS: '\+';
- MINUS: '-';
- MOD: '%';
- LSQBR: '\[';
- RSQBR: '\]';
- LBR: '\{';
- RBR: '\}';
- NEWLINE: '(\r?\n[\t ]*)+'
- (%newline)
- ;
- WS: '[\t \f]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- actions: ACTIONS body NEWLINE;
- CONSTRUCTOR: 'Constructor(\([^\)]*\))?'
- {
- start: CONSTRUCTOR (LPAR formalparameters RPAR)?;
- formalparameters: formalparameter (COMMA formalparameter)*;
- formalparameter: namevalue (COLON nav_expr)?(ASSIGN defaultvalue)?;
- namevalue: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- defaultvalue: atomvalue;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- TRUE: 'True';
- FALSE: 'False';
- CONSTRUCTOR: 'Constructor';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
-
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- WS: '[\t \f\n]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- METHOD: 'Method [^\(]*\([^\)]*\)'
- {
- start: METHOD methodname LPAR formalparameters? RPAR;
- methodname: name;
- formalparameters: formalparameter (COMMA formalparameter)*;
- formalparameter: namevalue (COLON nav_expr)?(ASSIGN defaultvalue)?;
- namevalue: name;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- defaultvalue: atomvalue;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- TRUE: 'True';
- FALSE: 'False';
- METHOD: 'Method';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
-
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- WS: '[\t \f\n]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
- };
- body: BODY;
- BODY: '\{[^\}]*\}'
- {
- start: LBR NEWLINE? statement* RBR;
- @statement: import | funccall_stm | decl_stm |
- assignment | plusassign | minusassign | while_stm
- | ifelse_stm | break_stm | continue_stm | return_stm;
- decl_stm: nav_expr decl_name (ASSIGN expression)? NEWLINE;
- decl_name: name;
- return_stm: RETURN (expression)? NEWLINE;
- ifelse_stm: IF expression COLON NEWLINE
- statementbody
- (ELSE COLON NEWLINE
- statementbody
- )? END NEWLINE
- ;
- while_stm: WHILE expression COLON NEWLINE statementbody END NEWLINE;
- statementbody: statement+;
- break_stm: BREAK NEWLINE;
- continue_stm: CONTINUE NEWLINE;
- import: (FROM fromname)? IMPORT importname (AS asname)? NEWLINE;
- fromname: dotted_name;
- importname: dotted_name | MULT;
- asname: name;
- funccall_stm: (expression '->')? functionname LPAR arguments? RPAR NEWLINE;
- funccall_expr: (expression '->')? functionname LPAR arguments? RPAR;
- nav_expr: self? | (self DOT)? dotexpression;
- self: SELF;
- dotexpression: dotted_name;
- functionname: name;
- arguments: argument (COMMA argument)*;
- argument: (argumentname ASSIGN)? expression;
- argumentname: name;
- assignment: expression ASSIGN expression NEWLINE;
- plusassign: expression PLUSASSIGN expression NEWLINE;
- minusassign: expression MINUSASSIGN expression NEWLINE;
- expression: nav_expr | atomvalue | tuple | vector | dict |
- unopexpr | binopexpr | funccall_expr | selection;
- atomvalue: integervalue | floatvalue | booleanvalue | stringvalue;
- integervalue: integer;
- floatvalue: float;
- booleanvalue: boolean;
- stringvalue: string;
- @unopexpr: parexpr | notexpr | minusexpr;
- parexpr: LPAR expression RPAR;
- notexpr: NOT expression;
- minusexpr: MINUS expression;
- @binopexpr: selection | andexpr | orexpr | lthanexpr | leqthanexpr |
- gthanexpr | geqthanexpr | equalsexpr | nequalsexpr |
- multexpr | divexpr | modexpr | subtractionexpr | sumexpr;
- dict: LSQBR NEWLINE? dictitems NEWLINE? RSQBR;
- dictitems: dictitem (COMMA NEWLINE? dictitem)*;
- dictitem: expression COLON expression;
- vector: LSQBR NEWLINE? (vectoritems NEWLINE?)? RSQBR;
- vectoritems: vectoritem (COMMA NEWLINE? vectoritem)*;
- vectoritem: expression;
- tuple: LPAR tuplearg (COMMA tuplearg)+ RPAR;
- tuplearg: expression;
- selection: expression LSQBR expression RSQBR;
- andexpr: expression LAND expression;
- orexpr: expression LOR expression;
- lthanexpr: expression LTHAN expression;
- leqthanexpr: expression LEQTHAN expression;
- gthanexpr: expression GTHAN expression;
- geqthanexpr: expression GEQTHAN expression;
- equalsexpr: expression EQUALS expression;
- nequalsexpr: expression NEQUALS expression;
- subtractionexpr: expression MINUS expression;
- sumexpr: expression PLUS expression;
- multexpr: expression MULT expression;
- divexpr: expression DIV expression;
- modexpr: expression MOD expression;
- dotted_name: name (DOT name)*;
- name: NAME;
- NAME: '[a-zA-Z_][a-zA-Z_0-9]*(?!r?"|r?\')'
- (%unless
- IMPORT: 'import';
- AS: 'as';
- FROM: 'from';
- NOT: 'not';
- TRUE: 'True';
- FALSE: 'False';
- LAND: 'and';
- LOR: 'or';
- IF: 'if';
- ELSE: 'else';
- WHILE: 'while';
- BREAK: 'break';
- CONTINUE: 'continue';
- RETURN: 'return';
- END: 'end';
- SELF: 'self';
- );
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- MULT: '\*';
- DIV: '/';
- POTENCY: '@\d';
- LTHAN: '<';
- LEQTHAN: '<=';
- GTHAN: '>';
- GEQTHAN: '>=';
- ASSIGN: '=';
- PLUSASSIGN: '\+=';
- MINUSASSIGN: '\-=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- EQUALS: '==';
- NEQUALS: '!=';
- PLUS: '\+';
- MINUS: '-';
- MOD: '%';
- LSQBR: '\[';
- RSQBR: '\]';
- LBR: '\{';
- RBR: '\}';
- NEWLINE: '(\r?\n[\t ]*)+'
- (%newline)
- ;
- WS: '[\t \f]+' (%ignore);
- COMMENT: '\#[^\n]*'(%ignore);
-
- INDENT: '<INDENT>';
- DEDENT: '<DEDENT>';
- };
- // specific tokens
- CLASS: 'Class';
- TOP: 'Top';
- BOTTOM: 'Bottom';
- INPORT: 'Inport';
- OUTPORT: 'Outport';
- NAMEATTR: 'name';
- DEFAULTATTR: 'default';
- TYPEATTR: 'type';
- CLASSATTR: 'class';
- PRIORITYATTR: 'priority';
- ASSOCIATION: 'Association';
- INHERITANCE: 'Inheritance';
- COMPOSITION: 'Composition';
- AGGREGATION: 'Aggregation';
- ATTRIBUTE: 'Attribute';
- MIN: 'min';
- MAX: 'max';
- DESTRUCTOR: 'Destructor';
- STATEMACHINE: 'StateMachine';
- STATE: 'State';
- INITIAL: 'initial';
- FINAL: 'final';
- HISTORY: 'history';
- ORTHOGONAL: 'Orthogonal';
- TRANSITION: 'Transition';
- TARGETATTR: 'target';
- PORTATTR: 'port';
- ACTIONS: 'Actions';
- ONENTER: 'OnEnter';
- ONEXIT: 'OnExit';
- // general tokens
- TRUE: 'True';
- FALSE: 'False';
- boolean: TRUE | FALSE;
- DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
- FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
- integer: DEC_NUMBER;
- float: FLOAT_NUMBER;
- STRVALUE : 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')' ;
- LONG_STRVALUE : '(?s)u?r?(""".*?(?<!\\)(\\\\)*?"""|\'\'\'.*?(?<!\\)(\\\\)*?\'\'\')'
- (%newline)
- ;
- string: (STRVALUE|LONG_STRVALUE) string?;
- MULT: '\*';
- DIV: '/';
- POTENCY: '@\d';
- LTHAN: '<';
- LEQTHAN: '<=';
- GTHAN: '>';
- GEQTHAN: '>=';
- ASSIGN: '=';
- DOT: '\.';
- COLON: ':';
- LPAR: '\(';
- RPAR: '\)';
- COMMA: ',';
- EQUALS: '==';
- PLUS: '\+';
- MINUS: '-';
- MOD: '%';
- LSQBR: '\[';
- RSQBR: '\]';
- NEWLINE: '(\r?\n[\t ]*)+' // Don't count on the + to prevent multiple NEWLINE tokens. It's just an optimization
- (%newline)
- ;
- // ignores
- WS: '[\t \f]+' (%ignore);
- LINE_CONT: '\\[\t \f]*\r?\n' (%ignore) (%newline);
- COMMENT: '\#[^\n]*'(%ignore);
- // identation
- INDENT: '<INDENT>';
- DEDENT: '<DEDENT>';
- EOF: '<EOF>';
- ###
- from plyplus.grammars.python_indent_postlex import PythonIndentTracker
- self.lexer_postproc = PythonIndentTracker
|