On Sep 11, 2008, at 9:12 AM, Егор Абрамович wrote:
> Hello,
>
> In my test I am trying to create a grammar that should capitalize all
> words in text.
> Supposing text contains of english characters, punctuation marks and
> numbers.
> Here is my grammar (with line numbers added):
>
> -------------------------------->8--- start of UpperAll.g
>
> 01: grammar UpperAll;
> 02: options {output=template; rewrite=true;}
> 03:
> 04: sent_en : ( en+=en_word PUNKT? INT? )+ //->
> template(words={$en}) "<words; separator=\" \">"
> 05: ;
> 06:
> 07: en_word : ('A'..'Z' | 'a'..'z' )+ -> template(word={
> TestUpperAll.caps($en_word.text) }) "<word>"
> 08: ;
> 09:
> 10: PUNKT : '.' | ',' | '!' | '?' | '(' | ')';
> 11: INT : '0'..'9'+ ;
> 12: NEWLINE : '\r'? '\n' ;
> 13: WS : (' '|'\t'|'\n'|'\r')+ {$channel = HIDDEN;} ;
>
> -------------------------------->8--- end of UpperAll.g
>
> When trying to generate, I am getting an error message:
>
> Check Grammar reported some errors:
> error(201):UpperAll.g:4:40: The following alternative can never be
> matched: 2
>
> Here is console output:
>
> [10:40:53] warning(200): UpperAll.g:4:28: Decision can match input
> such as "PUNKT" using multiple alternatives: 1, 2
This makes no sense since en_word is not optional... oh, right. see
next sentence.
note that you should not use .. range op in parser rules. put EN_WORD
in lexer.
The range of characters is somehow overlapping with parser tokens...
Use En_word or something.
Ter
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---