[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to write SableCC Productions
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;
[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