Lost in Parenthesis !
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Julien_FURET
Posted On:   Monday, February 19, 2007 10:20 AM

Hi everyone ! I am currently trying to write a Progress4GL grammar and I am experiencing difficulties with the management of parenthesis surrounding expressions... After several attemps on my own, I looked at Terence Parr's Java 1.3 Recognizer files (mainly java.g) and it seems to work without considering parenthesis ! But when my grammar parses my 4GL source file, it throws exceptions about "unexpected token : (" ... I do not know if my description is clear, so do not hesitate to contact me for further explanations ! Any help will be welcome :-) And please forgive my level of English. Regards. Juli   More>>

Hi everyone !

I am currently trying to write a Progress4GL grammar and I am experiencing difficulties with the management of parenthesis surrounding expressions...



After several attemps on my own, I looked at Terence Parr's Java 1.3 Recognizer files (mainly java.g) and it seems to work without considering parenthesis !



But when my grammar parses my 4GL source file, it throws exceptions about "unexpected token : (" ...



I do not know if my description is clear, so do not hesitate to contact me for further explanations ! Any help will be welcome :-)



And please forgive my level of English.



Regards.



Julien FURET

   <<Less

Re: Lost in Parenthesis !

Posted By:   Julien_FURET  
Posted On:   Monday, February 19, 2007 11:05 AM

Well, I've hesitated a loooong time before posting a message on this forum and as soon as I did it, I found the answer to my problem...



In fact, the best way is, in the lowest level of expression ("primaryExpression" in my case), to reference the highest level ("expression") with parenthesis.





expression :

logicalAndExpression ("or"^ logicalAndExpression)*

;



logicalAndExpression :

equalityExpression ("and"^ equalityExpression)*

;



equalityExpression :

relationalExpression

(EQUALS^ (relationalExpression | ifAffectBlock))*

;



relationalExpression :

additiveExpression

((SUP^|INF^|IE^|SE^|DIFF^) additiveExpression)*

;




additiveExpression :

multiplicativeExpression

((PLUS^ | MOINS^) multiplicativeExpression)*

;




multiplicativeExpression :

primaryExpression

((MUL^ | DIV^ | MOD^ ) primaryExpression)*

;




primaryExpression :

(fonction4GL) => fonction4GlBlock

| (action4GL) => actionBlock

| (AVAILABLE) => AVAILABLE identTable

| (LOCKED) => LOCKED identTable

| identTable

| constant

| LPAREN! (expression | ifAffectBlock) RPAREN!

;




Hope it'll help !
About | Sitemap | Contact