mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 05:01:24 +00:00
[qfcc] Unify much of the qc and glsl parser interface
This gets the types such that either there is only one definition, or C sees the same name for what is essentially the same type despite there being multiple local definitions.
This commit is contained in:
parent
6266ac4d94
commit
5191fc26a3
15 changed files with 47 additions and 76 deletions
|
@ -60,7 +60,34 @@ typedef struct rua_tok_s {
|
|||
const char *text;
|
||||
} rua_tok_t;
|
||||
|
||||
typedef union rua_val_s {
|
||||
int op;
|
||||
unsigned size;
|
||||
specifier_t spec;
|
||||
void *pointer; // for ensuring pointer values are null
|
||||
struct type_s *type;
|
||||
const struct expr_s *expr;
|
||||
struct expr_s *mut_expr;
|
||||
struct element_s *element;
|
||||
struct function_s *function;
|
||||
struct switch_block_s *switch_block;
|
||||
struct param_s *param;
|
||||
struct method_s *method;
|
||||
struct class_s *class;
|
||||
struct category_s *category;
|
||||
struct class_type_s *class_type;
|
||||
struct protocol_s *protocol;
|
||||
struct protocollist_s *protocol_list;
|
||||
struct keywordarg_s *keywordarg;
|
||||
struct methodlist_s *methodlist;
|
||||
struct symbol_s *symbol;
|
||||
struct symtab_s *symtab;
|
||||
struct attribute_s *attribute;
|
||||
struct designator_s *designator;
|
||||
} rua_val_t;
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
#include "tools/qfcc/source/glsl-parse.h"
|
||||
|
||||
typedef struct rua_macro_s rua_macro_t;
|
||||
typedef void (*rua_macro_f) (rua_macro_t *macro, void *scanner);
|
||||
|
@ -80,14 +107,14 @@ typedef struct rua_macro_s {
|
|||
rua_macro_t **args;
|
||||
} rua_macro_t;
|
||||
|
||||
typedef struct rua_val_s {
|
||||
typedef struct rua_preval_s {
|
||||
rua_tok_t t;
|
||||
union {
|
||||
const expr_t *expr;
|
||||
dstring_t *dstr;
|
||||
rua_macro_t *macro;
|
||||
};
|
||||
} rua_val_t;
|
||||
} rua_preval_t;
|
||||
|
||||
rua_macro_t *rua_start_macro (const char *name, bool params, void *scanner);
|
||||
rua_macro_t *rua_macro_param (rua_macro_t *macro, const rua_tok_t *token,
|
||||
|
|
|
@ -47,12 +47,11 @@
|
|||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/qfcc.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
typedef const expr_t *(*operation_t) (int op, const expr_t *e,
|
||||
const expr_t *e1, const expr_t *e2);
|
||||
typedef const expr_t *(*unaryop_t) (int op, const expr_t *e,
|
||||
|
|
|
@ -50,13 +50,12 @@
|
|||
#include "tools/qfcc/include/algebra.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/method.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
#define EX_EXPR(expr) #expr,
|
||||
const char *expr_names[] =
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "tools/qfcc/include/method.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/reloc.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/shared.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/struct.h"
|
||||
|
@ -65,8 +66,6 @@
|
|||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
ALLOC_STATE (expr_t, exprs);
|
||||
ALLOC_STATE (ex_listitem_t, listitems);
|
||||
|
||||
|
|
|
@ -36,12 +36,11 @@
|
|||
#include "tools/qfcc/include/algebra.h"
|
||||
#include "tools/qfcc/include/diagnostic.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
static int __attribute__((pure))
|
||||
get_group (const type_t *type, algebra_t *algebra)
|
||||
{
|
||||
|
|
|
@ -35,10 +35,9 @@
|
|||
#include "tools/qfcc/include/diagnostic.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
typedef struct {
|
||||
int op;
|
||||
type_t *result_type;
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "tools/qfcc/include/method.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/reloc.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/shared.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/struct.h"
|
||||
|
@ -64,8 +65,6 @@
|
|||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
const expr_t *
|
||||
test_expr (const expr_t *e)
|
||||
{
|
||||
|
|
|
@ -36,12 +36,11 @@
|
|||
#include "tools/qfcc/include/algebra.h"
|
||||
#include "tools/qfcc/include/diagnostic.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
static const expr_t *optimize_core (const expr_t *expr);
|
||||
static const expr_t skip;
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
%define api.token.prefix {GLSL_}
|
||||
%locations
|
||||
%parse-param {void *scanner}
|
||||
%define api.value.type {rua_val_t}
|
||||
%define api.location.type {rua_loc_t}
|
||||
|
||||
%{
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -107,28 +109,7 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
|
|||
|
||||
%}
|
||||
|
||||
%code requires { #include "tools/qfcc/include/type.h" }
|
||||
|
||||
%define api.location.type {struct rua_loc_s}
|
||||
|
||||
%union {
|
||||
int op;
|
||||
unsigned size;
|
||||
specifier_t spec;
|
||||
void *pointer; // for ensuring pointer values are null
|
||||
struct type_s *type;
|
||||
const struct expr_s *expr;
|
||||
struct expr_s *mut_expr;
|
||||
struct element_s *element;
|
||||
struct function_s *function;
|
||||
struct switch_block_s *switch_block;
|
||||
struct param_s *param;
|
||||
struct method_s *method;
|
||||
struct symbol_s *symbol;
|
||||
struct symtab_s *symtab;
|
||||
struct attribute_s *attribute;
|
||||
struct designator_s *designator;
|
||||
}
|
||||
%code requires { #define glsl_yypstate rua_yypstate }
|
||||
|
||||
// these tokens are common between qc and qp
|
||||
%left LOW
|
||||
|
|
|
@ -49,12 +49,11 @@
|
|||
#include "tools/qfcc/include/cpp.h"
|
||||
#include "tools/qfcc/include/linker.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/qfcc.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
options_t options = {
|
||||
.code = {
|
||||
.fast_float = true,
|
||||
|
|
|
@ -47,11 +47,10 @@
|
|||
#include "tools/qfcc/include/opcodes.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/pragma.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
typedef struct pragma_arg_s {
|
||||
struct pragma_arg_s *next;
|
||||
const char *arg;
|
||||
|
|
|
@ -87,7 +87,7 @@ parse_error (void *scanner)
|
|||
%code requires {
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
}
|
||||
%define api.value.type {rua_val_t}
|
||||
%define api.value.type {rua_preval_t}
|
||||
%define api.location.type {rua_loc_t}
|
||||
|
||||
%left LOW
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
%define api.token.prefix {QC_}
|
||||
%locations
|
||||
%parse-param {void *scanner}
|
||||
%define api.value.type {rua_val_t}
|
||||
%define api.location.type {rua_loc_t}
|
||||
|
||||
%{
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -107,35 +109,7 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
|
|||
|
||||
%}
|
||||
|
||||
%code requires { #include "tools/qfcc/include/type.h" }
|
||||
|
||||
%define api.location.type {struct rua_loc_s}
|
||||
|
||||
%union {
|
||||
int op;
|
||||
unsigned size;
|
||||
specifier_t spec;
|
||||
void *pointer; // for ensuring pointer values are null
|
||||
struct type_s *type;
|
||||
const struct expr_s *expr;
|
||||
struct expr_s *mut_expr;
|
||||
struct element_s *element;
|
||||
struct function_s *function;
|
||||
struct switch_block_s *switch_block;
|
||||
struct param_s *param;
|
||||
struct method_s *method;
|
||||
struct class_s *class;
|
||||
struct category_s *category;
|
||||
struct class_type_s *class_type;
|
||||
struct protocol_s *protocol;
|
||||
struct protocollist_s *protocol_list;
|
||||
struct keywordarg_s *keywordarg;
|
||||
struct methodlist_s *methodlist;
|
||||
struct symbol_s *symbol;
|
||||
struct symtab_s *symtab;
|
||||
struct attribute_s *attribute;
|
||||
struct designator_s *designator;
|
||||
}
|
||||
%code requires { #define qc_yypstate rua_yypstate }
|
||||
|
||||
// these tokens are common between qc and qp
|
||||
%left LOW
|
||||
|
|
|
@ -57,14 +57,13 @@
|
|||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/qfcc.h"
|
||||
#include "tools/qfcc/include/reloc.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/statements.h"
|
||||
#include "tools/qfcc/include/strpool.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
#include "tools/qfcc/include/value.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
const char * const op_type_names[] = {
|
||||
"op_def",
|
||||
"op_value",
|
||||
|
|
|
@ -49,13 +49,12 @@
|
|||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/qfcc.h"
|
||||
#include "tools/qfcc/include/reloc.h"
|
||||
#include "tools/qfcc/include/rua-lang.h"
|
||||
#include "tools/qfcc/include/shared.h"
|
||||
#include "tools/qfcc/include/switch.h"
|
||||
#include "tools/qfcc/include/symtab.h"
|
||||
#include "tools/qfcc/include/type.h"
|
||||
|
||||
#include "tools/qfcc/source/qc-parse.h"
|
||||
|
||||
typedef struct case_node_s {
|
||||
const expr_t *low;
|
||||
const expr_t *high;
|
||||
|
|
Loading…
Reference in a new issue