4 ALPHADIGIT [a-zA-Z_0-9]
11 * Description: Lexical analyser for PROLOGIO; can be used with
12 * either lex and flex.
17 /* +++steve162e: added, otherwise, PROIO_input will be undefined (at least under LINUX)
18 please check, if this is also TRUE under other UNIXes.
21 #if defined(FLEX_SCANNER) && defined(_LINUX)
22 #define PROIO_input my_input
29 extern char *malloc();
31 #define Return(x) return x;
33 #if defined(VMS) && !defined(strdup)
34 #define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s));
37 static size_t lex_buffer_length = 0;
38 static const char *lex_buffer = NULL;
39 static size_t lex_string_ptr = 0;
40 static int lex_read_from_string = 0;
42 static int my_input(void);
43 static int my_unput(char);
47 # define YY_INPUT(buf,result,max_size) \
48 if (lex_read_from_string) \
49 { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
51 if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
52 YY_FATAL_ERROR( "read() in flex scanner failed" );
55 # define unput(_c) my_unput(_c)
62 {SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);}
66 {ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);}
68 "'"{WORDCHAR}*"'" {int len = strlen(yytext);
70 yylval.s = strdup(yytext+1);
73 \"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);}
81 "[" Return(OPEN_SQUARE);
83 "]" Return(CLOSE_SQUARE);
95 while (yyinput() != '*');
98 while (input() != '*');
103 case '*': unput('*');
114 static int lex_input() {
117 #else /* BSD/AT&T lex */
119 # error "Sorry, but need either flex or AT&T lex"
121 static int lex_input() {
125 # define unput(_c) my_unput(_c)
129 # define input() my_input()
130 static int my_unput(char c)
132 if (lex_read_from_string) {
133 /* Make sure we have something */
134 if (lex_string_ptr) {
135 if (c == '\n') yylineno--;
139 yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
140 /* unput(c); Causes infinite recursion! */
148 void LexFromFile(FILE *fd)
150 lex_read_from_string = 0;
152 /* Don't know why this is necessary, but otherwise
153 * lex only works _once_!
161 void LexFromString(char *buffer)
163 lex_read_from_string = 1;
165 lex_buffer_length = strlen(buffer);
167 /* Don't know why this is necessary, but otherwise
168 * lex only works _once_!
175 static int my_input( void )
177 if (lex_read_from_string) {
178 if (lex_string_ptr == lex_buffer_length)
181 char c = lex_buffer[lex_string_ptr++];
183 if (c == '\n') yylineno++;
195 if (yy_current_buffer)
196 yy_delete_buffer(yy_current_buffer);