help-bison
[Top][All Lists]
Advanced

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

How to implement optional semicolon rules


From: Matthias Simon
Subject: How to implement optional semicolon rules
Date: Sat, 15 Nov 2014 15:25:33 +0100
User-agent: Roundcube Webmail/0.7.1

Hi,

I am struggling with some semicolon rules for some time now. In this language (TTCN3) statements end with an mandatory semicolon, except there is a curly bracket around. Example:

// -------------8<-------------[SNIP!]
    {
        var integer a;
        var integer b[2] := { 23, 5 }
        var integer c
    }
// ------------->8-------------[SNAP!]


Declaration for variable b does not require a terminating semicolon, due to closing bracket of its initialization. Also declaration of variable c needs no semicolon due to the closing block.

TTCN3's grammar is already quite complex, therefore I made semicolon _always_ mandatory and patched the lexer to `inject' semicolons when they were expected by bison. This turned out to be quite hacky, so I am a little clueless here. Perhaps you have some ideas how to solve this nicely?

Cheers!

Matthias



reply via email to

[Prev in Thread] Current Thread [Next in Thread]