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
28 #define Return(x) return x;
30 #if defined(VMS) && !defined(strdup)
31 #define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s));
34 static size_t lex_buffer_length = 0;
35 static const char *lex_buffer = NULL;
36 static size_t lex_string_ptr = 0;
37 static int lex_read_from_string = 0;
39 static int my_input(void);
43 # define YY_INPUT(buf,result,max_size) \
44 if (lex_read_from_string) \
45 { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
47 if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
48 YY_FATAL_ERROR( "read() in flex scanner failed" );
51 # define unput(_c) my_unput(_c)
52 static int my_unput(char);
59 {SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);}
63 {ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);}
65 "'"{WORDCHAR}*"'" {int len = strlen(yytext);
67 yylval.s = strdup(yytext+1);
70 \"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);}
78 "[" Return(OPEN_SQUARE);
80 "]" Return(CLOSE_SQUARE);
92 while (yyinput() != '*');
95 while (input() != '*');
100 case '*': unput('*');
111 static int lex_input() {
114 #else /* BSD/AT&T lex */
116 # error "Sorry, but need either flex or AT&T lex"
118 static int lex_input() {
123 # define input() my_input()
124 static int my_unput(char c)
126 if (lex_read_from_string != 0) {
127 /* Make sure we have something */
128 if (lex_string_ptr) {
129 if (c == '\n') yylineno--;
133 yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
134 /* unput(c); Causes infinite recursion! */
142 void LexFromFile(FILE *fd)
144 lex_read_from_string = 0;
146 /* Don't know why this is necessary, but otherwise
147 * lex only works _once_!
155 void LexFromString(char *buffer)
157 lex_read_from_string = 1;
159 lex_buffer_length = strlen(buffer);
161 /* Don't know why this is necessary, but otherwise
162 * lex only works _once_!
169 static int my_input( void )
171 if (lex_read_from_string) {
172 if (lex_string_ptr == lex_buffer_length)
175 char c = lex_buffer[lex_string_ptr++];
177 if (c == '\n') yylineno++;
189 if (yy_current_buffer)
190 yy_delete_buffer(yy_current_buffer);