#666 Grammar tweaks

KevinKelley Sat 11 Jul 2009

I think tcolar mentioned this one too a while back, but nullable types don't show up in the Fan grammar page.

I think all four of simpleType, listType, mapType, and funcType can be nullable most places in the grammar, so I added a

<nullableType>  = <type> ("?")? ;

production, and changed occurrences of <type> to <nullableType> where it seemed to make sense.

Another little grammar typo is, in all three of classHeader, mixinHeader, and enumHeader, after the "class" literal for ex., there should be an <id>.

tcolar Sat 11 Jul 2009

Yeah there was that, and few other thing, like allowing trailing comma in list & maps and few other things.

If that helps here is the grammar i have : http://svn.colar.net/Fan/src/net/colar/netbeans/fan/antlr/Fan.g

it's a little hard to read cause there are some ANTLR specific and i'm still working on it as far as building an AST goes so it's till chnaging, but the parsing itself works on all .fan file in the fan distro.

tcolar Sat 11 Jul 2009

Most of the things i added/changed from the fandev grammar page, i did comment out in my antlr grammar, so you can "find" most of the fixes in there.

brian Sat 11 Jul 2009

Thanks for catching that stuff.

I fixed the class headers.

I changed the type productions to be:

<type>           :=  <nullType> | <nonNullType>
<nullType>       :=  <nonNullType> "?"
<nonNullType>    :=  <simpleType> | <listType> | <mapType> | <funcType>

You like that?

KevinKelley Sat 11 Jul 2009

Thanks, looks good to me.

Login or Signup to reply.