Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Started with ANTLR
    primarykey
    data
    text
    <p>a few days ago I posted this question on the ANTLR mailinglist, but didn't recieve any support. So I'm hoping you guys here can help me out:</p> <p>I am currently trying to dig into Antlr as I find this tool very helpful. The last Time I used it, I generated something based upon a finished grammar. This time I wanted to build my own grammar and really start understanding what's happening.</p> <p>For this I decided to build a parser for some Wiki-Notation-Like text.</p> <p>Here an example (without the -Start - and - End - row):</p> <pre><code>------------ Start --------------- before More before And yet even more ... [Lineup] [Floor:Main Floor] Test1 Test2 [Floor:Classics Floor] Test3 Test4 Test5 Test6 [/Lineup] after more After .. And even more. ------------ End --------------- </code></pre> <p>If the text contains a "Lineup" block, then this should be parsed. The content is at least one "Floor" followed by a number of Names, a new "Floor" or the closing "Lineup" I managed my parser to parse the text if I change my grammar and the text I am trying to parse to "[Floor:]" (One Block) but I really need a name in there :(</p> <p>As soon as I change my Grammar to support the Floor-Name, nothing works anymore. Could you please help me with this? I'm not looking for someone that fixes it for me without a comment. I would really like to know why my grammar doesn't work. I'm really stuck and I'm working on this for days now (Ok ... I admit, it's just my spare time after work ... but at least all of that).</p> <p>Here comes my gammar. If I try to parse the full text, I allways get EarlyExitExceptions while parsing the :( :</p> <pre><code>grammar CalendarEventsJava; /*------------------------------------------------------------------ * PARSER RULES *------------------------------------------------------------------*/ event : ( (LINE_CONTENT | NEWLINE)* (lineup (LINE_CONTENT | NEWLINE)*)? ); lineup : (LINEUP_OPEN NEWLINE floor+ LINEUP_CLOSE); floor : (FLOOR_OPEN LINE_CONTENT FLOOR_CLOSE NEWLINE lineupEntry+); lineupEntry : (LINE_CONTENT? NEWLINE); artist : LINE_CONTENT; /*------------------------------------------------------------------ * LEXER RULES *------------------------------------------------------------------*/ LINEUP_OPEN : '[Lineup]'; LINEUP_CLOSE : '[/Lineup]'; FLOOR_OPEN : '[Floor:'; FLOOR_CLOSE : ']'; BLANKS : ( ' ' | '\t' )+; NONBREAKING : ~('\r' | '\n' | ']'); NEWLINE : '\r'? '\n'; // the content of a line consists of at least one non-breaking character. LINE_CONTENT : (NONBREAKING | ']')+ ; </code></pre> <p>I really hope you can help me, as I'm really anxious to really get started with ANTLR, cause I think it really rocks :)</p> <p>Chris</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload