grammar improvements
This commit is contained in:
parent
ef40c3e962
commit
7758b76c7d
121
CommentMacro.g4
121
CommentMacro.g4
|
@ -1,52 +1,52 @@
|
||||||
grammar CommentMacro;
|
grammar CommentMacro;
|
||||||
|
|
||||||
/** The grammer begins here, as a series of statements. */
|
/**
|
||||||
prog: statement+ ;
|
** Parser Rules
|
||||||
|
**/
|
||||||
|
|
||||||
/** Each statement has one or many expressions */
|
prog : statement+ EOF ;
|
||||||
statement
|
|
||||||
: macro NEWLINE
|
statement : macro (':' macro)* NEWLINE
|
||||||
| NEWLINE
|
| NEWLINE
|
||||||
;
|
;
|
||||||
|
|
||||||
macro
|
macro
|
||||||
: 'GM' master device? // Go Master
|
: 'GM' master (device)? // Go Master
|
||||||
| 'GM' master SLASH number device? // Go Master
|
| 'GM' master SLASH number (device)? // Go Master
|
||||||
| 'HM' master device? // Halt Master
|
| 'HM' master (device)? // Halt Master
|
||||||
| 'AM' master device? // Assert Master
|
| 'AM' master (device)? // Assert Master
|
||||||
| 'RM' master device? // Relesae Master
|
| 'RM' master (device)? // Relesae Master
|
||||||
| 'RA' device? // Release All
|
| 'RA' (device)? // Release All
|
||||||
| 'RO' device? // Release Others
|
| 'RO' (device)? // Release Others
|
||||||
| 'FM' master SLASH number time? device? // Fade Master
|
| 'FM' master SLASH number (time)? (device)? // Fade Master
|
||||||
| 'FGM' number time? device? // Fade Grand Master
|
| 'FGM' number (time)? (device)? // Fade Grand Master
|
||||||
| 'CM' number device? // Choose Master
|
| 'CM' number (device)? // Choose Master
|
||||||
| 'GL' target device? // Go List
|
| 'GL' target (device)? // Go List
|
||||||
| 'GL' target SLASH number device? // Go List
|
| 'GL' target SLASH number (device)? // Go List
|
||||||
| 'HL' target device? // Halt List
|
| 'HL' target (device)? // Halt List
|
||||||
| 'AL' target device? // Assert List
|
| 'AL' target (device)? // Assert List
|
||||||
| 'RL' target device? // Release List
|
| 'RL' target (device)? // Release List
|
||||||
| 'GB' target device? // Go Batch
|
| 'GB' target (device)? // Go Batch
|
||||||
| 'HB' target device? // Halt Batch
|
| 'HB' target (device)? // Halt Batch
|
||||||
| 'AB' target device? // Assert Batch
|
| 'AB' target (device)? // Assert Batch
|
||||||
| 'RB' target device? // Release Batch
|
| 'RB' target (device)? // Release Batch
|
||||||
| 'GS' target device? // Go Scene
|
| 'GS' target (device)? // Go Scene
|
||||||
| 'HS' target device? // Halt Scene
|
| 'HS' target (device)? // Halt Scene
|
||||||
| 'AS' target device? // Assert Scene
|
| 'AS' target (device)? // Assert Scene
|
||||||
| 'RS' target device? // Release Scene
|
| 'RS' target (device)? // Release Scene
|
||||||
| 'CP' number device? // Change Page
|
| 'CP' number (device)? // Change Page
|
||||||
| 'CP' NEXT device? // Next Page
|
| 'CP' NEXT (device)? // Next Page
|
||||||
| 'CP' PREV device? // Prev Page
|
| 'CP' PREV (device)? // Prev Page
|
||||||
| 'RV' number device? // Recall View
|
| 'RV' number (device)? // Recall View
|
||||||
| 'RN' device // Reset Node
|
| 'RN' device // Reset Node
|
||||||
| 'GK' number device? // Go Keystroke Macro
|
| 'GK' number (device)? // Go Keystroke Macro
|
||||||
| 'HK' number device? // Halt Keystroke Macro
|
| 'HK' number (device)? // Halt Keystroke Macro
|
||||||
| 'RK' number device? // Stop Keystroke Macro
|
| 'RK' number (device)? // Stop Keystroke Macro
|
||||||
;
|
;
|
||||||
|
|
||||||
master : (target | CURRENT) ;
|
master : (target | CURRENT) ;
|
||||||
time : TIME number ;
|
time : TIME number ;
|
||||||
device : nodeType number ;
|
device : nodeType number ;
|
||||||
number : NUMBER ;
|
|
||||||
|
|
||||||
nodeType
|
nodeType
|
||||||
: WHOLEHOG
|
: WHOLEHOG
|
||||||
|
@ -56,43 +56,36 @@ nodeType
|
||||||
|
|
||||||
/** recursive targeting is non-greedy */
|
/** recursive targeting is non-greedy */
|
||||||
target
|
target
|
||||||
: ( number | span ) also*?
|
: ( number | span ) (',' target)*
|
||||||
;
|
;
|
||||||
|
|
||||||
span
|
span
|
||||||
: number THRU number
|
: number THRU number
|
||||||
;
|
;
|
||||||
|
|
||||||
also
|
number : NUMBER ;
|
||||||
: ALSO target
|
|
||||||
;
|
|
||||||
|
|
||||||
SLASH : '/' ;
|
|
||||||
ALSO : ',' ;
|
/**
|
||||||
THRU : '>' ;
|
** LEXAR Rules
|
||||||
NEXT : '+' ;
|
**/
|
||||||
PREV : '-' ;
|
|
||||||
CURRENT : '*' ;
|
SLASH : '/' ;
|
||||||
TIME : 't' ;
|
THRU : '>' ;
|
||||||
|
NEXT : '+' ;
|
||||||
|
PREV : '-' ;
|
||||||
|
CURRENT : '*' ;
|
||||||
|
TIME : 't' ;
|
||||||
|
|
||||||
WHOLEHOG : [hH] ;
|
WHOLEHOG : [hH] ;
|
||||||
DP8K : [dD] ;
|
DP8K : [dD] ;
|
||||||
IOP : 'IOP';
|
IOP : 'IOP';
|
||||||
|
|
||||||
NUMBER // intigers or floats
|
fragment DIGIT : [0-9] ;
|
||||||
: [0-9]+ '.' [0-9]*
|
NUMBER : DIGIT+ ('.' DIGIT+)? ;
|
||||||
| '.' [0-9]+
|
|
||||||
| [0-9]+
|
|
||||||
;
|
|
||||||
|
|
||||||
NEWLINE // return newlines to parser (end-statement signal)
|
NEWLINE : '\r'? '\n' ; // return newlines to parser
|
||||||
: '\r'? '\n'
|
WS : [ \t]+ -> skip ; // ignore whitespace
|
||||||
;
|
|
||||||
|
|
||||||
WS // ignore whitespace
|
|
||||||
: [ \t]+
|
|
||||||
-> skip
|
|
||||||
;
|
|
||||||
|
|
||||||
COMMENT // toss c and HTML sytle block comments
|
COMMENT // toss c and HTML sytle block comments
|
||||||
: ( '<!--' .*? '-->'
|
: ( '<!--' .*? '-->'
|
||||||
|
@ -100,7 +93,7 @@ COMMENT // toss c and HTML sytle block comments
|
||||||
) -> skip
|
) -> skip
|
||||||
;
|
;
|
||||||
|
|
||||||
LINE_COMMENT
|
LINE_COMMENT // ignore inline commkents
|
||||||
: ( '//' ~[\r\n]*
|
: ( '//' ~[\r\n]*
|
||||||
| '#' ~[\r\n]*
|
| '#' ~[\r\n]*
|
||||||
) -> skip
|
) -> skip
|
||||||
|
|
|
@ -17,7 +17,7 @@ You must also install the ANTLR tool. On a mac with homebrew, do:
|
||||||
|
|
||||||
Clone this repository and building the lexer and parser for Python3
|
Clone this repository and building the lexer and parser for Python3
|
||||||
|
|
||||||
> $ antlr4 -Dlanguage=Python3 CommentMacro.g4
|
> $ antlr -Dlanguage=Python3 CommentMacro.g4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,6 @@ These Comment Macros do not have supporting equivelents in OSC:
|
||||||
Pleas feel welcome to submit pull requests or patches that enable support for:
|
Pleas feel welcome to submit pull requests or patches that enable support for:
|
||||||
|
|
||||||
* Sending target ranges as batches
|
* Sending target ranges as batches
|
||||||
* Multiple comment macros per line
|
* More than one comment macros per line
|
||||||
* Send multi-macro line as a batch
|
* Send multi-macro line as a batch
|
||||||
* Timing on master fades
|
* Timing on master fades
|
||||||
|
|
Loading…
Reference in New Issue