On 03/03/16 04:05, vignesh kailas wrote:
> I have a grammar like this in antlr ver4:
>
> csrc_includes :
> (header)*
> ;
>
> header : HASH INCLUDE_LITERAL ANGULAR_OPEN FILE_NAME ANGULAR_CLOSE
First of all., csrc_includes and header are parser rules. Shouldn't
they instead be lexer rules?
Second, instead of using csrc_includes in your grammar, could you
instead use:
CSRC_INCLUDES : (HEADER)+
;
Then, instead of referencing CSRC_INCLUDES in your grammar, you could
replace it with references to (CSRC_INCLUDES)? Make their use
optional, but if used require one or more includes to be present.
> The above grammar is throwing an error stating that the csrc_includes
> can evaluate to a null expression as well. Now, I do understand the
> implication of this grammar and the meaning of the error. But is there a
> way that will help me define a grammar like this (implies that there can
> be no header includes inside a c src file).
>
> Big thanks in advance :)
>
> --
> You received this message because you are subscribed to the Google
> Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
antlr-discussi...@googlegroups.com
> <mailto:
antlr-discussi...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.
--
Kevin J. Cummings
kjc...@verizon.net
cumm...@kjchome.homeip.net
cumm...@kjc386.framingham.ma.us
Registered Linux User #1232 (
http://www.linuxcounter.net/)