2019-07-29 23:45:16 -04:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
=====================
|
|
|
|
|
|
|
|
Copyright © 2019 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 ArmControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
** Parser Rules
|
|
|
|
**/
|
|
|
|
|
|
|
|
prog : statement* EOF;
|
|
|
|
|
|
|
|
statement : command ( ';' command )* NEWLINE?
|
|
|
|
| NEWLINE
|
|
|
|
;
|
|
|
|
|
|
|
|
command
|
2019-07-30 10:26:05 -04:00
|
|
|
: 'go' ( coords | name value | name ) #Go
|
|
|
|
| 'pause' number #Pause
|
|
|
|
| 'wait' number? #Wait
|
|
|
|
| 'pass' #Pass
|
2019-07-29 23:45:16 -04:00
|
|
|
;
|
|
|
|
|
|
|
|
coords : '{' value? ( seperator value? )* '}' ;
|
|
|
|
|
|
|
|
name : NAME ;
|
|
|
|
|
|
|
|
value
|
|
|
|
: number
|
|
|
|
| hexidecimal
|
|
|
|
;
|
|
|
|
|
|
|
|
number
|
|
|
|
: NUMBER
|
|
|
|
;
|
|
|
|
|
|
|
|
hexidecimal
|
|
|
|
: HEX
|
|
|
|
;
|
|
|
|
|
|
|
|
seperator
|
|
|
|
: SEPERATOR
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
** LEXAR Rules
|
|
|
|
**/
|
|
|
|
|
|
|
|
NAME
|
|
|
|
: [a-zA-Z_][a-zA-Z_0-9]*
|
|
|
|
;
|
|
|
|
|
|
|
|
NUMBER
|
|
|
|
: DIGIT+ ('.' DIGIT+)?
|
|
|
|
;
|
|
|
|
|
|
|
|
HEX
|
|
|
|
: HexDigit HexDigit
|
|
|
|
;
|
|
|
|
|
|
|
|
fragment
|
|
|
|
DIGIT
|
|
|
|
: [0-9]
|
|
|
|
;
|
|
|
|
|
|
|
|
fragment
|
|
|
|
HexDigit
|
|
|
|
: [0-9a-fA-F]
|
|
|
|
;
|
|
|
|
|
|
|
|
SEPERATOR
|
|
|
|
: ','
|
|
|
|
;
|
|
|
|
|
|
|
|
NEWLINE // return newlines to parser
|
|
|
|
: '\r'? '\n'
|
|
|
|
;
|
|
|
|
|
|
|
|
WS // ignore whitespace
|
|
|
|
: [ \t]+ -> skip
|
|
|
|
;
|
|
|
|
|
|
|
|
COMMENT // ignore inline commkents
|
|
|
|
: ( '//' ~[\r\n]*
|
|
|
|
| '#' ~[\r\n]*
|
|
|
|
) -> skip
|
|
|
|
;
|