My grammar contains the following (condensed):
block:
: specialfunction
specialfunction
: SPECIALFUNCTION OPAR (parameter (',' parameter)*)? CPAR
;
SPECIALFUNCTION : 'FUNCTION1'| 'FUNCTION2';
The list of possible values for SPECIALFUNCTION can and will change over time. The names are also used elsewhere in the code so rather than hardcoding them in the grammar and code, I'd like to have a method that returns valid SPECIALFUNCTIONs that can then be called from various places in the code as well as the grammar.
SPECIALFUNCTION : <make a call to get the current list of SPECIALFUNCTIONS e.g. SomeClass.GetListOfNames>
public SomeClass
{
public string GetListOfNames()
{
return "'FUNCTION1' | 'ANOTHERSPECIALFUNCTION' | 'NEWONE'";
}
}
Then as new SpecialFunctions are added I'd just add'em to GetListOfNames.
Note I am using C#.