|
|
Re: xtext create open declaration [message #1740793 is a reply to message #1740785] |
Thu, 18 August 2016 14:44 |
Sachin Samaram Messages: 271 Registered: April 2016 |
Senior Member |
|
|
Hi,
I have grammar :
Sm_lib : 'sm_cancel' (exp=Expression);
Expression:
LogicalOr
;
LogicalOr :
BitwiseOr ({LogicalOr.left=current} '||' right=BitwiseOr)*
;
BitwiseOr :
LogicalAnd ({BitwiseOr.left=current} '|' right=LogicalAnd)*
;
LogicalAnd :
BitwiseAnd ({LogicalAnd.left=current} '&&' right=BitwiseAnd)*
;
BitwiseAnd :
Equivalency ({BitwiseAnd.left=current} '&' right=Equivalency)*
;
Equivalency :
Relational (({Equivalency.left=current} '==' | {NotEquivalency.left=current} '!=' | {Assignment.left=current}'=') right=Relational)*
;
Relational :
PlusMinus (({Ge.left=current} '>='| {le.left=current} '<='| {Gt.left=current} '>'| {lt.left=current} '<') right=PlusMinus)*
;
PlusMinus:
DivMult (({Plus.left=current}'+'| {Minus.left=current}'-') right=DivMult)*
;
DivMult:
LogicalNot (({Multiply.left=current} '*'| {Division.left=current}'/') right=LogicalNot)*
;
LogicalNot :
OnesComplement ({LogicalNot.left=current} '!' right=OnesComplement)*
;
OnesComplement :
Exponentiation ({OnesComplement.left=current} ('~') right=Exponentiation)*
;
Exponentiation :
ColonOperator ({Exponentialtion.left=current} '^' right=ColonOperator)*
;
ColonOperator :
PercentOperator | ({ColonOperator} (':'('+')?) expr=PercentOperator)
;
PercentOperator :
ArrowExpression | ({PercentOperator} ('%'|'%t'|'%.'|'%:') expr=ArrowExpression)
;
ArrowExpression :
Concatenation | ({ArrowExpression} ('->') expr=Concatenation)
;
Concatenation :
Primary ({Concatenation.left=current} '##' right=Primary)*
;
Primary:
string=STRING | number=NUMBER | variable=ID (ArrayLiteral+=ArrayLiteral* & SizeLiteral+=SizeLiteral*) | ('(' expression=Expression ')') | FieldNum;
terminal DBMS: ('DBMS'|'Dbms'|'dbms') (('\\'((' '|'\t')* '\r'? '\n')) | !('\n' | '\r'))*;
terminal ID : ('a'..'z'|'A'..'Z'|'$'|'.'|'@'|'_')('a'..'z'|'A'..'Z'|'$'|'.'|'0'..'9'|'@'|'*'|'_')*;
terminal STRING : '"' ( '\\'('"'|('\r'? '\n')) | !('\n'|'"') )* '"' |
"'" ( '\\'("'"|('\r'? '\n')) | !('\n'|"'") )* "'";
terminal SL_COMMENT: '//' !('\n' | '\r')*;
terminal HASH_COMMENT : ('#'('\r'? '\n')?) | ('#' !('#'|'\n'|'\r')+ ('\r'? '\n')?) | (('#''#''#') !('\n'|'\r')* ('\r'? '\n')?);
terminal WS : (' '|'\t'| ('\\'((' '|'\t')* '\r'? '\n')))+;
terminal NL : ('\r'? '\n')+;
terminal NUMBER: SIGN? (OCTAL|FLOAT|INT|BINARY|HEX);
terminal OCTAL returns ecore::EInt: ('0') ('0'..'7')+;
terminal FLOAT returns ecore::EFloat: ('0'..'9' ('0'..'9')*) '.' ('0'..'9')*;
terminal INT returns ecore::EInt: '0'..'9' ('0'..'9')*;
terminal RANGE: '0'..'9' '..' ('0'..'9')*;
terminal BINARY returns ecore::EInt: ('0b'|'0B') ('0'|'1')+;
terminal HEX returns ecore::EInt:('0x'|'0X')('0'..'9'|'a'..'f'|'A'..'F')+;
terminal fragment SIGN : '+' | '-' ;
Now I want to create assignment grammar without any keyword preceded.
Like
a = sm_cancel(true)
Here 'a' is just a variable without a type. And sm_cancel is parser rule. My code is not working because ' a = ' cannot be parsed.
[Updated on: Thu, 18 August 2016 14:45] Report message to a moderator
|
|
|
|
|
Re: xtext create open declaration [message #1740799 is a reply to message #1740797] |
Thu, 18 August 2016 15:07 |
|
as i said i dont want to digg trough 100 lines of grammar to find out which grammar rules you think could satisfy your assignment or not.
this makes everyone no wanting to answer your questions. i mean this serious.
this is why i e.g. dont understand
Sm_lib : 'sm_cancel' (exp=Expression);
why not
Sm_lib : 'sm_cancel' '(' (params+=Expression (','params+=Expression)*)?);
and obiously dont see any try to declare sm_lib to be a Relational. (direcly or indirectly.
e.g. making sm:lib a Primary
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03552 seconds