Book a Demo

Author Topic: Grammar Errors - Need advice  (Read 2814 times)

Leslie Sherman

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Grammar Errors - Need advice
« on: October 16, 2013, 08:07:16 am »
Hi,

I am trying to create a Grammar file for ColdFusion to allow my group to import ColdFusion classes into EA. I tweaked the ssl.nbnf file that comes with EA 10 to support the syntax of ColdFusion but am encountering issues with it completing the class definition.

My ColdFusion test class is
<cfcomponent displayname="LASTestController" hint="Idostuff">
      <cfset variables.instance.errors = nullString>
</cfcomponent>

I am able to validate my grammar file without errors or warnings. When I try to parse it in the Grammar Debugger, I receive the error:
Error: Unexpected symbol ' hint='.(Line 2 Column 45)

My grammar definitions related to this are below. If in the Test code class I remove the text with "hint="Idostuff"", it will successfully read the class. Once I add in the "hint" text it fails with the error above. I have tried a number of different ways to handle this but it doesn't seem to work.

I suspect it is a syntax issues.
Do you have any suggestions on what I am doing wrong in my syntax?

caseInsensitive();
<simpleName>                                          ::= <IDENTIFIER>;
<IDENTIFIER>                                          ::= ("a".."z" | "_") ("a".."z" | "0".."9" | "_")*;
<classDeclaration>      ::= node("CLASS", node("DECLARATION", "<cfcomponent " "displayname" <className> [<classNotes>] ">" ) node("BODY", <classBody> ) "</cfcomponent>");


<className>                                                ::= "=\"" attribute("NAME", <simpleName>) "\""|
                                                                  " =\"" attribute("NAME", <simpleName>) "\"";

<classNotes>                                          ::= "hint=\"" attribute("DESCRIPTION", <simpleName>)"\""|
                                                                  "hint =" attribute("DESCRIPTION", <simpleName>) "\"";

Any suggestions would be greatly appreciated!!

Regards,

Leslie

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Grammar Errors - Need advice
« Reply #1 on: October 16, 2013, 08:53:44 am »
I would try separating the portions of the string.

ie. "hint" "=\""

if whitespace is a possibility use
"hint" "=" "\""

I just can't remember if it doesn't like to see identifiers in the same literal as punctuation.

Leslie Sherman

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Grammar Errors - Need advice
« Reply #2 on: October 17, 2013, 08:51:33 am »
I updated the classDeclaration and classNotes to be:
<classDeclaration>                                    ::= node("CLASS", node("DECLARATION", "<cfcomponent " "displayname" <className> [<classInherits>] [<classNotes>] ">" ) node("BODY", <classBody> ) "</cfcomponent>");

<classNotes>                                          ::= "hint" "=" "\"" attribute("DESCRIPTION", <simpleName>) "\"";

I still receive the same error. It doesn't seem to handle multiple text phrases well.

I still receive the same error.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Grammar Errors - Need advice
« Reply #3 on: October 17, 2013, 09:49:37 am »
I can't see the error.

Have you tried using the Grammar debugger to see what it tries?

Leslie Sherman

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Grammar Errors - Need advice
« Reply #4 on: October 18, 2013, 02:39:34 am »
Simon,

Thank you for responding to my post and trying to help me.

I am receiving the error from the Grammar Debugger. The only info I receive about the error is

Error: Unexpected symbol ' hint=' (line 2 Column 45)

The only thing that seems to get rid of the error is to remove the hint="Idostuff" text from the sample code. It doesn't seem to be able to map the hint text to the <classNotes> definition.

could there be a syntax issue in another part of the file that is causing this issue but not coming out in the debug error?

Regards,

Leslie

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Grammar Errors - Need advice
« Reply #5 on: October 18, 2013, 09:04:29 am »
Ah, I think at least part of the problem is that the grammar debugger won't show you all the steps the parser took unless the parse succeeded. (That a bug and we have fixed it for a future version.)

The problem is probably in your tokenization rules.

What does your tokenization rule look like?

ie.
Code: [Select]
lex(<TOKENS>);
<TOKENS> ::= <WHITESPACE>+ |
                       <COMMENT> |
                       <NUMBER> |
                       <STRING> |
                       token( keywords() | <IDENTIFIER> );