#1055 Misc BNF grammar problems

jessevdam Sat 3 Apr 2010

I found a missing character ":" in the bnf defenition of <ctorChain>

<ctorDef> := <facets> <ctorFlags> "new" <id> "(" <params> ")" \[ctorChain\]

<methodBody>

<ctorFlags> := \[<protection>\]

-<ctorChain> := <ctorChainThis> | <ctorChainSuper>

+<ctorChain> := ":" <ctorChainThis> | <ctorChainSuper>

<ctorChainThis> := "this" "." <id> "(" <args> ")"

<ctorChainSuper> := "super" \["." <id>\] "(" <args> ")"

Is the bnf grammer in the help up to date with the current implementation of the language?

brian Sat 3 Apr 2010

I pushed a fix, thanks.

The grammar should be up-to-date, but have bugs since I don't generate my parser from it (my tokenizer and parser is all hand coded). I know @tcolar has been basing his NetBeans parser on the grammar and has been helping me keep things up to date.

KevinKelley Sat 3 Apr 2010

IT was hammered on quite a bit in the 1.0.47 version timeframe, a few months ago, by tcolar for his FantomIDE and by me for my tools; but I'm not aware that it's been heavily tested recently. I'm sure it's intended to be up to date, modulo the occasional miss (like that one); Brian's good about feeding changes back into documentation.

I need to get my things synced up with current state, too; so please keep reporting if you find anything else questionable.

tcolar Sat 3 Apr 2010

There are a couple of things i had to change to make it work, and omissions, I tried to comment it all in my Parser class, so if you wade through the comments here, you will findall the other "issues" I found with the grammar:

http://www.colar.net/websvn/filedetails.php?repname=src&path=/Fan/src/net/colar/netbeans/fan/parboiled/FantomParser.java

The parser is up to date and parses all fantom distro source files without errors. (My netbeans IDE release is not yet because i"m working a few more issues, but it should come soon).

I'll try to pull out all my changes and list them here soon.

tcolar Sat 3 Apr 2010

Grammar fixes (some might have been fixed already)

  • CompUnit: allow for extra docs at end of file (if last type commented out)
  • TypeDef: Some fantom code has protection after modifiers(static private), so allowing that
  • TypeDef: Static block support missing from Fan grammar
  • FieldDef: Type required for fields(no inferred) (Grammar sya optional)
  • MethodDef: Fan grammar misses final as valid modifier
  • CtorDef: // Fantom Grammar page is missing the : for callChain
  • itemList/mapList: Allow extra trailing comma
  • Uri: //missing from Fantom litteral page, special URI escape sequences sequence(\\, firstOf(:,'/','#','[',']','@','&','=',';','?')),

Grammar Ambiguities: Stuff that won't work as-is in the parser:

  • Don't allow field accesors to be parsed as itBlock (context dependant)
  • Usually the \n is mmeaningless ... but not always, a bit of a case by case
  • [,':' : mapType & simpleMapTypes are ambigous, you could have [Str:Int:Str] and not know how to parse it. Those can be a real pain in the but, [ types in maps can be lists, maps(with or without brackets) and the ":" can also be confusing between map separator, qualified type separator :: and ternary expr separator.

Not really grammar issues, but parser performance issues: Many expressions rewritten for faster parsing, for example

  • compareExpr & rangeExpr: Changed to not allow zeroOrMore as there can be only one comparaison check in an expression (no 3< x <5)

I have more of that kind of optimization, but won't list here are it's not garmmar issues per say.

brian Sat 3 Apr 2010

Promoted to ticket #1055 and assigned to brian

go thru tcolar's list and make sure we have docs up-to-date

jessevdam Sun 4 Apr 2010

<itAdd> := <expr> ("," <expr>)* <eos>

should be

<itAdd> := <expr> "," (<expr> ",")* \[<expr>\]

Or that is how it currently implemented in the fantorm parser

brian Thu 6 May 2010

Renamed from bnf grammer small fault and question to Misc BNF grammar problems

brian Thu 6 May 2010

Ticket resolved in 1.0.53

OK, I pushed a fix which I think covers everything noted in this ticket - changeset

Let me know if I missed anything.

Login or Signup to reply.