Your NUMBER
rule has been heavily manually left-factored. In reality, it is a single lexer rule that produces 9 different types of token. The left-factoring was likely performed due to the way ANTLR 3 lexers use prediction with a recursive descent parser. ANTLR 4 uses a completely different lexer algorithm based on DFAs. The error you see is a result of this change - since ANTLR 4 lexers are no longer recursive-descent parsers, they no longer have the ability to execute action code at arbitrary points.
The most effective way to write the above rule in ANTLR 4 is to use the "inefficient" syntax from ANTLR 3. In ANTLR 4, it will not be slow.
EMS
: NUMBER E M
;
EXS
: NUMBER E X
;
LENGTH
: NUMBER P X
| NUMBER P T
| NUMBER P C
| NUMBER C M
| NUMBER M M
| NUMBER I N
;
TIME
: NUMBER M S
| NUMBER S
;
ANGLE
: NUMBER D E G
| NUMBER R A D
;
FREQ
: NUMBER K? H Z
;
DIMENSION
: NUMBER IDENT
;
PERCENTAGE
: NUMBER '%'
;
NUMBER
: [0-9] ('.' [0-9]+)?
| '.' [0-9]+
;