formatting

This commit is contained in:
Tom Everett
2016-03-01 17:32:37 -07:00
parent 87901d6b54
commit bd65c3a3a6
+179 -162
View File
@@ -33,229 +33,246 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
grammar pdp7asm; grammar pdp7asm;
prog prog
: line+ : line +
; ;
line line
: declarations? comment? eol : declarations? comment? eol
; ;
declarations declarations
: declaration (';' declaration)* : declaration (';' declaration)*
; ;
declaration declaration
: label? (instruction | assignment | expression)? : label? (instruction | assignment | expression)?
; ;
instruction instruction
: opcode argument* : opcode argument*
; ;
argument argument
: expression : expression
; ;
assignment assignment
: (variable | LOC | RELOC) '=' expression : (variable | LOC | RELOC) '=' expression
; ;
expression expression
: multiplyingExpression ((PLUS|MINUS) multiplyingExpression)* : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)*
; ;
multiplyingExpression multiplyingExpression
: atom ((TIMES|DIV) atom)* : atom ((TIMES | DIV) atom)*
; ;
atom atom
: variable : variable
| LOC | LOC
| RELOC | RELOC
| STRING | STRING
| DECIMAL | DECIMAL
| DECIMAL_MINUS | DECIMAL_MINUS
| OCTAL | OCTAL
| OCTAL_LITERAL | OCTAL_LITERAL
| d | d
; ;
d d
: '-'? DECIMAL_LITERAL : '-'? DECIMAL_LITERAL
; ;
eol eol
: EOL : EOL
; ;
comment comment
: COMMENT : COMMENT
; ;
label label
: LABEL : LABEL
; ;
variable variable
: IDENTIFIER : IDENTIFIER
; ;
opcode opcode
: 'dac' : 'dac'
| 'jms' | 'jms'
| 'dzm' | 'dzm'
| 'lac' | 'lac'
| 'xor' | 'xor'
| 'add' | 'add'
| 'tad' | 'tad'
| 'xct' | 'xct'
| 'isz' | 'isz'
| 'and' | 'and'
| 'sad' | 'sad'
| 'jmp' | 'jmp'
| 'nop' | 'nop'
| 'i' | 'i'
| 'law' | 'law'
| 'cma' | 'cma'
| 'las' | 'las'
| 'ral' | 'ral'
| 'rar' | 'rar'
| 'hlt' | 'hlt'
| 'sma' | 'sma'
| 'sza' | 'sza'
| 'snl' | 'snl'
| 'skp' | 'skp'
| 'sna' | 'sna'
| 'szl' | 'szl'
| 'rtl' | 'rtl'
| 'rtr' | 'rtr'
| 'cil' | 'cil'
| 'rcl' | 'rcl'
| 'rcr' | 'rcr'
| 'cia' | 'cia'
| 'lrs' | 'lrs'
| 'lrss' | 'lrss'
| 'lls' | 'lls'
| 'llss' | 'llss'
| 'als' | 'als'
| 'alss' | 'alss'
| 'mul' | 'mul'
| 'idiv' | 'idiv'
| 'lacq' | 'lacq'
| 'clq' | 'clq'
| 'omq' | 'omq'
| 'cmq' | 'cmq'
| 'lmq' | 'lmq'
| 'dscs' | 'dscs'
| 'dslw' | 'dslw'
| 'dslm' | 'dslm'
| 'dsld' | 'dsld'
| 'dsls' | 'dsls'
| 'dssf' | 'dssf'
| 'dsrs' | 'dsrs'
| 'iof' | 'iof'
| 'ion' | 'ion'
| 'caf' | 'caf'
| 'clon' | 'clon'
| 'clsf' | 'clsf'
| 'clof' | 'clof'
| 'ksf' | 'ksf'
| 'krb' | 'krb'
| 'tsf' | 'tsf'
| 'tcf' | 'tcf'
| 'tls' | 'tls'
| 'sck' | 'sck'
| 'cck' | 'cck'
| 'lck' | 'lck'
| 'rsf' | 'rsf'
| 'rsa' | 'rsa'
| 'rrb' | 'rrb'
| 'psf' | 'psf'
| 'pcf' | 'pcf'
| 'psa' | 'psa'
| 'cdf' | 'cdf'
| 'rlpd' | 'rlpd'
| 'lda' | 'lda'
| 'wcga' | 'wcga'
| 'raef' | 'raef'
| 'rlpd' | 'rlpd'
| 'beg' | 'beg'
| 'spb' | 'spb'
| 'cpb' | 'cpb'
| 'lpb' | 'lpb'
| 'wbl' | 'wbl'
| 'dprs' | 'dprs'
| 'dpsf' | 'dpsf'
| 'dpcf' | 'dpcf'
| 'dprc' | 'dprc'
| 'crsf' | 'crsf'
| 'crrb' | 'crrb'
; ;
LOC LOC
: '.' : '.'
; ;
RELOC RELOC
: '..' : '..'
; ;
PLUS PLUS
: '+' : '+'
; ;
MINUS MINUS
: '-' : '-'
; ;
TIMES TIMES
: '*' : '*'
; ;
DIV DIV
: '/' : '/'
; ;
LABEL LABEL
: [a-zA-Z0-9]+ ':' : [a-zA-Z0-9] + ':'
; ;
IDENTIFIER IDENTIFIER
: [a-zA-Z] [a-zA-Z0-9]* : [a-zA-Z] [a-zA-Z0-9]*
; ;
OCTAL_LITERAL OCTAL_LITERAL
: '0' [0-7]* : '0' [0-7]*
; ;
DECIMAL_LITERAL DECIMAL_LITERAL
: [1-9] [0-9]* : [1-9] [0-9]*
; ;
DECIMAL DECIMAL
: 'd' [0-9]+ : 'd' [0-9] +
; ;
OCTAL OCTAL
: 'o' [0-7]+ : 'o' [0-7] +
; ;
DECIMAL_MINUS DECIMAL_MINUS
: 'dm' [0-9]+ : 'dm' [0-9] +
; ;
STRING STRING
: '<' [a-zA-Z0-9$*,%/]+ '>' : '<' [a-zA-Z0-9$*,%/] + '>'
; ;
COMMENT COMMENT
: '"' ~[\r\n]* : '"' ~ [\r\n]*
; ;
EOL EOL
: [\r\n]+ : [\r\n] +
; ;
WS WS
: [ \t] -> skip : [ \t] -> skip
; ;