[antlr-interest] No viable alternative.

Chris Rebert cvrebert at gmail.com
Mon Jul 28 15:39:49 PDT 2008


Just a hunch, but what happens if you add a semicolon at the end of
the first "var" line?

On Mon, Jul 28, 2008 at 12:12 PM,  <rkevinburton at charter.net> wrote:
> I am relatively new to ANTLR and so I decided to look at "modifying" some existing grammars and see what that gives me. I decided to start with a ECMAScript grammar from Xebic Research. The only change I made to it was to add types to the arguments to functions and have it generate C# code. It didn't work :-( The following function declaration works just fine:
>
> function GetCatalogs(catalogContext:CatalogContext)
> {
>  var getCatalogs = catalogContext.GetCatalogs().Catalogs
> }
>
>
> BUt as soon as I add another variable declaration I get a NoViableAlt exception:
>
> function GetCatalogs(catalogContext:CatalogContext)
> {
>  var getCatalogs = catalogContext.GetCatalogs().Catalogs
>  var catalogResponseType = new CatalogDataSet()
> }
>
> Due to the size I will not try to reproduce the applicable rules here but I ran it under ANTLRWorks (Interpeter) and I received the same results. So if you need to test you could take the above function declaration (take out the argument type after the colon if you haven't modified the grammar to handle types) and you should get the same error (starting at functionDeclaration). Any ideas?
>
> Thank you.
>
> Kevin
>


More information about the antlr-interest mailing list