I am wrting a small csharp console application which reads text from console, do some some manipulations and returns a string. For this, I am using Antlr. The grammar file is shown below.
grammar test;
options {
language = CSharp2;
output = AST;
}
start returns [String res]: expression EOF
{
$res=$expression.res;
} ;
expression returns [String res]
: Identifier {$res=$Identifier.text}
|Num {$res=$num.text;
|function {$res=function.res}
;
function: 'left' '( Identifier ')'{some code here}
| 'right' '( Identifier ')'{some code here}
|..........
;
Num : (Minus)?('0'..'9')+ ;
Identifier : ('a'..'z'|'A'..'Z'|'\\'|'/'|'_'|':'|';'|'?'|'.'|'0'..'9')('a'..'z'|'A'..'Z'|'\\'|'/'|'_'|':'|';'|'.'|'?'|'0'..'9')*;
I have several such functions which do some string manipulations. Now, I want Antlr to identify these function names irrespective of case. At present, it accepts only lower case letters as function names like.. upper(asdf). I cannot convert every token to lower case in my application as it changes the case of Identifiers also. How can I achieve this ?
Simply define the appropriate token. So, for the code above:
or, if you are sure you want have cases like
lEfT: