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

Re: How to write SableCC Productions



Oops.  Thanks for the correction.

-Dan

Roger Keays wrote:
> 
> On Tue, 5 Jun 2001, Dan Sandberg wrote:
> 
> > Hi.
> >
> > You can't put alternatives in parenthesis.  So:
> > il_instruction = ( label colon ) ? ( il_simple_operation | il_expression
> > ) ? eol ;
> >
> > should be
> >
> > il_instruction = ( label colon )? il_instruction_rest? eol;
> > il_instruction_rest = {simple_operator} il_simple_operator |
> >                       {expression} il_expression;
> >
> 
> Is this right? I though parantheses indicated ignored alternatives. I
> think what Bittkau is looking for is:
> 
> il_instruction =  labelcolon? il_instruction_rest? eol;
> labelcolol = label colon
> il_instruction_rest = {simple_operator} il_simple_operator |
>                        {expression} il_expression;
> 
> Regards,
> 
> Roger
> 
> > [Alternatives need to be named, using the {name} notation]
> >
> > Also, I don't see where the label token was defined in the example you
> > gave.
> >
> > I don't know of any tools that convert from BNF automatically.
> >
> > -Dan
> >
> > Bittkau Rainer wrote:
> > >
> > > I'm at the very first steps to write a compiler for the IEC 61131-3 PLC
> > > language.
> > > The following BNF fragment
> > >
> > > il_instruction ::= [label':'][il_simple_operation | il_expression] EOL {EOL}
> > >
> > > transformed to SableCC
> > >
> > > Tokens
> > >   colon = ':' ;
> > >   endofline = cr | lf | cr lf;
> > >   eol = endofline+;
> > > Productions
> > >   il_instruction = ( label colon ) ? ( il_simple_operation | il_expression )
> > > ? eol ;
> > >
> > > Error message:
> > > org.sablecc.sablecc.parser.ParserException: [6,36] TSemicolon TBar excepted.
> > >
> > > [6,36] is the position of the first '?'
> > > What is wrong with it?
> > >
> > > Are there any tools to do the transformation? (there are about 250 other
> > > productions to do)
> > >
> > > TIA
> > >
> > > Mit freundlichen Grüssen
> > > Rainer Bittkau
> > >
> > > Baumer Electric AG, Abt. Betriebsmittel
> > > Hummelstrasse 17
> > > Postfach
> > > CH-8501 Frauenfeld
> > > Tel. ++41 52 728 14 55; Fax. ++41 52 728 17 27
> > > mailto:rbittkau@baumerelectric.com
> > > http://www.baumerelectric.com
> >