[antlr-interest] No viable alternative.

rkevinburton at charter.net rkevinburton at charter.net
Mon Jul 28 12:12:07 PDT 2008


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