4 ALPHADIGIT [a-zA-Z_0-9]
11 * Description: Lexical analyser for PROLOGIO; can be used with
12 * either lex and flex.
16 /* +++steve162e: added, otherwise, PROIO_input will be undefined (at least under LINUX)
17 please check, if this is also TRUE under other UNIXes.
20 #if defined(FLEX_SCANNER) && defined(_LINUX)
21 #define PROIO_input my_input
28 extern char *malloc();
30 #define Return(x) return x;
32 #if defined(VMS) && !defined(strdup)
33 #define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s));
36 static size_t lex_buffer_length = 0;
37 static const char *lex_buffer = NULL;
38 static size_t lex_string_ptr = 0;
39 static int lex_read_from_string = 0;
41 static int my_input(void);
42 static int my_unput(char);
46 # define YY_INPUT(buf,result,max_size) \
47 if (lex_read_from_string) \
48 { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
50 if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
51 YY_FATAL_ERROR( "read() in flex scanner failed" );
54 # define unput(_c) my_unput(_c)
61 {SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);}
65 {ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);}
67 "'"{WORDCHAR}*"'" {int len = strlen(yytext);
69 yylval.s = strdup(yytext+1);
72 \"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);}
80 "[" Return(OPEN_SQUARE);
82 "]" Return(CLOSE_SQUARE);
94 while (yyinput() != '*');
97 while (input() != '*');
102 case '*': unput('*');
113 static int lex_input() {
116 #else /* BSD/AT&T lex */
118 # error "Sorry, but need either flex or AT&T lex"
120 static int lex_input() {
124 # define unput(_c) my_unput(_c)
128 # define input() my_input()
129 static int my_unput(char c)
131 if (lex_read_from_string) {
132 /* Make sure we have something */
133 if (lex_string_ptr) {
134 if (c == '\n') yylineno--;
138 yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
139 /* unput(c); Causes infinite recursion! */
147 void LexFromFile(FILE *fd)
149 lex_read_from_string = 0;
151 /* Don't know why this is necessary, but otherwise
152 * lex only works _once_!
160 void LexFromString(char *buffer)
162 lex_read_from_string = 1;
164 lex_buffer_length = strlen(buffer);
166 /* Don't know why this is necessary, but otherwise
167 * lex only works _once_!
174 static int my_input( void )
176 if (lex_read_from_string) {
177 if (lex_string_ptr == lex_buffer_length)
180 char c = lex_buffer[lex_string_ptr++];
182 if (c == '\n') yylineno++;
193 if (yy_current_buffer)
194 yy_delete_buffer(yy_current_buffer);