summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Plugins/NanorexMMPImportExport/checked_group.rl
blob: e792365e31eeb470ad6e7d184ef9bc49f6d70467 (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
121
122
123
124
125
126
127
128
129
130

// checked_group.rl - Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

%%{
	
# Ragel definitions for the 'group' statement and related
#	
# NOTES:
#
# 1. Define the following variables in scope
#    char *lineStart;
#
# 2. Define the following functions in scope
#    void syntaxError(char *errorMessage);
	
	machine checked_group;
	
	include utilities "utilities.rl";
	include checked_atom "checked_atom.rl";
	include checked_molecule "checked_molecule.rl";
	
	
	checked_group_view_data_stmt_begin_line =
		'group'   > { lineStart = p; }
		nonNEWLINEspace*
		'(' nonNEWLINEspace* 'View' nonNEWLINEspace+ 'Data' nonNEWLINEspace* ')'
		EOL
		@ { newViewDataGroup(); }
		@lerr { syntaxError("Expecting the 'group (View Data)' statement"); }
	;
	
	checked_group_name =
		char_string_with_space
		@lerr { syntaxError("Badly formed group-name"); }
	;
	
	checked_group_style =
		char_string_with_space2
		@lerr { syntaxError("Badly formed group-style"); }
	;
	
	checked_group_mol_struct_stmt_begin_line =
		'group'   > {lineStart=p;}
# -- no style -- % { stringVal2.clear(); }
		nonNEWLINEspace*
		'('  nonNEWLINEspace*  checked_group_name  nonNEWLINEspace*  ')'
# -- no style -- (nonNEWLINEspace+ checked_group_style)?
		nonNEWLINEspace*
		EOL
		@ { newMolStructGroup(stringVal, stringVal2); }
	;
	
	
	checked_end1_line =
		'end1'   > {lineStart = p;}
		nonNEWLINEspace*
		EOL
		@ { end1(); }
		@lerr { syntaxError("Badly formed 'end1' statement"); }
	;
	
	checked_group_clipboard_stmt_begin_line =
		'egroup'  > {lineStart=p;}
		nonNEWLINEspace*
		'(' nonNEWLINEspace* 'Clipboard' nonNEWLINEspace* ')'
		EOL
		@ { newClipboardGroup(); }
		@lerr { syntaxError("Expecting the 'group (Clipboard)' statement"); }
	;
	
	
	checked_egroup_line =
		'egroup'   >{lineStart=p;}   % { stringVal.clear(); }
		nonNEWLINEspace*
		(  '('  (nonNEWLINEspace*  checked_group_name  nonNEWLINEspace*)?  ')'
		   nonNEWLINEspace*
		)?
		EOL
		@ { endGroup(stringVal); }
	;
	
	checked_info_opengroup_key =
		char_string_with_space
		@lerr { syntaxError("Badly formed 'info opengroup' key"); }
	;
	
	checked_info_opengroup_value =
		char_string_with_space2
		@lerr { syntaxError("Badly formed 'info opengroup' value"); }
	;
	
	checked_info_opengroup_line =
		'info'   >{lineStart=p;}
		nonNEWLINEspace+
		'opengroup'
		nonNEWLINEspace+
		checked_info_opengroup_key
		nonNEWLINEspace*
		'='
		nonNEWLINEspace*
		checked_info_opengroup_value
		nonNEWLINEspace*
		EOL
		@ { newOpenGroupInfo(stringVal, stringVal2); }
	;
	
	
checked_group_scanner :=
		|*
			WHITESPACE** checked_group_mol_struct_stmt_begin_line;
			WHITESPACE** checked_info_opengroup_line;
			WHITESPACE** checked_egroup_line =>
				{ cerr << lineNum << ": returning from group" << endl; fret; };
			WHITESPACE** checked_mol_decl_line;
			WHITESPACE** checked_info_chunk_line;
			WHITESPACE** checked_atom_decl_line;
			WHITESPACE** checked_info_atom_line;
			WHITESPACE** checked_bond_line;
			WHITESPACE** checked_bond_direction_line;
	
			# skip blank and comment lines by providing no actions
			WHITESPACE** COMMENT_LINE;
			IGNORED_LINE =>
				{   cerr << lineNum << ": Error : ";
					std::copy(ts, te, std::ostream_iterator<char>(cerr));
					cerr << endl;
				};
	*|;
	
}%%