Created
October 7, 2018 21:14
-
-
Save lvjp/7449854156a61f63661b0817da4b0fad to your computer and use it in GitHub Desktop.
ANTLR4.7 : Lexer more and getText() are not friend ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lexer grammar MoreSetTextLexer; | |
tokens { | |
DecodedValue | |
} | |
ValueDetector: '@' -> more, pushMode(ValueDecoder); | |
mode ValueDecoder; | |
EndOfValue : '@' -> popMode, type(DecodedValue); | |
SpecialChar | |
: '&' ~([;])* ';' | |
{ | |
final String text = getText(); | |
System.out.println("An & --> " + getText()); | |
setText("&" + getText().substring(1, getText().length() -1).toUpperCase() + ";"); | |
} | |
-> more | |
; | |
Others : . { System.out.println("One more char: " + getText()); } -> more ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parser grammar MoreSetTextParser; | |
options { | |
tokenVocab=MoreSetTextLexer; | |
} | |
file : DecodedValue+ ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment