summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Plugins/NanorexMMPImportExport/checked_molecule.rl
blob: f416cee2261956636579b776cbccf0de89276460 (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
// checked_molecule.rl - Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

%%{

#! MACHINE molecule
#! Provides pattern definitions to recognize a molecule statement
#! Provides syntax-error checking
	
# NOTES:
# 1. Include the following lines before including this file
#        include utilities "utilities.rl";
	
	machine checked_molecule;
	
	checked_molecule_name =
		'('  nonNEWLINEspace*  char_string_with_space  nonNEWLINEspace* ')'
		@lerr { syntaxError("Badly formed molecule name"); }
	;
	
	checked_molecule_style =
		char_string_with_space2
		@lerr { syntaxError("Badly formed molecule style"); }
	;
	
	checked_mol_decl_line =
		'mol'  >{lineStart=p;}
		nonNEWLINEspace+    > { stringVal2.clear(); /* style is optional */ }
		checked_molecule_name
		(    nonNEWLINEspace+
		     checked_molecule_style
		)?
		nonNEWLINEspace*
		EOL
		@ {
			if(stringVal2 == "")
				stringVal2 = "def";
			newMolecule(stringVal, stringVal2);
		}
	;
	
	checked_info_chunk_key =
		char_string_with_space 
		$lerr { syntaxError("Badly formed key"); }
	;
	
	checked_info_chunk_value =
		char_string_with_space2
		$lerr { syntaxError("Badly formed value"); }
	;
	
	checked_info_chunk_line =
		'info'  >{lineStart=p;} 
		nonNEWLINEspace+
		'chunk'
		nonNEWLINEspace+
		checked_info_chunk_key
		nonNEWLINEspace*
		'='  $lerr { syntaxError("Expected '=' in assignment"); }
		nonNEWLINEspace*
		checked_info_chunk_value
		nonNEWLINEspace*
		EOL
		@ { newChunkInfo(stringVal, stringVal2); }
	;
	
}%%