Introduce rs6000-ibm-aix64 platform.
[dyninst.git] / dyner / src / cmdline.l
1 %{
2 #if defined(i386_unknown_nt4_0)
3 #define YY_SKIP_YYWRAP
4 #define YY_NEVER_INTERACTIVE 1
5
6 int yywrap()
7 {
8     return 1;
9 }
10 #endif
11
12 #include <string.h>
13 #include "BPatch_snippet.h"
14 #include "dyner.tab.h"
15
16 extern "C" {
17 void set_lex_input(char *);
18 }
19
20 static char *input_str = NULL;
21
22 #ifdef FLEX_SCANNER
23 #undef YY_INPUT
24
25 #define YY_INPUT(b,r,ms) (r = my_yyinput(b, ms))
26
27 int my_yyinput(char *buf, int max_size);
28 #else
29 #undef input
30 #undef unput
31
32 #define input()  (*input_str++)
33 #define unput(c) (*--input_str = c)
34
35 #endif
36
37
38 static int yyinput(void);
39
40 static int doubleQuote()
41 {
42     int count;
43     char ch;
44     bool backSlash = false;
45
46     count = 0;
47     while (1) {
48         ch = yyinput();
49         yyleng++;
50         switch (ch) {
51             case '"':
52                 if (backSlash) {
53                     /* \" */
54                     yytext[count++] = '"';
55                 } else {
56                     yyleng--;
57                     yytext[count] = '\0';
58                     dynerlval.sval = strdup(yytext);
59                     return(STRING);
60                 }
61                 break;
62
63             case '\n':
64                 /* New line before end of string */
65                 return(_ERROR);
66                 break;
67
68             case '\\':
69                 yytext[count++] = ch;
70                 backSlash = true;
71                 break;
72
73             case 'n':
74                 if (backSlash) {
75                     yytext[count-1] = '\n';
76                 } else {
77                     yytext[count++] = ch;
78                 }
79                 backSlash = false;
80                 break;
81
82             default:
83                 yytext[count++] = ch;
84                 backSlash = false;
85                 break;
86         }
87     }
88 }
89
90 %}
91
92 %%
93
94 if                      { return IF; }
95
96 else                    { return ELSE; }
97
98 [0-9]+                  { dynerlval.ival = atoi(yytext); return NUMBER; }
99
100 [A-za-z][A-Za-z0-9_]*   { dynerlval.sval = strdup(yytext); return IDENTIFIER; }
101
102 \<=                     { return LESS_EQ; }
103
104 \>=                     { return GREATER_EQ; }
105
106 ==                      { return EQ; }
107
108 ,                       { return COMMA; }
109
110 =                       { return ASSIGN; }
111
112 !=                      { return NOT_EQ; }
113  
114 \{                      { return START_BLOCK; }
115
116 \}                      { return END_BLOCK; }
117
118 \$                      { return DOLLAR; }
119
120 \.                      { return DOT; }
121
122 ;                       { return SEMI; }
123
124 [()<>+*/-]              { return yytext[0]; }
125
126 &&                      { return AND; }
127
128 \|\|                    { return OR; }
129
130 [ \t\n]+                { /* Nothing */; }
131
132 \"                      { int ret;
133                           ret = doubleQuote();
134                           return(ret);
135                         }
136
137 "++"                    { return PLUSPLUS; }
138
139 "--"                    { return MINUSMINUS; }
140
141 .                       { return _ERROR; }
142
143 %%
144
145 void set_lex_input(char *str)
146 {
147     static int firstCall = 1;
148
149     input_str = str;
150
151     if (!firstCall) yy_flush_buffer(YY_CURRENT_BUFFER);
152     firstCall = 0;
153 }
154
155 #ifdef FLEX_SCANNER
156 int my_yyinput(char *buf, int max_size)
157 {
158     int sz = 0;
159
160     while (*input_str != '\0' && sz < max_size) {
161         *buf++ = *input_str++;
162         sz++;
163     }
164
165     return sz;
166 }
167 #endif
168
169 #if !defined(i386_unknown_nt4_0)
170 int yywrap()
171 {
172     return 1;
173 }
174 #endif