2001-06-12 21:06:28 +00:00
|
|
|
%{
|
2001-09-28 07:09:38 +00:00
|
|
|
/*
|
2002-11-06 16:32:28 +00:00
|
|
|
qc-lex.l
|
2001-09-28 07:09:38 +00:00
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
lexer for quakec
|
2001-09-28 07:09:38 +00:00
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-09-28 07:09:38 +00:00
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2001/06/12
|
2001-09-28 07:09:38 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
2002-06-01 04:41:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-14 20:18:29 +00:00
|
|
|
|
2002-06-01 04:41:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2002-06-27 22:48:28 +00:00
|
|
|
#include <QF/dstring.h>
|
2001-06-13 07:16:39 +00:00
|
|
|
#include <QF/hash.h>
|
2001-10-24 22:50:06 +00:00
|
|
|
#include <QF/sys.h>
|
2002-06-27 22:48:28 +00:00
|
|
|
|
2011-01-06 07:30:25 +00:00
|
|
|
#include "class.h"
|
2011-01-06 05:57:40 +00:00
|
|
|
#include "debug.h"
|
2011-01-24 12:54:57 +00:00
|
|
|
#include "diagnostic.h"
|
2002-06-01 05:30:16 +00:00
|
|
|
#include "expr.h"
|
2011-01-06 07:30:25 +00:00
|
|
|
#include "grab.h"
|
2002-06-04 18:44:03 +00:00
|
|
|
#include "options.h"
|
2012-11-22 11:42:00 +00:00
|
|
|
#include "pragma.h"
|
2011-01-24 12:31:32 +00:00
|
|
|
#include "qfcc.h"
|
|
|
|
#include "strpool.h"
|
2001-12-08 08:19:48 +00:00
|
|
|
#include "struct.h"
|
2011-01-17 13:33:33 +00:00
|
|
|
#include "symtab.h"
|
2002-01-23 20:50:25 +00:00
|
|
|
#include "type.h"
|
2011-03-22 03:24:39 +00:00
|
|
|
#include "value.h"
|
2011-01-06 05:57:40 +00:00
|
|
|
|
2001-06-12 21:06:28 +00:00
|
|
|
#include "qc-parse.h"
|
|
|
|
|
2003-04-16 19:41:52 +00:00
|
|
|
#ifndef YY_PROTO
|
|
|
|
# define YY_PROTO(x) x
|
|
|
|
#else
|
|
|
|
# define YY_FLEX_REALLOC_HACK
|
|
|
|
#endif
|
|
|
|
int yyget_lineno (void);
|
|
|
|
FILE *yyget_in (void);
|
|
|
|
FILE *yyget_out (void);
|
|
|
|
int yyget_leng (void);
|
|
|
|
char *yyget_text (void);
|
|
|
|
void yyset_lineno (int line_number);
|
|
|
|
void yyset_in (FILE * in_str);
|
|
|
|
void yyset_out (FILE * out_str);
|
|
|
|
int yyget_debug (void);
|
|
|
|
void yyset_debug (int bdebug);
|
|
|
|
int yylex_destroy (void);
|
|
|
|
|
2001-06-12 21:06:28 +00:00
|
|
|
#define YY_NO_UNPUT
|
2003-01-06 18:28:13 +00:00
|
|
|
#define YY_DECL int yylex YY_PROTO(( void ))
|
|
|
|
YY_DECL;
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2003-04-16 19:41:52 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
static int keyword_or_id (char *token);
|
2001-06-25 22:11:20 +00:00
|
|
|
|
2012-10-26 07:01:41 +00:00
|
|
|
extern QC_YYSTYPE qc_yylval;
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2001-06-12 21:06:28 +00:00
|
|
|
%}
|
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
s [ \t]
|
|
|
|
m [\-+]
|
|
|
|
D [0-9]
|
|
|
|
X [0-9a-fA-F]
|
|
|
|
ID [a-zA-Z_][a-zA-Z_0-9]*
|
|
|
|
FLOAT ({D}+|{D}*\.{D}+|{D}+\.{D}*)([eE]{m}?{D}+)?
|
|
|
|
INT ({D}+|0[xX]{X}+)
|
|
|
|
RANGE \.\.
|
|
|
|
ELLIPSIS \.\.\.
|
|
|
|
FRAMEID {ID}(\.{ID})*
|
2012-11-22 11:42:00 +00:00
|
|
|
PRAGMAID {ID}(-{ID})*
|
2011-01-17 13:33:33 +00:00
|
|
|
STRING \"(\\.|[^"\\])*\"
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2012-11-22 11:42:00 +00:00
|
|
|
%x GRAB_FRAME GRAB_OTHER COMMENT PRAGMA
|
2001-06-13 18:35:41 +00:00
|
|
|
|
2001-06-12 21:06:28 +00:00
|
|
|
%%
|
2011-01-06 07:30:25 +00:00
|
|
|
grab_frame = GRAB_FRAME;
|
|
|
|
grab_other = GRAB_OTHER;
|
|
|
|
|
|
|
|
"/*" { BEGIN (COMMENT); }
|
|
|
|
<COMMENT>"/*" { warning (0, "nested /* in comment"); }
|
|
|
|
<COMMENT>"*/" { BEGIN (INITIAL); }
|
|
|
|
<COMMENT>\r*\n { pr.source_line++; }
|
|
|
|
<COMMENT>. /* nothing to do */
|
|
|
|
<COMMENT><<EOF>> { error (0, "EOF in comment"); return 0; }
|
2007-03-30 09:02:36 +00:00
|
|
|
"//".* /* nothing to do */
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
^#{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { line_info (yytext + 1); }
|
|
|
|
^#line{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { line_info (yytext + 5); }
|
2007-04-06 05:52:20 +00:00
|
|
|
|
2012-11-22 11:42:00 +00:00
|
|
|
^{s}*#{s}*pragma{s}+ { BEGIN (PRAGMA); }
|
2007-04-06 05:52:20 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
{INT}+[uU]? {
|
2010-12-23 10:32:28 +00:00
|
|
|
const char *c = yytext + yyleng - 1;
|
2011-01-14 03:10:28 +00:00
|
|
|
int i = strtol (yytext, 0, 0);
|
2010-12-23 10:32:28 +00:00
|
|
|
if (*c == 'u' || *c == 'U')
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_integer_expr (i);//FIXME
|
2011-01-14 03:10:28 +00:00
|
|
|
else
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_integer_expr (i);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
{FLOAT} {
|
|
|
|
float f = strtof (yytext, 0);
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_float_expr (f);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2002-10-26 03:23:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
{ID} {
|
|
|
|
int tok = keyword_or_id(yytext);
|
|
|
|
return tok;
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
@{ID} {
|
2011-01-14 03:10:28 +00:00
|
|
|
int tok = keyword_or_id(yytext);
|
2002-05-07 16:55:54 +00:00
|
|
|
if (tok == '@')
|
|
|
|
REJECT;
|
|
|
|
return tok;
|
|
|
|
}
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
{STRING} {
|
2011-01-14 03:10:28 +00:00
|
|
|
const char *s = make_string (yytext, 0);
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_string_expr (s);
|
2011-01-17 13:33:33 +00:00
|
|
|
return STRING;
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
@ return '@';
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
'{s}*{m}?{FLOAT}{s}+{m}?{FLOAT}{s}+{m}?{FLOAT}{s}*' {
|
|
|
|
vec3_t v;
|
2001-06-25 17:15:56 +00:00
|
|
|
sscanf (yytext, "' %f %f %f '",
|
2011-01-14 03:10:28 +00:00
|
|
|
&v[0], &v[1], &v[2]);
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_vector_expr (v);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
'{s}*{m}?{FLOAT}{s}+{m}?{FLOAT}{s}+{m}?{FLOAT}{s}+{m}?{FLOAT}{s}*' {
|
|
|
|
quat_t q;
|
|
|
|
sscanf (yytext, "' %f %f %f %f'",
|
|
|
|
&q[0], &q[1], &q[2], &q[3]);
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_quaternion_expr (q);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2002-01-04 08:45:24 +00:00
|
|
|
}
|
|
|
|
|
2002-01-04 17:13:13 +00:00
|
|
|
'(\\[^xX0-7\r\n]|[^'\r\n]|\\[xX][0-9A-Fa-f]+|\\[0-7]+)*' {
|
2007-03-31 15:27:36 +00:00
|
|
|
const char *str = make_string (yytext, 0);
|
2002-01-04 08:45:24 +00:00
|
|
|
|
|
|
|
if (str[1])
|
|
|
|
warning (0, "multibyte char constant");
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_integer_expr (*str);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
|
|
|
|
2001-08-20 06:22:28 +00:00
|
|
|
[+\-*/&|^%]= {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = yytext[0];
|
2001-08-20 06:22:28 +00:00
|
|
|
return ASX;
|
|
|
|
}
|
|
|
|
|
|
|
|
"<<=" {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = SHL;
|
2001-08-20 06:22:28 +00:00
|
|
|
return ASX;
|
|
|
|
}
|
|
|
|
|
|
|
|
">>=" {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = SHR;
|
2001-08-20 06:22:28 +00:00
|
|
|
return ASX;
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:39 +00:00
|
|
|
[!(){}.*/&|^~+\-=\[\];,#%?:] {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.pointer = 0; // ensure pointer vals are null
|
2002-05-01 21:35:39 +00:00
|
|
|
return yytext[0];
|
|
|
|
}
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
{ELLIPSIS} return ELLIPSIS;
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
"<<" return SHL;
|
|
|
|
">>" return SHR;
|
2001-08-10 16:17:00 +00:00
|
|
|
|
2011-01-14 03:10:28 +00:00
|
|
|
"&&" return AND;
|
|
|
|
"||" return OR;
|
|
|
|
"==" return EQ;
|
|
|
|
"!=" return NE;
|
|
|
|
"<=" return LE;
|
|
|
|
">=" return GE;
|
|
|
|
"<" return LT;
|
|
|
|
">" return GT;
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2001-08-20 06:22:28 +00:00
|
|
|
"++" {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = '+';
|
2001-08-20 06:22:28 +00:00
|
|
|
return INCOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
"--" {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = '-';
|
2001-08-20 06:22:28 +00:00
|
|
|
return INCOP;
|
|
|
|
}
|
|
|
|
|
2007-04-06 08:19:58 +00:00
|
|
|
"$"{s}*{FRAMEID} {
|
2007-04-06 05:52:20 +00:00
|
|
|
int ret = do_grab (yytext);
|
2011-01-06 07:30:25 +00:00
|
|
|
if (ret >= 0) {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.expr = new_integer_expr (ret);
|
2011-01-14 03:10:28 +00:00
|
|
|
return CONST;
|
2011-01-06 07:30:25 +00:00
|
|
|
} else {
|
2001-06-13 18:35:41 +00:00
|
|
|
BEGIN (-ret);
|
2011-01-06 07:30:25 +00:00
|
|
|
}
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2011-01-06 07:30:25 +00:00
|
|
|
<GRAB_FRAME>{FRAMEID} add_frame_macro (yytext);
|
|
|
|
<GRAB_OTHER>[^\r\n]* /* skip */
|
2012-11-22 11:42:00 +00:00
|
|
|
<PRAGMA>{ID} { pragma (yytext); }
|
2001-06-13 18:35:41 +00:00
|
|
|
|
2002-01-04 18:27:01 +00:00
|
|
|
<*>\r*\n {
|
2002-07-03 21:32:03 +00:00
|
|
|
pr.source_line++;
|
2001-06-13 18:35:41 +00:00
|
|
|
BEGIN (INITIAL);
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2001-06-12 21:06:28 +00:00
|
|
|
|
2001-06-13 18:35:41 +00:00
|
|
|
<*>{s}* /* skip */
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2001-06-28 21:26:40 +00:00
|
|
|
<*>. error (0, "all your typo are belong to us");
|
2001-06-12 21:06:28 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
int
|
|
|
|
yywrap (void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2001-06-13 07:16:39 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2011-01-17 13:33:33 +00:00
|
|
|
const char *name;
|
|
|
|
int value;
|
|
|
|
type_t *type;
|
2012-07-14 07:32:48 +00:00
|
|
|
int traditional;
|
|
|
|
unsigned version;
|
2011-02-03 23:38:58 +00:00
|
|
|
int objc;
|
2001-06-13 07:16:39 +00:00
|
|
|
} keyword_t;
|
|
|
|
|
|
|
|
static keyword_t keywords[] = {
|
2012-07-14 07:32:48 +00:00
|
|
|
{"void", TYPE, &type_void, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"float", TYPE, &type_float, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"string", TYPE, &type_string, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"vector", TYPE, &type_vector, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"entity", TYPE, &type_entity, 2, PROG_ID_VERSION, 0},
|
2011-02-03 23:38:58 +00:00
|
|
|
{"quaternion", TYPE, &type_quaternion, 0, PROG_VERSION, 0},
|
2011-03-25 07:46:32 +00:00
|
|
|
{"int", TYPE, &type_integer, 0, PROG_VERSION, 0},
|
2011-02-03 23:38:58 +00:00
|
|
|
{"unsigned", TYPE, &type_integer, 0, PROG_VERSION, 0},//FIXME
|
|
|
|
{"function", TYPE, &type_function, 0, PROG_VERSION, 0},
|
|
|
|
{"id", TYPE, &type_id, 0, PROG_VERSION, 1},
|
2012-11-08 11:58:48 +00:00
|
|
|
{"Class", TYPE, &type_Class, 0, PROG_VERSION, 1},
|
2011-02-03 23:38:58 +00:00
|
|
|
// {"Protocol", TYPE, &type_Protocol, 0, PROG_VERSION, 0},
|
2012-11-12 02:12:33 +00:00
|
|
|
{"Method", TYPE, &type_obj_method, 0, PROG_VERSION, 1},
|
|
|
|
{"Super", TYPE, &type_obj_super, 0, PROG_VERSION, 1},
|
2011-02-03 23:38:58 +00:00
|
|
|
{"SEL", TYPE, &type_SEL, 0, PROG_VERSION, 1},
|
|
|
|
{"IMP", TYPE, &type_IMP, 0, PROG_VERSION, 1},
|
2012-07-14 07:32:48 +00:00
|
|
|
{"local", LOCAL, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"return", RETURN, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"while", WHILE, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"do", DO, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"if", IF, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"else", ELSE, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"for", FOR, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"break", BREAK, 0, 2, PROG_ID_VERSION, 0},
|
|
|
|
{"continue", CONTINUE, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"switch", SWITCH, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"case", CASE, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"default", DEFAULT, 0, 1, PROG_ID_VERSION, 0},
|
2011-02-03 23:38:58 +00:00
|
|
|
{"nil", NIL, 0, 0, PROG_ID_VERSION, 0},
|
2012-11-27 09:31:47 +00:00
|
|
|
{"@nil", NIL, 0, 2, PROG_ID_VERSION, 0},
|
2011-02-03 23:38:58 +00:00
|
|
|
{"struct", STRUCT, 0, 0, PROG_VERSION, 0},
|
|
|
|
{"union", STRUCT, 0, 0, PROG_VERSION, 0},
|
|
|
|
{"enum", ENUM, 0, 0, PROG_ID_VERSION, 0},
|
|
|
|
{"typedef", TYPEDEF, 0, 0, PROG_ID_VERSION, 0},
|
|
|
|
|
2012-11-27 09:31:01 +00:00
|
|
|
// this is a hack to trigger the initialization of the class
|
2011-03-03 23:25:50 +00:00
|
|
|
// sytem if they are seen before any other Objective-QC symbol
|
2012-11-27 09:31:01 +00:00
|
|
|
{"obj_module", 0, 0, 0, PROG_VERSION, 1},
|
2011-03-03 23:25:50 +00:00
|
|
|
|
2011-02-03 23:38:58 +00:00
|
|
|
{"@class", CLASS, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@defs", DEFS, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@encode", ENCODE, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@end", END, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@implementation", IMPLEMENTATION, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@interface", INTERFACE, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@private", PRIVATE, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@protected", PROTECTED, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@protocol", PROTOCOL, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@public", PUBLIC, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@reference", REFERENCE, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@selector", SELECTOR, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@self", SELF, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@this", THIS, 0, 0, PROG_VERSION, 1},
|
|
|
|
{"@args", ARGS, 0, 0, PROG_VERSION, 0},
|
|
|
|
{"@va_list", TYPE, &type_va_list, 0, PROG_VERSION, 0},
|
|
|
|
{"@param", TYPE, &type_param, 0, PROG_VERSION, 0},
|
|
|
|
{"@extern", EXTERN, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"@static", STATIC, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"@system", SYSTEM, 0, 1, PROG_ID_VERSION, 0},
|
|
|
|
{"@sizeof", SIZEOF, 0, 0, PROG_VERSION, 0},
|
|
|
|
{"@overload", OVERLOAD, 0, 0, PROG_VERSION, 0},
|
2001-06-13 07:16:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *
|
2012-07-18 13:34:37 +00:00
|
|
|
keyword_get_key (const void *kw, void *unused)
|
2001-06-13 07:16:39 +00:00
|
|
|
{
|
|
|
|
return ((keyword_t*)kw)->name;
|
|
|
|
}
|
|
|
|
|
2011-01-06 07:30:25 +00:00
|
|
|
static int
|
2011-01-14 03:10:28 +00:00
|
|
|
keyword_or_id (char *token)
|
2001-06-13 07:16:39 +00:00
|
|
|
{
|
|
|
|
static hashtab_t *keyword_tab;
|
2001-12-08 08:19:48 +00:00
|
|
|
keyword_t *keyword;
|
2011-01-17 13:33:33 +00:00
|
|
|
symbol_t *sym;
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2001-12-08 08:19:48 +00:00
|
|
|
if (!keyword_tab) {
|
2007-04-06 05:52:20 +00:00
|
|
|
size_t i;
|
2001-06-13 07:16:39 +00:00
|
|
|
keyword_tab = Hash_NewTable (1021, keyword_get_key, 0, 0);
|
|
|
|
for (i = 0; i < sizeof (keywords) / sizeof (keywords[0]); i++)
|
2002-02-18 06:23:59 +00:00
|
|
|
if (keywords[i].traditional >= options.traditional
|
|
|
|
&& keywords[i].version <= options.code.progsversion)
|
2001-08-07 16:50:22 +00:00
|
|
|
Hash_Add (keyword_tab, &keywords[i]);
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
|
|
|
keyword = Hash_Find (keyword_tab, token);
|
|
|
|
if (keyword) {
|
2012-11-08 07:46:48 +00:00
|
|
|
if (!options.traditional && keyword->objc && !obj_initialized)
|
2002-05-22 01:39:07 +00:00
|
|
|
class_init ();
|
2011-03-03 23:25:50 +00:00
|
|
|
if (keyword->value) {
|
|
|
|
if (keyword->value == STRUCT) {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.op = token[0];
|
2011-03-03 23:25:50 +00:00
|
|
|
} else {
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.type = 0;
|
|
|
|
qc_yylval.type = keyword->type;
|
2011-03-03 23:25:50 +00:00
|
|
|
}
|
|
|
|
return keyword->value;
|
2011-01-17 13:33:33 +00:00
|
|
|
}
|
2001-06-13 07:16:39 +00:00
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
if (token[0] == '@') {
|
|
|
|
return '@';
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
sym = symtab_lookup (current_symtab, token);
|
|
|
|
if (!sym)
|
|
|
|
sym = new_symbol (token);
|
2012-10-26 07:01:41 +00:00
|
|
|
qc_yylval.symbol = sym;
|
2011-01-17 13:33:33 +00:00
|
|
|
if (sym->sy_type == sy_type)
|
2004-11-02 07:02:00 +00:00
|
|
|
return TYPE_NAME;
|
2011-02-13 07:05:09 +00:00
|
|
|
if (sym->sy_type == sy_class)
|
2011-01-17 13:33:33 +00:00
|
|
|
return CLASS_NAME;
|
2001-06-13 07:16:39 +00:00
|
|
|
return NAME;
|
|
|
|
}
|
|
|
|
|
2003-04-16 19:41:52 +00:00
|
|
|
#ifdef YY_FLEX_REALLOC_HACK
|
2008-07-19 05:40:57 +00:00
|
|
|
static __attribute__ ((used)) void *(*const yy_flex_realloc_hack)(void *,yy_size_t) = yy_flex_realloc;
|
2003-04-17 00:25:55 +00:00
|
|
|
#else
|
2008-07-19 05:40:57 +00:00
|
|
|
static __attribute__ ((used)) void (*yyunput_hack)(int, char*) = yyunput;
|
|
|
|
static __attribute__ ((used)) int (*input_hack)(void) = input;
|
2003-04-17 00:14:13 +00:00
|
|
|
#endif
|