1
0
Fork 0
baconscript/CommentMacro.g4

129 lines
4.1 KiB
ANTLR

/*
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.
*/
grammar CommentMacro;
/**
** Parser Rules
**/
prog : statement+ EOF ;
statement : macro (':' macro)* NEWLINE?
| NEWLINE
;
macro
: '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
;
master : (target | CURRENT) ;
time : TIME number ;
device : nodeType number ;
nodeType
: WHOLEHOG
| DP8K
| IOP
;
/** recursive targeting is non-greedy */
target
: ( number | span ) (',' target)*
;
span
: number THRU number
;
number : NUMBER ;
/**
** LEXAR Rules
**/
fragment DIGIT : [0-9] ;
NUMBER : DIGIT+ ('.' DIGIT+)? ;
SLASH : '/' ;
THRU : '>' ;
NEXT : '+' ;
PREV : '-' ;
CURRENT : '*' ;
TIME : 't' ;
WHOLEHOG : [hH] ;
DP8K : [dD] ;
IOP : 'IOP';
NEWLINE : '\r'? '\n' ; // return newlines to parser
WS : [ \t]+ -> skip ; // ignore whitespace
COMMENT // toss c and HTML sytle block comments
: ( '<!--' .*? '-->'
| '/*' .*? '*/'
) -> skip
;
LINE_COMMENT // ignore inline commkents
: ( '//' ~[\r\n]*
| '#' ~[\r\n]*
) -> skip
;