Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar Exp;
- Number
- : Digit+
- ;
- // Only for testing purposes...
- ipSum returns [double value]
- : o0=Number'.'o1=Number'.'o2=Number'.'o3=Number {$value = Double.parseDouble($o0.text) +
- Double.parseDouble($o1.text) +
- Double.parseDouble($o2.text) +
- Double.parseDouble($o3.text);}
- ;
- Ip : Octet'.'Octet'.'Octet'.'Octet
- ;
- Mac : Hexbyte':'Hexbyte':'Hexbyte':'Hexbyte':'Hexbyte':'Hexbyte
- ;
- Id : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
- ;
- fragment
- Octet
- : ('0'..'9')
- | ('0'..'9')('0'..'9')
- | '00'('0'..'9')
- | '1'('0'..'9')('0'..'9')
- | '2'('0'..'4')('0'..'9')
- | '25'('0'..'5')
- ;
- fragment
- Hexbyte
- : Hexdigit Hexdigit
- ;
- fragment
- Hexdigit
- : ('a'..'f')|Digit
- ;
- fragment
- Digit
- : '0'..'9'
- ;
- WS
- : (' ' | '\t' | '\r'| '\n') {$channel=HIDDEN;}
- ;
Add Comment
Please, Sign In to add comment