|
|
Re: Lexing/parsing advice sought [message #1143857 is a reply to message #1143328] |
Fri, 18 October 2013 09:25   |
Eclipse User |
|
|
|
[Edit: Sorry, pilot error, the code under test was using a different instruction that is still assigned the old rule. I still have a question about my SC_COMMENT rule though!]
OK, here's my full grammar.
grammar com.holycityaudio.spincad.SpinCAD with org.eclipse.xtext.common.Terminals
generate spinCAD "http://www.holycityaudio.com/spincad/SpinCAD"
Program:
equates += Equate*
mem += Mem*
comments += Comment*
instructions += Instruction*
;
// {Instruction}
//-----------------------------------------------------------------------------
Equate:
EquDouble | EquInt | EquEyeD;
EquDouble:
'equ' ename = ID value = SPINREAL
;
EquInt:
'equ' ename = ID value = INT
;
EquEyeD:
'equ' ename = ID value = ID
;
Comment:
cname = SC_COMMENT
;
Mem:
'mem' buffer = ID length = INT
;
Instruction:
Inst_B15_S1_9 |
Inst_B6_S1_14 |
Inst_S1_14_S1_10 |
Inst_B6 |
Inst_B24 |
Inst |
Skip |
Jam
;
Inst_B6_S1_14:
ReadRegister |
WriteRegister |
ReadRegisterFilter |
Maxx |
WriteRegisterHighPass |
WriteRegisterLowPass
;
Inst_B15_S1_9:
ReadDelay |
WriteDelay |
WriteAllPass
;
Inst_B6:
Mulx |
Ldax
;
Inst_B24:
And |
Or |
Xor
;
Inst:
Clr | Not | Absa
;
Inst_S1_14_S1_10:
Exp | ScaleOffset
;
ReadRegister: 'rdax' arg1 = ID ',' arg2 = SPINREAL;
WriteRegisterLowPass: 'wrlx' arg1 = ID ',' arg2 = SPINREAL;
WriteRegisterHighPass: 'wrhx' arg1 = ID ',' arg2 = SPINREAL;
WriteRegister: 'wrax' arg1 = ID ',' arg2 = SPINREAL;
Maxx: 'maxx' arg1 = ID ',' arg2 = SPINREAL;
ReadRegisterFilter: 'rdfx' arg1 = ID ',' arg2 = SPINREAL;
Mulx: 'mulx' arg1 = ID;
Ldax: 'ldax' arg1 = ID;
Exp: 'exp' arg1 = SPINREAL ',' arg2 = SPINREAL;
ScaleOffset: 'sof' arg1 = SPINREAL ',' arg2 = SPINREAL;
WriteDelay: 'wra' arg1 = ID ('^' | '#' | ('+' arg3 = INT))? ',' arg2 = SPINREAL;
WriteAllPass: 'wrap' arg1 = ID ('^' | '#' | ('+' arg3 = INT))? ',' arg2 = SPINREAL;
ReadDelay: 'rda' arg1 = ID ('^' | '#' | ('+' arg3 = INT))? ',' arg2 = SPINREAL;
And: 'and' arg1 = INT;
Or: 'or' arg1 = INT;
Xor: 'xor' arg1 = INT;
Clr: 'clr';
Not: 'not';
Absa: 'absa';
Skip: 'skp' arg1 = ID ',' arg2 = ID;
Jam: 'jam' arg1=ID;
//------------------------
terminal SPINREAL : ('0'..'1') '.' ('0'..'9')*;
terminal SC_COMMENT : ';' !('\n'|'\r')* ('\r'? '\n')?;
//terminal LABEL : ('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
// terminal MEMADDR : ('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')* ('+' INT)?;
Many thanks!
GW
[Updated on: Fri, 18 October 2013 21:53] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06519 seconds