I'm trying to use Antlr4 to process the following from a file:
process example(test){
run $test say hi
}
My grammar looks like the following:
grammar example;
main: process* EOF;
processCall: processName '(' processArg ')';
process: ('process' | 'Process' | 'PROCESS') processName '(' processArg ') {' IDENTIFIER?
processArgReplaces IDENTIFIER? '}';
processArgReplaces: IDENTIFIER? '$' processArg IDENTIFIER?;
processName: WORD;
processArg: (WORD ',')* WORD;
WORD: [a-zA-Z0-9?_]+;
IDENTIFIER: [a-zA-Z] [ a-zA-Z0-9?_]+;
BS: [\r\n\t\f]+ -> skip;
But my output gives me no viable alternative at input 'process example name('
The problem is I need to support spaces in certain areas.
process name(arg){
[anything here is one token]
OR
anotherprocess(arg) [comes out as {anotherprocess} and {arg}]
}
I've tried changing the IDENTIFIER around as I think it's taking over the match before process
has a chance to, but wouldn't the explicit token mean that line wouldn't be just generic words?