File: parser.l

package info (click to toggle)
explorer 0.72-2.1
  • links: PTS
  • area: contrib
  • in suites: hamm, slink
  • size: 1,556 kB
  • ctags: 1,203
  • sloc: cpp: 10,226; makefile: 384; sh: 206; ansic: 106; lex: 95; csh: 6
file content (118 lines) | stat: -rw-r--r-- 2,963 bytes parent folder | download
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
/*

#
# This file is part of MindsEye
#
# MindsEye is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# MindsEye is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MindsEye; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#

*/

%{
#include <parser.h>
#include <parse_tools.h>
#include <m_config.h>
%}

/*---- Definitions ----------------------------------------------------------*/

DIGIT	[0-9]*
FLOAT	[0-9]+*"."[0-9]+*

WORD	([a-z]|[A-Z]|[ /~!@#$%^&*()_+|`])+([a-zA-Z /~!@#$%^&*()_+|`1234567890-=\\]*)

GROUP	("["){WORD}("]")

STRING	("\""){WORD}("\"")

NAME	("<"){WORD}(">")

/*---- Rules ----------------------------------------------------------------*/

%%

{GROUP}		{
             #ifdef SHOW_PARSING               
			   printf ("\nGroup statement found: (%s)\n\n",
                       remove_delimit (yytext)); 
             #else
               create_group (parse_confclass,remove_delimit (yytext));
             #endif
			}

{NAME}		{
             #ifdef SHOW_PARSING
			   printf ("Name statement found: (%s)\n",
                       remove_delimit (yytext)); 
             #else
               create_var (parse_confclass,remove_delimit (yytext));
             #endif
			}

{STRING}	{
             #ifdef SHOW_PARSING
			   printf ("String found: (%s)\n",
                       remove_delimit (yytext)); 
             #else
               add_string (parse_confclass,remove_delimit (yytext));
             #endif
			}

{DIGIT}	    {
             #ifdef SHOW_PARSING
			   printf ("Number (int) found: (%d)\n",
                       atoi (yytext)); 
             #else
               add_integer (parse_confclass,atoi (yytext));
             #endif
			}

{FLOAT}	    {
             #ifdef SHOW_PARSING
			   printf ("Number (float) found: (%f)\n",
                       atof (yytext)); 
             #else
               add_float (parse_confclass,atof (yytext));
             #endif
			}

.			{
             #ifdef SHOW_UNKNOWN_TOKENS
			   printf ("Unidentified token found (%s)\n",yytext);
             #endif   
			}

\n			{
               //printf ("\n");
			}

%%



ConfigClass *parse_confclass;

/*---------------------------------------------------------------------------*/
void parse_a_file (ConfigClass *temp_config,FILE *parse_file)
{
 if ((parse_file!=NULL) && (temp_config!=NULL))
 {
   parse_confclass=temp_config;

   yyin = parse_file;
   yylex();
 }
}
/*---------------------------------------------------------------------------*/