| 25 |
|
|
| 26 |
|
tokens |
| 27 |
|
{ |
| 28 |
< |
COMPONENT = "component"; |
| 29 |
< |
MOLECULE = "molecule"; |
| 30 |
< |
ZCONSTRAINT = "zconstraint"; |
| 31 |
< |
ATOM = "atom"; |
| 32 |
< |
BOND = "bond"; |
| 33 |
< |
BEND = "bend"; |
| 34 |
< |
TORSION = "torsion"; |
| 35 |
< |
RIGIDBODY = "rigidBody"; |
| 36 |
< |
CUTOFFGROUP = "cutoffGroup"; |
| 37 |
< |
FRAGMENT = "fragment"; |
| 38 |
< |
MEMBERS = "members"; |
| 39 |
< |
POSITION = "position"; |
| 40 |
< |
ORIENTATION = "orientation"; |
| 28 |
> |
COMPONENT = "component"; |
| 29 |
> |
MOLECULE = "molecule"; |
| 30 |
> |
ZCONSTRAINT = "zconstraint"; |
| 31 |
> |
RESTRAINT = "restraint"; |
| 32 |
> |
ATOM = "atom"; |
| 33 |
> |
BOND = "bond"; |
| 34 |
> |
BEND = "bend"; |
| 35 |
> |
TORSION = "torsion"; |
| 36 |
> |
INVERSION = "inversion"; |
| 37 |
> |
RIGIDBODY = "rigidBody"; |
| 38 |
> |
CUTOFFGROUP = "cutoffGroup"; |
| 39 |
> |
CONSTRAINT = "constraint"; |
| 40 |
> |
DISTANCE = "distance"; |
| 41 |
> |
FRAGMENT = "fragment"; |
| 42 |
> |
MEMBERS = "members"; |
| 43 |
> |
CENTER = "center"; |
| 44 |
> |
SATELLITES = "satellites"; |
| 45 |
> |
POSITION = "position"; |
| 46 |
> |
ORIENTATION = "orientation"; |
| 47 |
> |
FLUCQ = "flucQ"; |
| 48 |
> |
RNEMD = "RNEMD"; |
| 49 |
> |
MINIMIZER = "minimizer"; |
| 50 |
> |
FIXED = "Fixed"; |
| 51 |
> |
HARMONIC = "Harmonic"; |
| 52 |
> |
CUBIC = "Cubic"; |
| 53 |
> |
QUARTIC = "Quartic"; |
| 54 |
> |
POLYNOMIAL = "Polynomial"; |
| 55 |
> |
MORSE = "Morse"; |
| 56 |
> |
GHOSTBEND = "GhostBend"; |
| 57 |
> |
UREYBRADLEY = "UreyBradley"; |
| 58 |
> |
COSINE = "Cosine"; |
| 59 |
> |
GHOSTTORSION = "GhostTorsion"; |
| 60 |
> |
CHARMM = "Charmm"; |
| 61 |
> |
OPLS = "Opls"; |
| 62 |
> |
TRAPPE = "Trappe"; |
| 63 |
> |
AMBERIMPROPER = "AmberImproper"; |
| 64 |
> |
IMPROPERCOSINE = "ImproperCosine"; |
| 65 |
> |
CENTRALATOMHEIGHT = "CentralAtomHeight"; |
| 66 |
> |
DREIDING = "Dreiding"; |
| 67 |
> |
CHARGE = "charge"; |
| 68 |
|
ENDBLOCK; |
| 69 |
|
} |
| 70 |
|
|
| 44 |
– |
{ |
| 45 |
– |
// Suppport C++-style single-line comments? |
| 46 |
– |
} |
| 71 |
|
|
| 72 |
|
mdfile : (statement)* |
| 73 |
|
; |
| 74 |
|
|
| 75 |
|
statement : assignment |
| 76 |
< |
| componentblock |
| 77 |
< |
| moleculeblock |
| 78 |
< |
| zconstraintblock |
| 79 |
< |
; |
| 80 |
< |
|
| 76 |
> |
| componentblock |
| 77 |
> |
| moleculeblock |
| 78 |
> |
| zconstraintblock |
| 79 |
> |
| restraintblock |
| 80 |
> |
| flucqblock |
| 81 |
> |
| rnemdblock |
| 82 |
> |
| minimizerblock |
| 83 |
> |
; |
| 84 |
> |
|
| 85 |
|
assignment : ID ASSIGNEQUAL^ constant SEMICOLON! |
| 86 |
|
; |
| 87 |
|
|
| 88 |
< |
constant : signedNumber |
| 88 |
> |
constant : intConst |
| 89 |
> |
| floatConst |
| 90 |
> |
| vectorConst |
| 91 |
|
| ID |
| 92 |
|
| StringLiteral |
| 93 |
|
; |
| 97 |
|
|
| 98 |
|
zconstraintblock : ZCONSTRAINT^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 99 |
|
; |
| 100 |
+ |
|
| 101 |
+ |
restraintblock : RESTRAINT^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 102 |
+ |
; |
| 103 |
+ |
|
| 104 |
+ |
flucqblock : FLUCQ^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 105 |
+ |
; |
| 106 |
+ |
|
| 107 |
+ |
rnemdblock : RNEMD^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 108 |
+ |
; |
| 109 |
+ |
|
| 110 |
+ |
minimizerblock : MINIMIZER^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 111 |
+ |
; |
| 112 |
|
|
| 113 |
|
moleculeblock : MOLECULE^ LCURLY! (moleculestatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 114 |
|
; |
| 118 |
|
| bondblock |
| 119 |
|
| bendblock |
| 120 |
|
| torsionblock |
| 121 |
+ |
| inversionblock |
| 122 |
|
| rigidbodyblock |
| 123 |
|
| cutoffgroupblock |
| 124 |
|
| fragmentblock |
| 125 |
+ |
| constraintblock |
| 126 |
|
; |
| 127 |
|
|
| 128 |
|
atomblock : ATOM^ LBRACKET! intConst RBRACKET! LCURLY! (atomstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 129 |
|
; |
| 130 |
|
|
| 131 |
|
atomstatement : assignment |
| 132 |
< |
| POSITION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
| 133 |
< |
| ORIENTATION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
| 134 |
< |
; |
| 132 |
> |
| POSITION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 133 |
> |
| ORIENTATION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 134 |
> |
| CHARGE^ LPAREN! floatConst RPAREN! SEMICOLON! |
| 135 |
> |
; |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
bondblock : BOND^ (LBRACKET! intConst! RBRACKET!)? LCURLY!(bondstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 139 |
|
; |
| 140 |
|
|
| 141 |
|
bondstatement : assignment |
| 142 |
< |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 143 |
< |
; |
| 142 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 143 |
> |
| FIXED^ LPAREN! floatConst RPAREN! SEMICOLON! |
| 144 |
> |
| HARMONIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 145 |
> |
| CUBIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 146 |
> |
| QUARTIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 147 |
> |
| POLYNOMIAL^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 148 |
> |
| MORSE^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 149 |
> |
; |
| 150 |
|
|
| 151 |
|
bendblock : BEND^ (LBRACKET! intConst! RBRACKET!)? LCURLY! (bendstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 152 |
|
; |
| 153 |
|
|
| 154 |
|
bendstatement : assignment |
| 155 |
< |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 156 |
< |
; |
| 155 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 156 |
> |
| HARMONIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 157 |
> |
| GHOSTBEND^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 158 |
> |
| UREYBRADLEY^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 159 |
> |
| CUBIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 160 |
> |
| QUARTIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 161 |
> |
| POLYNOMIAL^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 162 |
> |
| COSINE^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 163 |
> |
; |
| 164 |
|
|
| 165 |
|
torsionblock : TORSION^ (LBRACKET! intConst! RBRACKET!)? LCURLY!(torsionstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 166 |
|
; |
| 167 |
|
|
| 168 |
|
torsionstatement : assignment |
| 169 |
< |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 170 |
< |
; |
| 169 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 170 |
> |
| GHOSTTORSION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 171 |
> |
| CUBIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 172 |
> |
| QUARTIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 173 |
> |
| POLYNOMIAL^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 174 |
> |
| CHARMM^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 175 |
> |
| OPLS^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 176 |
> |
| TRAPPE^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 177 |
> |
| HARMONIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 178 |
> |
; |
| 179 |
|
|
| 180 |
+ |
inversionblock : INVERSION^ (LBRACKET! intConst! RBRACKET!)? LCURLY!(inversionstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 181 |
+ |
; |
| 182 |
+ |
|
| 183 |
+ |
inversionstatement : assignment |
| 184 |
+ |
| CENTER^ LPAREN! intConst RPAREN! SEMICOLON! |
| 185 |
+ |
| SATELLITES^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 186 |
+ |
| AMBERIMPROPER^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 187 |
+ |
| IMPROPERCOSINE^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 188 |
+ |
| HARMONIC^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 189 |
+ |
| CENTRALATOMHEIGHT^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 190 |
+ |
| DREIDING^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
| 191 |
+ |
; |
| 192 |
+ |
|
| 193 |
|
rigidbodyblock : RIGIDBODY^ LBRACKET! intConst RBRACKET! LCURLY!(rigidbodystatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 194 |
|
; |
| 195 |
|
|
| 196 |
|
rigidbodystatement : assignment |
| 197 |
< |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 198 |
< |
; |
| 197 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 198 |
> |
; |
| 199 |
|
|
| 200 |
|
cutoffgroupblock : CUTOFFGROUP^ (LBRACKET! intConst! RBRACKET!)? LCURLY! (cutoffgroupstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 201 |
< |
; |
| 201 |
> |
; |
| 202 |
|
|
| 203 |
|
cutoffgroupstatement : assignment |
| 204 |
< |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 205 |
< |
; |
| 204 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 205 |
> |
; |
| 206 |
|
|
| 207 |
|
fragmentblock : FRAGMENT^ LBRACKET! intConst RBRACKET! LCURLY! (fragmentstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 208 |
< |
; |
| 208 |
> |
; |
| 209 |
|
|
| 210 |
|
fragmentstatement : assignment |
| 211 |
< |
; |
| 211 |
> |
; |
| 212 |
|
|
| 213 |
+ |
constraintblock : CONSTRAINT^ (LBRACKET! intConst! RBRACKET!)? LCURLY!(constraintstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
| 214 |
+ |
; |
| 215 |
|
|
| 216 |
< |
|
| 217 |
< |
signedNumberTuple : signedNumber (COMMA! signedNumber)* |
| 218 |
< |
; |
| 219 |
< |
|
| 216 |
> |
constraintstatement : assignment |
| 217 |
> |
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
| 218 |
> |
; |
| 219 |
> |
|
| 220 |
> |
|
| 221 |
> |
doubleNumberTuple : doubleNumber (COMMA! doubleNumber)* |
| 222 |
> |
; |
| 223 |
> |
|
| 224 |
|
inttuple : intConst (COMMA! intConst)* |
| 225 |
< |
; |
| 226 |
< |
|
| 225 |
> |
; |
| 226 |
> |
|
| 227 |
|
protected |
| 228 |
|
intConst |
| 229 |
< |
: OCTALINT | DECIMALINT | HEXADECIMALINT |
| 230 |
< |
; |
| 229 |
> |
: |
| 230 |
> |
NUM_INT | NUM_LONG |
| 231 |
> |
; |
| 232 |
|
|
| 233 |
|
protected |
| 234 |
< |
signedNumber : (PLUS! | MINUS^)? |
| 235 |
< |
(intConst | floatConst) |
| 236 |
< |
; |
| 234 |
> |
doubleNumber |
| 235 |
> |
: |
| 236 |
> |
(intConst | floatConst) |
| 237 |
> |
; |
| 238 |
|
|
| 239 |
|
protected |
| 240 |
|
floatConst |
| 241 |
< |
: |
| 242 |
< |
FLOATONE | FLOATTWO |
| 243 |
< |
; |
| 241 |
> |
: |
| 242 |
> |
NUM_FLOAT | NUM_DOUBLE |
| 243 |
> |
; |
| 244 |
|
|
| 245 |
|
|
| 246 |
+ |
/* |
| 247 |
+ |
protected |
| 248 |
+ |
vectorConst |
| 249 |
+ |
: |
| 250 |
+ |
LPAREN^ doubleNumber COMMA doubleNumber COMMA doubleNumber RPAREN |
| 251 |
+ |
; |
| 252 |
+ |
*/ |
| 253 |
|
|
| 254 |
+ |
protected |
| 255 |
+ |
vectorConst |
| 256 |
+ |
: |
| 257 |
+ |
LPAREN^ doubleNumberTuple RPAREN |
| 258 |
+ |
; |
| 259 |
+ |
|
| 260 |
+ |
|
| 261 |
|
class MDLexer extends Lexer; |
| 262 |
|
|
| 263 |
|
options |
| 310 |
|
LCURLY : '{' ; |
| 311 |
|
RCURLY : '}' ; |
| 312 |
|
|
| 212 |
– |
PLUS : '+' ; |
| 213 |
– |
MINUS : '-' ; |
| 214 |
– |
|
| 215 |
– |
/* |
| 216 |
– |
EQUAL : "==" ; |
| 217 |
– |
NOTEQUAL : "!=" ; |
| 218 |
– |
LESSTHANOREQUALTO : "<=" ; |
| 219 |
– |
LESSTHAN : "<" ; |
| 220 |
– |
GREATERTHANOREQUALTO : ">=" ; |
| 221 |
– |
GREATERTHAN : ">" ; |
| 222 |
– |
|
| 223 |
– |
DIVIDE : '/' ; |
| 224 |
– |
DIVIDEEQUAL : "/=" ; |
| 225 |
– |
PLUS : '+' ; |
| 226 |
– |
PLUSEQUAL : "+=" ; |
| 227 |
– |
PLUSPLUS : "++" ; |
| 228 |
– |
MINUS : '-' ; |
| 229 |
– |
MINUSEQUAL : "-=" ; |
| 230 |
– |
MINUSMINUS : "--" ; |
| 231 |
– |
STAR : '*' ; |
| 232 |
– |
TIMESEQUAL : "*=" ; |
| 233 |
– |
MOD : '%' ; |
| 234 |
– |
MODEQUAL : "%=" ; |
| 235 |
– |
SHIFTRIGHT : ">>" ; |
| 236 |
– |
SHIFTRIGHTEQUAL : ">>=" ; |
| 237 |
– |
SHIFTLEFT : "<<" ; |
| 238 |
– |
SHIFTLEFTEQUAL : "<<=" ; |
| 239 |
– |
|
| 240 |
– |
AND : "&&" ; |
| 241 |
– |
NOT : '!' ; |
| 242 |
– |
OR : "||" ; |
| 243 |
– |
|
| 244 |
– |
AMPERSAND : '&' ; |
| 245 |
– |
BITWISEANDEQUAL : "&=" ; |
| 246 |
– |
TILDE : '~' ; |
| 247 |
– |
BITWISEOR : '|' ; |
| 248 |
– |
BITWISEOREQUAL : "|=" ; |
| 249 |
– |
BITWISEXOR : '^' ; |
| 250 |
– |
BITWISEXOREQUAL : "^=" ; |
| 251 |
– |
*/ |
| 252 |
– |
|
| 253 |
– |
|
| 313 |
|
Whitespace |
| 314 |
|
: |
| 315 |
|
( // whitespace ignored |
| 360 |
|
} |
| 361 |
|
("line")? // this would be for if the directive started "#line" |
| 362 |
|
(Space)+ |
| 363 |
< |
n:Decimal { setLine(oopse::lexi_cast<int>(n->getText()) - 1); } |
| 363 |
> |
n:Decimal { setLine(OpenMD::lexi_cast<int>(n->getText()) - 1); } |
| 364 |
|
(Space)+ |
| 365 |
|
(sl:StringLiteral) {std::string filename = sl->getText().substr(1,sl->getText().length()-2); observer->notify(filename);} |
| 366 |
|
((Space)+ Decimal)* // To support cpp flags (GNU) |
| 459 |
|
) |
| 460 |
|
; |
| 461 |
|
|
| 403 |
– |
// Numeric Constants: |
| 462 |
|
|
| 463 |
|
protected |
| 464 |
< |
Digit |
| 464 |
> |
Vocabulary |
| 465 |
|
: |
| 466 |
< |
'0'..'9' |
| 466 |
> |
'\3'..'\377' |
| 467 |
|
; |
| 468 |
|
|
| 469 |
< |
protected |
| 470 |
< |
Decimal |
| 469 |
> |
|
| 470 |
> |
ID |
| 471 |
> |
options {testLiterals = true;} |
| 472 |
|
: |
| 473 |
< |
('0'..'9')+ |
| 473 |
> |
('a'..'z'|'A'..'Z'|'_') |
| 474 |
> |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
| 475 |
|
; |
| 476 |
|
|
| 477 |
+ |
|
| 478 |
|
protected |
| 479 |
< |
LongSuffix |
| 480 |
< |
: 'l' |
| 481 |
< |
| 'L' |
| 479 |
> |
Digit |
| 480 |
> |
: |
| 481 |
> |
'0'..'9' |
| 482 |
|
; |
| 483 |
|
|
| 484 |
|
protected |
| 485 |
< |
UnsignedSuffix |
| 486 |
< |
: 'u' |
| 487 |
< |
| 'U' |
| 485 |
> |
Decimal |
| 486 |
> |
: |
| 487 |
> |
('0'..'9')+ |
| 488 |
|
; |
| 489 |
|
|
| 490 |
+ |
// hexadecimal digit (again, note it's protected!) |
| 491 |
|
protected |
| 492 |
< |
FloatSuffix |
| 493 |
< |
: 'f' |
| 494 |
< |
| 'F' |
| 495 |
< |
; |
| 492 |
> |
HEX_DIGIT |
| 493 |
> |
: ('0'..'9'|'A'..'F'|'a'..'f') |
| 494 |
> |
; |
| 495 |
> |
|
| 496 |
> |
|
| 497 |
> |
// a numeric literal |
| 498 |
> |
NUM_INT |
| 499 |
> |
{ |
| 500 |
> |
bool isDecimal = false; |
| 501 |
> |
ANTLR_USE_NAMESPACE(antlr)RefToken t = ANTLR_USE_NAMESPACE(antlr)nullToken; |
| 502 |
> |
} |
| 503 |
> |
: ('+' | '-')? |
| 504 |
> |
( |
| 505 |
> |
'.' {_ttype = DOT;} |
| 506 |
> |
( ('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})? |
| 507 |
> |
{ |
| 508 |
> |
if ( t && |
| 509 |
> |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
| 510 |
> |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
| 511 |
> |
_ttype = NUM_FLOAT; |
| 512 |
> |
} |
| 513 |
> |
else { |
| 514 |
> |
_ttype = NUM_DOUBLE; // assume double |
| 515 |
> |
} |
| 516 |
> |
} |
| 517 |
> |
)? |
| 518 |
|
|
| 519 |
< |
protected |
| 520 |
< |
Exponent |
| 521 |
< |
: |
| 522 |
< |
('e'|'E'|'d'|'D') ('+'|'-')? (Digit)+ |
| 523 |
< |
; |
| 519 |
> |
| ( '0' {isDecimal = true;} // special case for just '0' |
| 520 |
> |
( ('x'|'X') |
| 521 |
> |
( // hex |
| 522 |
> |
// the 'e'|'E' and float suffix stuff look |
| 523 |
> |
// like hex digits, hence the (...)+ doesn't |
| 524 |
> |
// know when to stop: ambig. ANTLR resolves |
| 525 |
> |
// it correctly by matching immediately. It |
| 526 |
> |
// is therefor ok to hush warning. |
| 527 |
> |
options { |
| 528 |
> |
warnWhenFollowAmbig=false; |
| 529 |
> |
} |
| 530 |
> |
: HEX_DIGIT |
| 531 |
> |
)+ |
| 532 |
> |
| //float or double with leading zero |
| 533 |
> |
(('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+ |
| 534 |
> |
| ('0'..'7')+ // octal |
| 535 |
> |
)? |
| 536 |
> |
| ('1'..'9') ('0'..'9')* {isDecimal=true;} // non-zero decimal |
| 537 |
> |
) |
| 538 |
> |
( ('l'|'L') { _ttype = NUM_LONG; } |
| 539 |
|
|
| 540 |
+ |
// only check to see if it's a float if looks like decimal so far |
| 541 |
+ |
| {isDecimal}? |
| 542 |
+ |
( '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})? |
| 543 |
+ |
| EXPONENT (f3:FLOAT_SUFFIX {t=f3;})? |
| 544 |
+ |
| f4:FLOAT_SUFFIX {t=f4;} |
| 545 |
+ |
) |
| 546 |
+ |
{ |
| 547 |
+ |
if ( t && |
| 548 |
+ |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
| 549 |
+ |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
| 550 |
+ |
_ttype = NUM_FLOAT; |
| 551 |
+ |
} |
| 552 |
+ |
else { |
| 553 |
+ |
_ttype = NUM_DOUBLE; // assume double |
| 554 |
+ |
} |
| 555 |
+ |
} |
| 556 |
+ |
)? |
| 557 |
+ |
) |
| 558 |
+ |
; |
| 559 |
+ |
|
| 560 |
+ |
// a couple protected methods to assist in matching floating point numbers |
| 561 |
|
protected |
| 562 |
< |
Vocabulary |
| 563 |
< |
: |
| 564 |
< |
'\3'..'\377' |
| 445 |
< |
; |
| 562 |
> |
EXPONENT |
| 563 |
> |
: ('e'|'E'|'d'|'D') ('+'|'-')? ('0'..'9')+ |
| 564 |
> |
; |
| 565 |
|
|
| 566 |
< |
Number |
| 567 |
< |
: |
| 568 |
< |
( (Digit)+ ('.' | 'e' | 'E' | 'd' | 'D' ) )=> |
| 569 |
< |
(Digit)+ |
| 451 |
< |
( '.' (Digit)* (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
| 452 |
< |
| Exponent {_ttype = FLOATTWO;} //Zuo 3/12/01 |
| 453 |
< |
) //{_ttype = DoubleDoubleConst;} |
| 454 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
| 455 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
| 456 |
< |
)? |
| 457 |
< |
| |
| 458 |
< |
'.' {_ttype = DOT;} |
| 459 |
< |
( (Digit)+ (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
| 460 |
< |
//{_ttype = DoubleDoubleConst;} |
| 461 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
| 462 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
| 463 |
< |
)? |
| 464 |
< |
)? |
| 465 |
< |
| |
| 466 |
< |
'0' ('0'..'7')* //{_ttype = IntOctalConst;} |
| 467 |
< |
(LongSuffix //{_ttype = LongOctalConst;} |
| 468 |
< |
|UnsignedSuffix //{_ttype = UnsignedOctalConst;} |
| 469 |
< |
)* {_ttype = OCTALINT;} |
| 470 |
< |
| |
| 471 |
< |
'1'..'9' (Digit)* //{_ttype = IntIntConst;} |
| 472 |
< |
(LongSuffix //{_ttype = LongIntConst;} |
| 473 |
< |
|UnsignedSuffix //{_ttype = UnsignedIntConst;} |
| 474 |
< |
)* {_ttype = DECIMALINT;} |
| 475 |
< |
| |
| 476 |
< |
'0' ('x' | 'X') ('a'..'f' | 'A'..'F' | Digit)+ |
| 477 |
< |
//{_ttype = IntHexConst;} |
| 478 |
< |
(LongSuffix //{_ttype = LongHexConst;} |
| 479 |
< |
|UnsignedSuffix //{_ttype = UnsignedHexConst;} |
| 480 |
< |
)* {_ttype = HEXADECIMALINT;} |
| 481 |
< |
; |
| 482 |
< |
|
| 483 |
< |
ID |
| 484 |
< |
options {testLiterals = true;} |
| 485 |
< |
: |
| 486 |
< |
('a'..'z'|'A'..'Z'|'_') |
| 487 |
< |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
| 488 |
< |
; |
| 566 |
> |
protected |
| 567 |
> |
FLOAT_SUFFIX |
| 568 |
> |
: 'f'|'F'|'d'|'D' |
| 569 |
> |
; |