File: smartsParserLexer.l

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (151 lines) | stat: -rwxr-xr-x 3,760 bytes parent folder | download | duplicates (6)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%{
#include <BALL/STRUCTURE/smartsParser.h>
#include <BALL/DATATYPE/string.h>
#include <BALL/COMMON/parserDefinitions.h>

using namespace BALL;

#include "smartsParserParser.h"

%}

%option nounput
%option noyywrap

%%

[0-9]	{
						SmartsParser::state.current_parser->state.char_count++;
						SmartsParserlval.number = yytext[0] - '0';
						return TK_DIGIT;
}

He|Li|Be|Ne|Na|Mg|Al|Si|Ar|K|Ca|Sc|Ti|V|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|As|Se|Kr|Rb|Sr|Y|Zr|Nb|Mo|Tc|Ru|Rh|Pd|Ag|Cd|In|Sn|Sb|Te|Xe|Cs|Ba|Lu|Hf|Ta|W|Re|Os|Ir|Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Lr|Rf|Db|Sg|Bh|Hs|Mt|Uun|Uuu|Uub|Uut|Uuq|Uup|Uuh|Uus|Uuo|La|Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Ac|Th|Pa|U|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No {
						SmartsParser::state.current_parser->state.char_count += strlen(yytext);
						SmartsParserlval.text = yytext;
						return TK_ATOM;
}

br|cl|b|c|n|o|p|s|f|i {
						SmartsParser::state.current_parser->state.char_count += strlen(yytext);
						SmartsParserlval.text = yytext;
            return TK_ORG_SUBSET_ATOM;
}

Cl|Br|B|C|N|O|P|S|F|I {
						SmartsParser::state.current_parser->state.char_count += strlen(yytext);
						SmartsParserlval.text = yytext;
            return TK_ORG_SUBSET_ATOM;
}

A	{					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ALIPHATIC_ATOM;
}

a	{					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_AROMATIC_ATOM;
}

R	{
						SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_NUM_RINGS;
}

r	{					
						SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_RING_SIZE;
}

v {					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_VALENCE;
}

X	{					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_CONNECTED;
}

x {					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_RING_CONNECTED;
}

D	{					SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ATOM_DEGREE;
}

\*	{				SmartsParser::state.current_parser->state.char_count += 1;
						return TK_ANY_ATOM;
}

@TH {
						SmartsParser::state.current_parser->state.char_count += 2;
						return TK_CHIRAL_CLASS_TH;
}

@AL {
						SmartsParser::state.current_parser->state.char_count += 2;
						return TK_CHIRAL_CLASS_AL;
}

@SP {
						SmartsParser::state.current_parser->state.char_count += 2;
						return TK_CHIRAL_CLASS_SP;
}

@TB {
						SmartsParser::state.current_parser->state.char_count += 2;
						return TK_CHIRAL_CLASS_TB;
}

@OH {
						SmartsParser::state.current_parser->state.char_count += 2;
						return TK_CHIRAL_CLASS_OH;
}

H	{
						SmartsParser::state.current_parser->state.char_count++;
            return TK_HYDROGEN_EXPLICIT;
}

h	{
						SmartsParser::state.current_parser->state.char_count++;
						return TK_HYDROGEN_IMPLICIT;
}

\$ {
						SmartsParser::state.current_parser->state.char_count++;
						return TK_RECURSIVE;
}

\-|=|~|:|\\|\/|\\\?|\/\?|@|#|\[|\]|\(|\)|!|\+|\.|,|;|& {
						SmartsParser::state.current_parser->state.char_count += strlen(yytext);
						SmartsParserlval.text = yytext;
						return yytext[0];
}

.	{
						SmartsParser::state.current_parser->state.char_count++;
						throw Exception::ParseError
							(__FILE__, __LINE__, 
							 String("unknown symbol '") + yytext[0] + "' at position " + String(SmartsParser::state.current_parser->state.char_count), "");
	
}

%%

YY_BUFFER_STATE SmartsParser_buffer;
void SmartsParser_initBuffer(const char* buf)
{
	SmartsParser_buffer = SmartsParser_scan_string(buf);
}

void SmartsParser_delBuffer()
{
	SmartsParser_delete_buffer(SmartsParser_buffer);
}

void SmartsParser_destroy()
{
#ifdef BALL_HAS_YYLEX_DESTROY
	SmartsParserlex_destroy();
#endif
}