Syntactic predicates were only used to work around a prediction weakness in ANTLR 3 that is not present in ANTLR 4. You can simply remove them during your transition to ANTLR 4.
Edit:
A syntactic predicate in ANTLR 3 had the following form:
(stuff) =>
Wherever you see that form in your grammar, just remove it. Here's what your second example looks like with the predicates removed.
NUMBER
:(
'0'..'9' ('.' '0'..'9'+)?
| '.' '0'..'9'+
)
(
E
(
M { $type = EMS; }
| X { $type = EXS; }
)
| P
(
X
| T
| C
)
{ $type = LENGTH; }
| C M { $type = LENGTH; }
| M
(
M { $type = LENGTH; }
| S { $type = TIME; }
)
| I N { $type = LENGTH; }
| D E G { $type = ANGLE; }
| R A D { $type = ANGLE; }
| S { $type = TIME; }
| K? H Z { $type = FREQ; }
| IDENT { $type = DIMENSION; }
| '%' { $type = PERCENTAGE; }
| // Just a number
)
;