2018-10-21 22:14:50 -04:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
=====================
|
|
|
|
|
|
|
|
Copyright © 2018 Kevin Matz (kevin@company235.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person
|
|
|
|
obtaining a copy of this software and associated documentation
|
|
|
|
files (the “Software”), to deal in the Software without
|
|
|
|
restriction, including without limitation the rights to use,
|
|
|
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following
|
|
|
|
conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2018-10-17 20:56:59 -04:00
|
|
|
grammar CommentMacro;
|
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
/**
|
|
|
|
** Parser Rules
|
|
|
|
**/
|
2018-10-17 20:56:59 -04:00
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
prog : statement+ EOF ;
|
|
|
|
|
2018-10-20 15:54:47 -04:00
|
|
|
statement : macro (':' macro)* NEWLINE?
|
2018-10-20 13:21:57 -04:00
|
|
|
| NEWLINE
|
|
|
|
;
|
2018-10-17 20:56:59 -04:00
|
|
|
|
|
|
|
macro
|
2018-10-20 13:21:57 -04:00
|
|
|
: 'GM' master (device)? // Go Master
|
|
|
|
| 'GM' master SLASH number (device)? // Go Master
|
|
|
|
| 'HM' master (device)? // Halt Master
|
|
|
|
| 'AM' master (device)? // Assert Master
|
|
|
|
| 'RM' master (device)? // Relesae Master
|
|
|
|
| 'RA' (device)? // Release All
|
|
|
|
| 'RO' (device)? // Release Others
|
|
|
|
| 'FM' master SLASH number (time)? (device)? // Fade Master
|
|
|
|
| 'FGM' number (time)? (device)? // Fade Grand Master
|
|
|
|
| 'CM' number (device)? // Choose Master
|
|
|
|
| 'GL' target (device)? // Go List
|
|
|
|
| 'GL' target SLASH number (device)? // Go List
|
|
|
|
| 'HL' target (device)? // Halt List
|
|
|
|
| 'AL' target (device)? // Assert List
|
|
|
|
| 'RL' target (device)? // Release List
|
|
|
|
| 'GB' target (device)? // Go Batch
|
|
|
|
| 'HB' target (device)? // Halt Batch
|
|
|
|
| 'AB' target (device)? // Assert Batch
|
|
|
|
| 'RB' target (device)? // Release Batch
|
|
|
|
| 'GS' target (device)? // Go Scene
|
|
|
|
| 'HS' target (device)? // Halt Scene
|
|
|
|
| 'AS' target (device)? // Assert Scene
|
|
|
|
| 'RS' target (device)? // Release Scene
|
|
|
|
| 'CP' number (device)? // Change Page
|
|
|
|
| 'CP' NEXT (device)? // Next Page
|
|
|
|
| 'CP' PREV (device)? // Prev Page
|
|
|
|
| 'RV' number (device)? // Recall View
|
|
|
|
| 'RN' device // Reset Node
|
|
|
|
| 'GK' number (device)? // Go Keystroke Macro
|
|
|
|
| 'HK' number (device)? // Halt Keystroke Macro
|
|
|
|
| 'RK' number (device)? // Stop Keystroke Macro
|
2018-10-17 20:56:59 -04:00
|
|
|
;
|
|
|
|
|
|
|
|
master : (target | CURRENT) ;
|
|
|
|
time : TIME number ;
|
|
|
|
device : nodeType number ;
|
|
|
|
|
|
|
|
nodeType
|
|
|
|
: WHOLEHOG
|
|
|
|
| DP8K
|
|
|
|
| IOP
|
|
|
|
;
|
|
|
|
|
|
|
|
/** recursive targeting is non-greedy */
|
|
|
|
target
|
2018-10-20 13:21:57 -04:00
|
|
|
: ( number | span ) (',' target)*
|
2018-10-17 20:56:59 -04:00
|
|
|
;
|
|
|
|
|
|
|
|
span
|
|
|
|
: number THRU number
|
|
|
|
;
|
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
number : NUMBER ;
|
|
|
|
|
2018-10-17 20:56:59 -04:00
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
/**
|
|
|
|
** LEXAR Rules
|
|
|
|
**/
|
|
|
|
|
2018-10-20 15:54:47 -04:00
|
|
|
fragment DIGIT : [0-9] ;
|
|
|
|
NUMBER : DIGIT+ ('.' DIGIT+)? ;
|
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
SLASH : '/' ;
|
|
|
|
THRU : '>' ;
|
|
|
|
NEXT : '+' ;
|
|
|
|
PREV : '-' ;
|
|
|
|
CURRENT : '*' ;
|
|
|
|
TIME : 't' ;
|
2018-10-17 20:56:59 -04:00
|
|
|
|
|
|
|
WHOLEHOG : [hH] ;
|
|
|
|
DP8K : [dD] ;
|
|
|
|
IOP : 'IOP';
|
|
|
|
|
2018-10-20 15:54:47 -04:00
|
|
|
NEWLINE : '\r'? '\n' ; // return newlines to parser
|
|
|
|
WS : [ \t]+ -> skip ; // ignore whitespace
|
2018-10-17 20:56:59 -04:00
|
|
|
|
|
|
|
COMMENT // toss c and HTML sytle block comments
|
|
|
|
: ( '<!--' .*? '-->'
|
|
|
|
| '/*' .*? '*/'
|
|
|
|
) -> skip
|
|
|
|
;
|
|
|
|
|
2018-10-20 13:21:57 -04:00
|
|
|
LINE_COMMENT // ignore inline commkents
|
2018-10-17 20:56:59 -04:00
|
|
|
: ( '//' ~[\r\n]*
|
|
|
|
| '#' ~[\r\n]*
|
|
|
|
) -> skip
|
|
|
|
;
|