blob: 534d69701e07486d018efa8b9c6714354a52393a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
// checked_atom.rl - Copyright 2008 Nanorex, Inc. See LICENSE file for details.
%%{
# Copyright 2008 Nanorex, Inc. See LICENSE file for details.
# NOTES:
#
# 1. Will need to include the following statements before including this file
# include utilities "utilities.rl";
#
# 2. Make declarations for the following variables visible in scope
# char *lineStart;
#
# 3. Define the following functions
# void syntaxError(std::string const& errorMessage);
#! MACHINE: checked_atom
#! Provides Ragel patterns for recognizing atom declaration lines and provides
#! syntax-error checking
machine checked_atom;
include atom "atom.rl";
checked_atom_id =
atom_id
@lerr { syntaxError("Badly formed integer"); }
;
checked_atomic_num =
atomic_num
@lerr { syntaxError("Badly formed atomic number"); }
;
checked_atom_coords =
'(' xcoord ',' ycoord ',' zcoord ')'
#% { cerr << "atom_coords = (" << x << ',' << y << ',' << z << ')' << endl; }
@lerr { syntaxError("Badly formed coordinates"); }
;
checked_atom_style =
char_string_with_space
% { atomStyle = stringVal;
/*cerr << "atom_style = " << stringVal << endl;*/
}
@lerr { syntaxError("Badly formed atom-style specification"); }
;
checked_atom_decl_line =
'atom' >{lineStart=p;} nonNEWLINEspace+
checked_atom_id nonNEWLINEspace+
checked_atomic_num nonNEWLINEspace+
checked_atom_coords
(nonNEWLINEspace+ checked_atom_style)?
nonNEWLINEspace*
EOL
@ { newAtom(atomId, atomicNum, x, y, z, atomStyle); }
# no error actions because each component supplies its own
;
checked_bond_type =
[123acg]
@ { stringVal = *p; }
@lerr { syntaxError("Invalid bond-specification - " + stringVal); }
;
checked_bond_target_atom_id =
whole_number
% newBondAction
@lerr { syntaxError("Invalid bond-target atom id"); }
;
checked_bond_line =
'bond' >{lineStart=p;}
checked_bond_type
(nonNEWLINEspace+ checked_bond_target_atom_id)+
nonNEWLINEspace*
EOL;
checked_bond_direction_line =
'bond_direction' >{lineStart=p;}
nonNEWLINEspace+
whole_number
$lerr { syntaxError("Invalid bond-direction specification"); }
nonNEWLINEspace+
whole_number2
$lerr { syntaxError("Invalid bond-direction specification"); }
nonNEWLINEspace*
EOL
@ newBondDirectionAction;
checked_info_atom_line =
'info' >{lineStart=p;}
nonNEWLINEspace+ 'atom'
nonNEWLINEspace+ char_string_with_space
$lerr{ syntaxError("Badly formed key"); }
nonNEWLINEspace* '='
$lerr { syntaxError("Expecting '=' after key"); }
nonNEWLINEspace* char_string_with_space2
$lerr{ syntaxError("Badly formed value"); }
nonNEWLINEspace*
EOL
@ newInfoAtomAction
;
checked_atom_attrib_line =
( checked_bond_line |
checked_bond_direction_line |
checked_info_atom_line
);
}%%
|