4 ALPHADIGIT [a-zA-Z_0-9]
11 * Description: Lexical analyser for PROLOGIO; can be used with
12 * either lex and flex.
13 * Copyright: (c) Julian Smart
14 * Licence: wxWindows Licence
19 /* +++steve162e: added, otherwise, PROIO_input will be undefined (at least under LINUX)
20 please check, if this is also TRUE under other UNIXes.
23 #if defined(FLEX_SCANNER) && defined(_LINUX)
24 #define PROIO_input my_input
28 #include "wx/deprecated/expr.h"
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);
45 # define YY_INPUT(buf,result,max_size) \
46 if (lex_read_from_string) \
47 { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \
49 if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
50 YY_FATAL_ERROR( "read() in flex scanner failed" );
53 # define unput(_c) my_unput(_c)
54 static int my_unput(char);
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() {
125 # define input() my_input()
126 static int my_unput(char c)
128 if (lex_read_from_string != 0) {
129 /* Make sure we have something */
130 if (lex_string_ptr) {
131 if (c == '\n') yylineno--;
135 yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;
136 /* unput(c); Causes infinite recursion! */
144 void LexFromFile(FILE *fd)
146 lex_read_from_string = 0;
148 /* Don't know why this is necessary, but otherwise
149 * lex only works _once_!
157 void LexFromString(char *buffer)
159 lex_read_from_string = 1;
161 lex_buffer_length = strlen(buffer);
163 /* Don't know why this is necessary, but otherwise
164 * lex only works _once_!
171 static int my_input( void )
173 if (lex_read_from_string) {
174 if (lex_string_ptr == lex_buffer_length)
177 char c = lex_buffer[lex_string_ptr++];
179 if (c == '\n') yylineno++;
191 if (yy_current_buffer)
192 yy_delete_buffer(yy_current_buffer);