[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parser help



Dave, 

You need to give names to your production alternatives. For example:

index_list =
          {empty}  //empty
        | {single} index_clause
        | {no_sep} index_list index_clause
        | {sep}    index_list semicolon index_clause
        ;

Then SableCC is able to generate AEmptyIndexList, ASingleIndexList, etc.
Otherwise it has to use the name of the production (index_list) for the
alternatives so it tries to generate more than one AIndexList class: an
error.

This is explained in more detail in chapter 5 of Etienne's thesis.


On Tue, 2003-09-23 at 10:50, Dave Makalsky wrote:
> Hi,
> 
> I am in the process of creating a parser for the Eiffel language; grammar is
> here: http://gobosoft.com/eiffel/syntax/index.html
> 
> I will make this grammar Free Software and available as soon as I am done.
> 
> I am starting to learn sablecc by just parsing the indexing portion of the
> grammar.
> 
> So, given a file looking like this:
> 
> indexing
> 
>   -- comment, ignore me
> 
>   foo : "happy"
>   bar : "sad"
>   foobar : "[happy
>              sad ]"
>   ident   : var1, var2
> end
> 
> I have enclosed my grammar file (see eiffel.grammar).  For some reason, when
> compiling I get the following error (see err.txt)
> 
> Any help would be most appreciated.
> 
> Cheers,
> 
> Dave Makalsky
>   
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> ----
> 

> java.lang.RuntimeException: [0,0] Redefinition of AIndexList.
> 	at org.sablecc.sablecc.ResolveIds.error(Unknown Source)
> 	at org.sablecc.sablecc.ResolveIds.inAParsedAlt(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAParsedAlt(Unknown Source)
> 	at org.sablecc.sablecc.node.AParsedAlt.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAAltsTail(Unknown Source)
> 	at org.sablecc.sablecc.node.AAltsTail.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAAlts(Unknown Source)
> 	at org.sablecc.sablecc.node.AAlts.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAProd(Unknown Source)
> 	at org.sablecc.sablecc.node.AProd.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAProductions(Unknown Source)
> 	at org.sablecc.sablecc.node.AProductions.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseAGrammar(Unknown Source)
> 	at org.sablecc.sablecc.node.AGrammar.apply(Unknown Source)
> 	at org.sablecc.sablecc.analysis.DepthFirstAdapter.caseStart(Unknown Source)
> 	at org.sablecc.sablecc.node.Start.apply(Unknown Source)
> 	at org.sablecc.sablecc.SableCC.processGrammar(Unknown Source)
> 	at org.sablecc.sablecc.SableCC.processGrammar(Unknown Source)
> 	at org.sablecc.sablecc.SableCC.main(Unknown Source)