| 54 |
|
assignment : ID ASSIGNEQUAL^ constant SEMICOLON! |
| 55 |
|
; |
| 56 |
|
|
| 57 |
< |
constant : signedNumber |
| 57 |
> |
constant : intConst |
| 58 |
> |
| floatConst |
| 59 |
|
| ID |
| 60 |
|
| StringLiteral |
| 61 |
|
; |
| 83 |
|
; |
| 84 |
|
|
| 85 |
|
atomstatement : assignment |
| 86 |
< |
| POSITION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
| 87 |
< |
| ORIENTATION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
| 86 |
> |
| POSITION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 87 |
> |
| ORIENTATION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 88 |
|
; |
| 89 |
|
|
| 90 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
< |
signedNumberTuple : signedNumber (COMMA! signedNumber)* |
| 134 |
> |
doubleNumberTuple : doubleNumber (COMMA! doubleNumber)* |
| 135 |
|
; |
| 136 |
|
|
| 137 |
|
inttuple : intConst (COMMA! intConst)* |
| 139 |
|
|
| 140 |
|
protected |
| 141 |
|
intConst |
| 142 |
< |
: OCTALINT | DECIMALINT | HEXADECIMALINT |
| 142 |
> |
: NUM_INT | NUM_LONG |
| 143 |
|
; |
| 144 |
|
|
| 145 |
|
protected |
| 146 |
< |
signedNumber : |
| 146 |
> |
doubleNumber : |
| 147 |
|
(intConst | floatConst) |
| 148 |
|
; |
| 149 |
|
|
| 150 |
|
protected |
| 151 |
|
floatConst |
| 152 |
|
: |
| 153 |
< |
FLOATONE | FLOATTWO |
| 153 |
> |
NUM_FLOAT | NUM_DOUBLE |
| 154 |
|
; |
| 155 |
|
|
| 156 |
|
|
| 206 |
|
RBRACKET : ']' ; |
| 207 |
|
LCURLY : '{' ; |
| 208 |
|
RCURLY : '}' ; |
| 208 |
– |
|
| 209 |
– |
|
| 210 |
– |
/* |
| 211 |
– |
EQUAL : "==" ; |
| 212 |
– |
NOTEQUAL : "!=" ; |
| 213 |
– |
LESSTHANOREQUALTO : "<=" ; |
| 214 |
– |
LESSTHAN : "<" ; |
| 215 |
– |
GREATERTHANOREQUALTO : ">=" ; |
| 216 |
– |
GREATERTHAN : ">" ; |
| 217 |
– |
|
| 218 |
– |
DIVIDE : '/' ; |
| 219 |
– |
DIVIDEEQUAL : "/=" ; |
| 220 |
– |
PLUS : '+' ; |
| 221 |
– |
PLUSEQUAL : "+=" ; |
| 222 |
– |
PLUSPLUS : "++" ; |
| 223 |
– |
MINUS : '-' ; |
| 224 |
– |
MINUSEQUAL : "-=" ; |
| 225 |
– |
MINUSMINUS : "--" ; |
| 226 |
– |
STAR : '*' ; |
| 227 |
– |
TIMESEQUAL : "*=" ; |
| 228 |
– |
MOD : '%' ; |
| 229 |
– |
MODEQUAL : "%=" ; |
| 230 |
– |
SHIFTRIGHT : ">>" ; |
| 231 |
– |
SHIFTRIGHTEQUAL : ">>=" ; |
| 232 |
– |
SHIFTLEFT : "<<" ; |
| 233 |
– |
SHIFTLEFTEQUAL : "<<=" ; |
| 234 |
– |
|
| 235 |
– |
AND : "&&" ; |
| 236 |
– |
NOT : '!' ; |
| 237 |
– |
OR : "||" ; |
| 238 |
– |
|
| 239 |
– |
AMPERSAND : '&' ; |
| 240 |
– |
BITWISEANDEQUAL : "&=" ; |
| 241 |
– |
TILDE : '~' ; |
| 242 |
– |
BITWISEOR : '|' ; |
| 243 |
– |
BITWISEOREQUAL : "|=" ; |
| 244 |
– |
BITWISEXOR : '^' ; |
| 245 |
– |
BITWISEXOREQUAL : "^=" ; |
| 246 |
– |
*/ |
| 247 |
– |
|
| 209 |
|
|
| 210 |
|
Whitespace |
| 211 |
|
: |
| 356 |
|
) |
| 357 |
|
; |
| 358 |
|
|
| 398 |
– |
// Numeric Constants: |
| 359 |
|
|
| 360 |
|
protected |
| 361 |
+ |
Vocabulary |
| 362 |
+ |
: |
| 363 |
+ |
'\3'..'\377' |
| 364 |
+ |
; |
| 365 |
+ |
|
| 366 |
+ |
|
| 367 |
+ |
ID |
| 368 |
+ |
options {testLiterals = true;} |
| 369 |
+ |
: |
| 370 |
+ |
('a'..'z'|'A'..'Z'|'_') |
| 371 |
+ |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
| 372 |
+ |
; |
| 373 |
+ |
|
| 374 |
+ |
|
| 375 |
+ |
protected |
| 376 |
|
Digit |
| 377 |
|
: |
| 378 |
|
'0'..'9' |
| 384 |
|
('0'..'9')+ |
| 385 |
|
; |
| 386 |
|
|
| 387 |
+ |
// hexadecimal digit (again, note it's protected!) |
| 388 |
|
protected |
| 389 |
< |
LongSuffix |
| 390 |
< |
: 'l' |
| 391 |
< |
| 'L' |
| 416 |
< |
; |
| 389 |
> |
HEX_DIGIT |
| 390 |
> |
: ('0'..'9'|'A'..'F'|'a'..'f') |
| 391 |
> |
; |
| 392 |
|
|
| 418 |
– |
protected |
| 419 |
– |
UnsignedSuffix |
| 420 |
– |
: 'u' |
| 421 |
– |
| 'U' |
| 422 |
– |
; |
| 393 |
|
|
| 394 |
< |
protected |
| 395 |
< |
FloatSuffix |
| 396 |
< |
: 'f' |
| 397 |
< |
| 'F' |
| 398 |
< |
; |
| 394 |
> |
// a numeric literal |
| 395 |
> |
NUM_INT |
| 396 |
> |
{ |
| 397 |
> |
bool isDecimal = false; |
| 398 |
> |
ANTLR_USE_NAMESPACE(antlr)RefToken t = ANTLR_USE_NAMESPACE(antlr)nullToken; |
| 399 |
> |
} |
| 400 |
> |
: ('+' | '-')? |
| 401 |
> |
( |
| 402 |
> |
'.' {_ttype = DOT;} |
| 403 |
> |
( ('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})? |
| 404 |
> |
{ |
| 405 |
> |
if ( t && |
| 406 |
> |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
| 407 |
> |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
| 408 |
> |
_ttype = NUM_FLOAT; |
| 409 |
> |
} |
| 410 |
> |
else { |
| 411 |
> |
_ttype = NUM_DOUBLE; // assume double |
| 412 |
> |
} |
| 413 |
> |
} |
| 414 |
> |
)? |
| 415 |
|
|
| 416 |
< |
protected |
| 417 |
< |
Exponent |
| 418 |
< |
: |
| 419 |
< |
('e'|'E'|'d'|'D') ('+'|'-')? (Digit)+ |
| 420 |
< |
; |
| 416 |
> |
| ( '0' {isDecimal = true;} // special case for just '0' |
| 417 |
> |
( ('x'|'X') |
| 418 |
> |
( // hex |
| 419 |
> |
// the 'e'|'E' and float suffix stuff look |
| 420 |
> |
// like hex digits, hence the (...)+ doesn't |
| 421 |
> |
// know when to stop: ambig. ANTLR resolves |
| 422 |
> |
// it correctly by matching immediately. It |
| 423 |
> |
// is therefor ok to hush warning. |
| 424 |
> |
options { |
| 425 |
> |
warnWhenFollowAmbig=false; |
| 426 |
> |
} |
| 427 |
> |
: HEX_DIGIT |
| 428 |
> |
)+ |
| 429 |
> |
| //float or double with leading zero |
| 430 |
> |
(('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+ |
| 431 |
> |
| ('0'..'7')+ // octal |
| 432 |
> |
)? |
| 433 |
> |
| ('1'..'9') ('0'..'9')* {isDecimal=true;} // non-zero decimal |
| 434 |
> |
) |
| 435 |
> |
( ('l'|'L') { _ttype = NUM_LONG; } |
| 436 |
|
|
| 437 |
< |
protected |
| 438 |
< |
Vocabulary |
| 439 |
< |
: |
| 440 |
< |
'\3'..'\377' |
| 441 |
< |
; |
| 442 |
< |
|
| 443 |
< |
Number |
| 444 |
< |
: |
| 445 |
< |
('+'|'-')? |
| 446 |
< |
( |
| 447 |
< |
( (Digit)+ ('.' | 'e' | 'E' | 'd' | 'D' ) )=> |
| 448 |
< |
(Digit)+ |
| 449 |
< |
( '.' (Digit)* (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
| 450 |
< |
| Exponent {_ttype = FLOATTWO;} //Zuo 3/12/01 |
| 451 |
< |
) //{_ttype = DoubleDoubleConst;} |
| 452 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
| 453 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
| 453 |
< |
)? |
| 454 |
< |
| |
| 455 |
< |
'.' {_ttype = DOT;} |
| 456 |
< |
( (Digit)+ (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
| 457 |
< |
//{_ttype = DoubleDoubleConst;} |
| 458 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
| 459 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
| 460 |
< |
)? |
| 461 |
< |
)? |
| 462 |
< |
| |
| 463 |
< |
'0' ('0'..'7')* //{_ttype = IntOctalConst;} |
| 464 |
< |
(LongSuffix //{_ttype = LongOctalConst;} |
| 465 |
< |
|UnsignedSuffix //{_ttype = UnsignedOctalConst;} |
| 466 |
< |
)* {_ttype = OCTALINT;} |
| 467 |
< |
| |
| 468 |
< |
'1'..'9' (Digit)* //{_ttype = IntIntConst;} |
| 469 |
< |
(LongSuffix //{_ttype = LongIntConst;} |
| 470 |
< |
|UnsignedSuffix //{_ttype = UnsignedIntConst;} |
| 471 |
< |
)* {_ttype = DECIMALINT;} |
| 472 |
< |
| |
| 473 |
< |
'0' ('x' | 'X') ('a'..'f' | 'A'..'F' | Digit)+ |
| 474 |
< |
//{_ttype = IntHexConst;} |
| 475 |
< |
(LongSuffix //{_ttype = LongHexConst;} |
| 476 |
< |
|UnsignedSuffix //{_ttype = UnsignedHexConst;} |
| 477 |
< |
)* {_ttype = HEXADECIMALINT;} |
| 437 |
> |
// only check to see if it's a float if looks like decimal so far |
| 438 |
> |
| {isDecimal}? |
| 439 |
> |
( '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})? |
| 440 |
> |
| EXPONENT (f3:FLOAT_SUFFIX {t=f3;})? |
| 441 |
> |
| f4:FLOAT_SUFFIX {t=f4;} |
| 442 |
> |
) |
| 443 |
> |
{ |
| 444 |
> |
if ( t && |
| 445 |
> |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
| 446 |
> |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
| 447 |
> |
_ttype = NUM_FLOAT; |
| 448 |
> |
} |
| 449 |
> |
else { |
| 450 |
> |
_ttype = NUM_DOUBLE; // assume double |
| 451 |
> |
} |
| 452 |
> |
} |
| 453 |
> |
)? |
| 454 |
|
) |
| 455 |
< |
; |
| 455 |
> |
; |
| 456 |
|
|
| 457 |
< |
ID |
| 458 |
< |
options {testLiterals = true;} |
| 459 |
< |
: |
| 460 |
< |
('a'..'z'|'A'..'Z'|'_') |
| 461 |
< |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
| 462 |
< |
; |
| 457 |
> |
// a couple protected methods to assist in matching floating point numbers |
| 458 |
> |
protected |
| 459 |
> |
EXPONENT |
| 460 |
> |
: ('e'|'E') ('+'|'-')? ('0'..'9')+ |
| 461 |
> |
; |
| 462 |
> |
|
| 463 |
> |
protected |
| 464 |
> |
FLOAT_SUFFIX |
| 465 |
> |
: 'f'|'F'|'d'|'D' |
| 466 |
> |
; |