[antlr-interest] Cannot match strings combining terminals w/o spaces between
Samuel Lampa
samuel.lampa at scilifelab.uu.se
Wed Jul 27 02:35:47 PDT 2011
I got problems matching the string:
"history":
... with the following ANTLR code (work in progress, really):
(STRING)':'
Where I have the STRING terminal defined as:
STRING : '"'('a'..'z'|'A'..'Z')+'"'
;
It works if I add the ending colon in the STRING definition itself, like
so (and then remove it from the parent rule):
STRING : '"'('a'..'z'|'A'..'Z')+'"'':'
;
... but this of course makes for a less general string definition :/ ...
Any ideas how I should go about this?
Best regards
// Samuel
Addendum: The full input string and EBNF code is as follows:
=== Input string ===
sam_to_bam.py
--input1=$source.input1
--dbkey=${input1.metadata.dbkey}
#if $source.index_source == "history":
--ref_file=$source.ref_file
#else
--ref_file="None"
#end if
--output1=$output1
--index_dir=${GALAXY_DATA_INDEX_DIR}
=== ANTLR code ===
grammar GalaxyToolConfig;
options {output=AST;}
command : binary param* ifstatement '\n' text? ELSE text? ENDIF text?
;
binary : WORD
;
param : '--' PARAMNAME '=' ( VARIABLE | STRING )
;
ifstatement
: IF ( STRING | VARIABLE ) EQ ( (STRING)':' | (VARIABLE)':' )
;
text : WORD WORD*
;
IF : '#if'
;
ELSE : '#else'
;
ENDIF : '#end if'
;
EQ : '=='
;
COLON : ':'
;
PARAMNAME: ('a'..'z')('a'..'z'|'A'..'Z'|'0'..'9'|'.'|'_')*
;
STRING : '"'('a'..'z'|'A'..'Z')+'"'
;
VARIABLE
: '$''{'?PARAMNAME'}'?
;
// CHAR :
('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'.'|'$'|'{'|'}'|'='|'"'|'-'|':'|';')
// ;
WORD : (~(' '|'\t'|'\r'|'\n'))+
;
WS : ( ' '
| '\t'
| '\r'
| '\n'
) {$channel=HIDDEN;}
;
--
System Expert / Bioinformatician
SNIC-UPPMAX / SciLifeLab Uppsala
Uppsala University, Sweden
--------------------------------------
E-mail: samuel.lampa at scilifelab.uu.se
Phone: +46 (0)18 - 471 1060
WWW: http://www.uppmax.uu.se
Uppnex: https://www.uppnex.uu.se
More information about the antlr-interest
mailing list