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

AW: How to write SableCC Productions



thank you for your help!

I've tried:

Helpers
  cr = 13 ;
  lf = 10 ;
Tokens
  colon = ':' ;
  underscore = '_';
  letter = ['a'..'z'] + ['A'..'Z'];
  endofline = cr | lf | cr lf ;
  
Productions
  il_instruction = labeltag? il_instruction_rest? eol;
  labeltag = label colon;
  label = identifier;
  il_instruction_rest = 
    {il_simple_operation} il_simple_operation |
    {il_expression} il_expression;
  
  identifier = letter+;   //not true, test only
  eol = endofline+;

so far so good, but now I get the error:
Verifying identifiers.
PIlSimpleOperation and TIlSimpleOperation undefined.

That may be, but I don't know where and how to define.

In the meantime I tried to convert the identifier from BNF:
identifier ::= (letter | ('_' (letter | digit))) {['_'] (letter | digit)}

would be very nice, if somebody could help me.

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


-----Ursprüngliche Nachricht-----
Von: Dan Sandberg [mailto:dan@siliconpoetry.com]
Gesendet: Dienstag, 5. Juni 2001 19:18
An: Roger Keays
Cc: Bittkau Rainer; 'sablecc-list@sable.mcgill.ca'
Betreff: 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
> >