Hello Andrius, Without being entirely sure, I noted the following two: First, the ' (quote) should appear as follows in the lexer rules: '\'' Second, you are defining the rString, rChar as tokens. Is this what you meant to do?
I am not sure if the following grammar matches what you want, but it works for your example: grammar loggram; rVal : CO STRING CO; CHAR_FOO: 'a'..'z'; STRING : CHAR_FOO+ '_' CHAR_FOO+; CO : '\''; HTH, Nikos On Tue, Feb 1, 2011 at 3:59 PM, Andrius Bentkus <[email protected]>wrote: > Hello, > > I'm trying to write a very simple log parser with ANTLR to compare it to my > current one (which is just a bunch of regexes). > The problem that I'm facing is that I don't know how to parse random input. > In my case the input looks something like this: "word1_word2" > > > What I came by so far is this: > rVal: CO rString CO; > rString: rChar | rChar rString; > rChar: ( 'a'..'z' | '/' | '_' | '0'..'9' | '.' ); > CO: '"'; > > rVal should match the rule (imo), but I just get the error line 1:1 no > viable alternative at input 'de_dust'. > Maybe you guys got some better ideas, or could explain me why it doesn't. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
