I started using antlr to parse a specific file format. The problem is that i don't know how to write correctly my grammar. The file have the following format. It contains multiple lines and each can have the following format: Only hexadecimal caracter with space or not A0 A4 B5 77 Only variable identifier with the format VAR_XXX ex: VAR_MY_VARIABLE Or the combinaison of the two previous format ex: A0 A4B5 VAR_MY_VARIABLE 77 98 VAR_MY_VARIABLE2 or VAR_MY_VARIABLE AA BB or AA BB VAR_MY_VARIABLE what i want to do is t
More>>

I started using antlr to parse a specific file format.

The problem is that i don't know how to write correctly my grammar.

The file have the following format.

It contains multiple lines and each can have the following format:

Only hexadecimal caracter with space or not

A0 A4 B5 77

Only variable identifier with the format VAR_XXX

ex: VAR_MY_VARIABLE

Or the combinaison of the two previous format

ex:

A0 A4B5 VAR_MY_VARIABLE 77 98 VAR_MY_VARIABLE2

or

VAR_MY_VARIABLE AA BB

or

AA BB VAR_MY_VARIABLE

what i want to do is to build a AST tree

And the problem is that i don't know how to do this with antlr. the tool always tell me that multiple rule can be applies with my grammar.