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 |
|
FRAGMENT = "fragment"; |
40 |
|
MEMBERS = "members"; |
41 |
+ |
CENTER = "center"; |
42 |
|
POSITION = "position"; |
43 |
|
ORIENTATION = "orientation"; |
44 |
+ |
FLUCQ = "flucQ"; |
45 |
+ |
RNEMD = "RNEMD"; |
46 |
+ |
MINIMIZER = "minimizer"; |
47 |
|
ENDBLOCK; |
48 |
|
} |
49 |
|
|
44 |
– |
{ |
45 |
– |
// Suppport C++-style single-line comments? |
46 |
– |
} |
50 |
|
|
51 |
|
mdfile : (statement)* |
52 |
|
; |
53 |
|
|
54 |
|
statement : assignment |
55 |
< |
| componentblock |
56 |
< |
| moleculeblock |
57 |
< |
| zconstraintblock |
58 |
< |
; |
59 |
< |
|
55 |
> |
| componentblock |
56 |
> |
| moleculeblock |
57 |
> |
| zconstraintblock |
58 |
> |
| restraintblock |
59 |
> |
| flucqblock |
60 |
> |
| rnemdblock |
61 |
> |
| minimizerblock |
62 |
> |
; |
63 |
> |
|
64 |
|
assignment : ID ASSIGNEQUAL^ constant SEMICOLON! |
65 |
|
; |
66 |
|
|
67 |
< |
constant : signedNumber |
67 |
> |
constant : intConst |
68 |
> |
| floatConst |
69 |
> |
| vectorConst |
70 |
|
| ID |
71 |
|
| StringLiteral |
72 |
|
; |
76 |
|
|
77 |
|
zconstraintblock : ZCONSTRAINT^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
78 |
|
; |
79 |
+ |
|
80 |
+ |
restraintblock : RESTRAINT^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
81 |
+ |
; |
82 |
+ |
|
83 |
+ |
flucqblock : FLUCQ^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
84 |
+ |
; |
85 |
+ |
|
86 |
+ |
rnemdblock : RNEMD^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
87 |
+ |
; |
88 |
+ |
|
89 |
+ |
minimizerblock : MINIMIZER^ LCURLY! (assignment)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
90 |
+ |
; |
91 |
|
|
92 |
|
moleculeblock : MOLECULE^ LCURLY! (moleculestatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
93 |
|
; |
97 |
|
| bondblock |
98 |
|
| bendblock |
99 |
|
| torsionblock |
100 |
+ |
| inversionblock |
101 |
|
| rigidbodyblock |
102 |
|
| cutoffgroupblock |
103 |
|
| fragmentblock |
107 |
|
; |
108 |
|
|
109 |
|
atomstatement : assignment |
110 |
< |
| POSITION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
111 |
< |
| ORIENTATION^ LPAREN! signedNumberTuple RPAREN! SEMICOLON! |
110 |
> |
| POSITION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
111 |
> |
| ORIENTATION^ LPAREN! doubleNumberTuple RPAREN! SEMICOLON! |
112 |
|
; |
113 |
|
|
114 |
|
|
133 |
|
| MEMBERS^ LPAREN! inttuple RPAREN! SEMICOLON! |
134 |
|
; |
135 |
|
|
136 |
+ |
inversionblock : INVERSION^ (LBRACKET! intConst! RBRACKET!)? LCURLY!(inversionstatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
137 |
+ |
; |
138 |
+ |
|
139 |
+ |
inversionstatement : assignment |
140 |
+ |
| CENTER^ LPAREN! intConst RPAREN! SEMICOLON! |
141 |
+ |
; |
142 |
+ |
|
143 |
|
rigidbodyblock : RIGIDBODY^ LBRACKET! intConst RBRACKET! LCURLY!(rigidbodystatement)* RCURLY {#RCURLY->setType(ENDBLOCK);} |
144 |
|
; |
145 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
< |
signedNumberTuple : signedNumber (COMMA! signedNumber)* |
165 |
> |
doubleNumberTuple : doubleNumber (COMMA! doubleNumber)* |
166 |
|
; |
167 |
|
|
168 |
|
inttuple : intConst (COMMA! intConst)* |
170 |
|
|
171 |
|
protected |
172 |
|
intConst |
173 |
< |
: OCTALINT | DECIMALINT | HEXADECIMALINT |
173 |
> |
: NUM_INT | NUM_LONG |
174 |
|
; |
175 |
|
|
176 |
|
protected |
177 |
< |
signedNumber : (PLUS! | MINUS^)? |
177 |
> |
doubleNumber : |
178 |
|
(intConst | floatConst) |
179 |
|
; |
180 |
|
|
181 |
|
protected |
182 |
|
floatConst |
183 |
|
: |
184 |
< |
FLOATONE | FLOATTWO |
184 |
> |
NUM_FLOAT | NUM_DOUBLE |
185 |
|
; |
186 |
|
|
187 |
+ |
protected |
188 |
+ |
vectorConst |
189 |
+ |
: |
190 |
+ |
LPAREN^ doubleNumber COMMA doubleNumber COMMA doubleNumber RPAREN |
191 |
+ |
; |
192 |
|
|
159 |
– |
|
193 |
|
class MDLexer extends Lexer; |
194 |
|
|
195 |
|
options |
241 |
|
RBRACKET : ']' ; |
242 |
|
LCURLY : '{' ; |
243 |
|
RCURLY : '}' ; |
211 |
– |
|
212 |
– |
PLUS : '+' ; |
213 |
– |
MINUS : '-' ; |
214 |
– |
|
215 |
– |
/* |
216 |
– |
EQUAL : "==" ; |
217 |
– |
NOTEQUAL : "!=" ; |
218 |
– |
LESSTHANOREQUALTO : "<=" ; |
219 |
– |
LESSTHAN : "<" ; |
220 |
– |
GREATERTHANOREQUALTO : ">=" ; |
221 |
– |
GREATERTHAN : ">" ; |
244 |
|
|
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 |
– |
|
245 |
|
Whitespace |
246 |
|
: |
247 |
|
( // whitespace ignored |
292 |
|
} |
293 |
|
("line")? // this would be for if the directive started "#line" |
294 |
|
(Space)+ |
295 |
< |
n:Decimal { setLine(oopse::lexi_cast<int>(n->getText()) - 1); } |
295 |
> |
n:Decimal { setLine(OpenMD::lexi_cast<int>(n->getText()) - 1); } |
296 |
|
(Space)+ |
297 |
|
(sl:StringLiteral) {std::string filename = sl->getText().substr(1,sl->getText().length()-2); observer->notify(filename);} |
298 |
|
((Space)+ Decimal)* // To support cpp flags (GNU) |
391 |
|
) |
392 |
|
; |
393 |
|
|
403 |
– |
// Numeric Constants: |
394 |
|
|
395 |
|
protected |
396 |
< |
Digit |
396 |
> |
Vocabulary |
397 |
|
: |
398 |
< |
'0'..'9' |
398 |
> |
'\3'..'\377' |
399 |
|
; |
400 |
|
|
401 |
< |
protected |
402 |
< |
Decimal |
401 |
> |
|
402 |
> |
ID |
403 |
> |
options {testLiterals = true;} |
404 |
|
: |
405 |
< |
('0'..'9')+ |
405 |
> |
('a'..'z'|'A'..'Z'|'_') |
406 |
> |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
407 |
|
; |
408 |
|
|
409 |
+ |
|
410 |
|
protected |
411 |
< |
LongSuffix |
412 |
< |
: 'l' |
413 |
< |
| 'L' |
411 |
> |
Digit |
412 |
> |
: |
413 |
> |
'0'..'9' |
414 |
|
; |
415 |
|
|
416 |
|
protected |
417 |
< |
UnsignedSuffix |
418 |
< |
: 'u' |
419 |
< |
| 'U' |
417 |
> |
Decimal |
418 |
> |
: |
419 |
> |
('0'..'9')+ |
420 |
|
; |
421 |
|
|
422 |
+ |
// hexadecimal digit (again, note it's protected!) |
423 |
|
protected |
424 |
< |
FloatSuffix |
425 |
< |
: 'f' |
426 |
< |
| 'F' |
433 |
< |
; |
424 |
> |
HEX_DIGIT |
425 |
> |
: ('0'..'9'|'A'..'F'|'a'..'f') |
426 |
> |
; |
427 |
|
|
435 |
– |
protected |
436 |
– |
Exponent |
437 |
– |
: |
438 |
– |
('e'|'E'|'d'|'D') ('+'|'-')? (Digit)+ |
439 |
– |
; |
428 |
|
|
429 |
< |
protected |
430 |
< |
Vocabulary |
431 |
< |
: |
432 |
< |
'\3'..'\377' |
433 |
< |
; |
429 |
> |
// a numeric literal |
430 |
> |
NUM_INT |
431 |
> |
{ |
432 |
> |
bool isDecimal = false; |
433 |
> |
ANTLR_USE_NAMESPACE(antlr)RefToken t = ANTLR_USE_NAMESPACE(antlr)nullToken; |
434 |
> |
} |
435 |
> |
: ('+' | '-')? |
436 |
> |
( |
437 |
> |
'.' {_ttype = DOT;} |
438 |
> |
( ('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})? |
439 |
> |
{ |
440 |
> |
if ( t && |
441 |
> |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
442 |
> |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
443 |
> |
_ttype = NUM_FLOAT; |
444 |
> |
} |
445 |
> |
else { |
446 |
> |
_ttype = NUM_DOUBLE; // assume double |
447 |
> |
} |
448 |
> |
} |
449 |
> |
)? |
450 |
|
|
451 |
< |
Number |
452 |
< |
: |
453 |
< |
( (Digit)+ ('.' | 'e' | 'E' | 'd' | 'D' ) )=> |
454 |
< |
(Digit)+ |
455 |
< |
( '.' (Digit)* (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
456 |
< |
| Exponent {_ttype = FLOATTWO;} //Zuo 3/12/01 |
457 |
< |
) //{_ttype = DoubleDoubleConst;} |
458 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
459 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
460 |
< |
)? |
461 |
< |
| |
462 |
< |
'.' {_ttype = DOT;} |
463 |
< |
( (Digit)+ (Exponent)? {_ttype = FLOATONE;} //Zuo 3/12/01 |
464 |
< |
//{_ttype = DoubleDoubleConst;} |
465 |
< |
(FloatSuffix //{_ttype = FloatDoubleConst;} |
466 |
< |
|LongSuffix //{_ttype = LongDoubleConst;} |
467 |
< |
)? |
468 |
< |
)? |
469 |
< |
| |
470 |
< |
'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 |
< |
; |
451 |
> |
| ( '0' {isDecimal = true;} // special case for just '0' |
452 |
> |
( ('x'|'X') |
453 |
> |
( // hex |
454 |
> |
// the 'e'|'E' and float suffix stuff look |
455 |
> |
// like hex digits, hence the (...)+ doesn't |
456 |
> |
// know when to stop: ambig. ANTLR resolves |
457 |
> |
// it correctly by matching immediately. It |
458 |
> |
// is therefor ok to hush warning. |
459 |
> |
options { |
460 |
> |
warnWhenFollowAmbig=false; |
461 |
> |
} |
462 |
> |
: HEX_DIGIT |
463 |
> |
)+ |
464 |
> |
| //float or double with leading zero |
465 |
> |
(('0'..'9')+ ('.'|EXPONENT|FLOAT_SUFFIX)) => ('0'..'9')+ |
466 |
> |
| ('0'..'7')+ // octal |
467 |
> |
)? |
468 |
> |
| ('1'..'9') ('0'..'9')* {isDecimal=true;} // non-zero decimal |
469 |
> |
) |
470 |
> |
( ('l'|'L') { _ttype = NUM_LONG; } |
471 |
|
|
472 |
< |
ID |
473 |
< |
options {testLiterals = true;} |
474 |
< |
: |
475 |
< |
('a'..'z'|'A'..'Z'|'_') |
476 |
< |
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* |
477 |
< |
; |
472 |
> |
// only check to see if it's a float if looks like decimal so far |
473 |
> |
| {isDecimal}? |
474 |
> |
( '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})? |
475 |
> |
| EXPONENT (f3:FLOAT_SUFFIX {t=f3;})? |
476 |
> |
| f4:FLOAT_SUFFIX {t=f4;} |
477 |
> |
) |
478 |
> |
{ |
479 |
> |
if ( t && |
480 |
> |
(t->getText().find('f') != ANTLR_USE_NAMESPACE(std)string::npos || |
481 |
> |
t->getText().find('F') != ANTLR_USE_NAMESPACE(std)string::npos ) ) { |
482 |
> |
_ttype = NUM_FLOAT; |
483 |
> |
} |
484 |
> |
else { |
485 |
> |
_ttype = NUM_DOUBLE; // assume double |
486 |
> |
} |
487 |
> |
} |
488 |
> |
)? |
489 |
> |
) |
490 |
> |
; |
491 |
> |
|
492 |
> |
// a couple protected methods to assist in matching floating point numbers |
493 |
> |
protected |
494 |
> |
EXPONENT |
495 |
> |
: ('e'|'E'|'d'|'D') ('+'|'-')? ('0'..'9')+ |
496 |
> |
; |
497 |
> |
|
498 |
> |
protected |
499 |
> |
FLOAT_SUFFIX |
500 |
> |
: 'f'|'F'|'d'|'D' |
501 |
> |
; |