| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- // Filename: cppBisonDefs.h
- // Created by: drose (17Jan99)
- //
- ////////////////////////////////////////////////////////////////////
- //
- // PANDA 3D SOFTWARE
- // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
- //
- // All use of this software is subject to the terms of the Panda 3d
- // Software license. You should have received a copy of this license
- // along with this source code; you will also find a current copy of
- // the license at http://www.panda3d.org/license.txt .
- //
- // To contact the maintainers of this program write to
- // [email protected] .
- //
- ////////////////////////////////////////////////////////////////////
- #ifndef CPPBISON_H
- #define CPPBISON_H
- // This header file defines the interface to the yacc (actually,
- // bison) parser and grammar. None of these interfaces are intended
- // to be used directly; they're defined here strictly to be used by
- // the CPPParser and CPPExpressionParser classes.
- #include <dtoolbase.h>
- #include <string>
- #include "cppExtensionType.h"
- #include "cppFile.h"
- using namespace std;
- class CPPParser;
- class CPPExpression;
- class CPPPreprocessor;
- class CPPDeclaration;
- class CPPInstance;
- class CPPType;
- class CPPStructType;
- class CPPEnumType;
- class CPPSimpleType;
- class CPPInstanceIdentifier;
- class CPPParameterList;
- class CPPTemplateParameterList;
- class CPPScope;
- class CPPIdentifier;
- void parse_cpp(CPPParser *cp);
- CPPExpression *parse_const_expr(CPPPreprocessor *pp,
- CPPScope *new_current_scope,
- CPPScope *new_global_scope);
- CPPType *parse_type(CPPPreprocessor *pp,
- CPPScope *new_current_scope,
- CPPScope *new_global_scope);
- extern CPPScope *current_scope;
- extern CPPScope *global_scope;
- extern CPPPreprocessor *current_lexer;
- // This structure holds the return value for each token.
- // Traditionally, this is a union, and is declared with the %union
- // declaration in the parser.y file, but unions are pretty worthless
- // in C++ (you can't include an object that has member functions in a
- // union), so we'll use a class instead. That means we need to
- // declare it externally, here.
- class yystype {
- public:
- string str;
- union {
- int integer;
- double real;
- CPPScope *scope;
- CPPDeclaration *decl;
- CPPInstance *instance;
- CPPType *type;
- CPPStructType *struct_type;
- CPPEnumType *enum_type;
- CPPSimpleType *simple_type;
- CPPInstanceIdentifier *inst_ident;
- CPPParameterList *param_list;
- CPPTemplateParameterList *template_param_list;
- CPPExtensionType::Type extension_enum;
- CPPExpression *expr;
- CPPIdentifier *identifier;
- } u;
- };
- #define YYSTYPE yystype
- // This structure takes advantage of a bison feature to track the
- // exact location in the file of each token, for more useful error
- // reporting. We define it up here so we can reference it in the
- // lexer.
- struct cppyyltype {
- int first_line;
- int first_column;
- int last_line;
- int last_column;
- CPPFile file;
- };
- #define YYLTYPE cppyyltype
- // Beginning around bison 1.35 or so, we need to define this macro as
- // well, to tell bison how to collect multiple locations together.
- #define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current = Rhs[1]; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
- #endif
|