Merge pull request #1255 from marauder2k9-torque/torquescript-generateCompiler

TorqueScript Generate compiler
This commit is contained in:
Brian Roberts 2024-04-27 00:44:35 -05:00 committed by GitHub
commit 4e88c4c050
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 31047 additions and 11643 deletions

View file

@ -0,0 +1,170 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
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 3 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, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_CMD_CMDGRAM_H_INCLUDED
# define YY_CMD_CMDGRAM_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int CMDdebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
rwDEFINE = 258, /* rwDEFINE */
rwENDDEF = 259, /* rwENDDEF */
rwDECLARE = 260, /* rwDECLARE */
rwDECLARESINGLETON = 261, /* rwDECLARESINGLETON */
rwBREAK = 262, /* rwBREAK */
rwELSE = 263, /* rwELSE */
rwCONTINUE = 264, /* rwCONTINUE */
rwGLOBAL = 265, /* rwGLOBAL */
rwIF = 266, /* rwIF */
rwNIL = 267, /* rwNIL */
rwRETURN = 268, /* rwRETURN */
rwWHILE = 269, /* rwWHILE */
rwDO = 270, /* rwDO */
rwENDIF = 271, /* rwENDIF */
rwENDWHILE = 272, /* rwENDWHILE */
rwENDFOR = 273, /* rwENDFOR */
rwDEFAULT = 274, /* rwDEFAULT */
rwFOR = 275, /* rwFOR */
rwFOREACH = 276, /* rwFOREACH */
rwFOREACHSTR = 277, /* rwFOREACHSTR */
rwIN = 278, /* rwIN */
rwDATABLOCK = 279, /* rwDATABLOCK */
rwSWITCH = 280, /* rwSWITCH */
rwCASE = 281, /* rwCASE */
rwSWITCHSTR = 282, /* rwSWITCHSTR */
rwCASEOR = 283, /* rwCASEOR */
rwPACKAGE = 284, /* rwPACKAGE */
rwNAMESPACE = 285, /* rwNAMESPACE */
rwCLASS = 286, /* rwCLASS */
rwASSERT = 287, /* rwASSERT */
ILLEGAL_TOKEN = 288, /* ILLEGAL_TOKEN */
CHRCONST = 289, /* CHRCONST */
INTCONST = 290, /* INTCONST */
TTAG = 291, /* TTAG */
VAR = 292, /* VAR */
IDENT = 293, /* IDENT */
TYPEIDENT = 294, /* TYPEIDENT */
DOCBLOCK = 295, /* DOCBLOCK */
STRATOM = 296, /* STRATOM */
TAGATOM = 297, /* TAGATOM */
FLTCONST = 298, /* FLTCONST */
opINTNAME = 299, /* opINTNAME */
opINTNAMER = 300, /* opINTNAMER */
opMINUSMINUS = 301, /* opMINUSMINUS */
opPLUSPLUS = 302, /* opPLUSPLUS */
STMT_SEP = 303, /* STMT_SEP */
opSHL = 304, /* opSHL */
opSHR = 305, /* opSHR */
opPLASN = 306, /* opPLASN */
opMIASN = 307, /* opMIASN */
opMLASN = 308, /* opMLASN */
opDVASN = 309, /* opDVASN */
opMODASN = 310, /* opMODASN */
opANDASN = 311, /* opANDASN */
opXORASN = 312, /* opXORASN */
opORASN = 313, /* opORASN */
opSLASN = 314, /* opSLASN */
opSRASN = 315, /* opSRASN */
opCAT = 316, /* opCAT */
opEQ = 317, /* opEQ */
opNE = 318, /* opNE */
opGE = 319, /* opGE */
opLE = 320, /* opLE */
opAND = 321, /* opAND */
opOR = 322, /* opOR */
opSTREQ = 323, /* opSTREQ */
opCOLONCOLON = 324, /* opCOLONCOLON */
opMDASN = 325, /* opMDASN */
opNDASN = 326, /* opNDASN */
opNTASN = 327, /* opNTASN */
opSTRNE = 328, /* opSTRNE */
UNARY = 329 /* UNARY */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 82 "CMDgram.y"
Token< char > c;
Token< int > i;
Token< const char* > s;
Token< char* > str;
Token< double > f;
StmtNode* stmt;
ExprNode* expr;
SlotAssignNode* slist;
VarNode* var;
SlotDecl slot;
InternalSlotDecl intslot;
ObjectBlockDecl odcl;
ObjectDeclNode* od;
AssignDecl asn;
IfStmtNode* ifnode;
#line 156 "CMDgram.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE CMDlval;
int CMDparse (void);
#endif /* !YY_CMD_CMDGRAM_H_INCLUDED */

View file

@ -8,7 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "console/console.h"
#include "console/compiler.h"
#include "console/torquescript/compiler.h"
#include "console/consoleInternal.h"
#include "core/strings/stringFunctions.h"
@ -166,7 +166,7 @@ decl_list
:
{ $$ = nil; }
| decl_list decl
{ if(!gStatementList) { gStatementList = $2; } else { gStatementList->append($2); } }
{ if(!Script::gStatementList) { Script::gStatementList = $2; } else { Script::gStatementList->append($2); } }
;
decl

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
#include "platform/platform.h"
#include "core/stringTable.h"
#include "console/console.h"
#include "console/compiler.h"
#include "console/torquescript/compiler.h"
#include "console/dynamicTypes.h"
#include "core/strings/stringFunctions.h"
@ -30,7 +30,7 @@ inline Token< T > MakeToken( T value, U32 lineNumber )
return result;
}
#include "console/cmdgram.h"
#include "console/torquescript/CMDgram.h"
// HACK: C++17 and beyond can't use register keyword
#define register

View file

@ -35,7 +35,7 @@ struct Token
T value;
S32 lineNumber;
};
#include "cmdgram.h"
#include "CMDgram.h"
namespace Compiler
{

View file

@ -1,6 +1,6 @@
echo Changing to %4 ...
cd %4
echo Generating %2 and %3 with prefix %1.
..\..\bin\bison\bison.exe -o %2 %3 --defines -p %1
..\..\..\bin\bison-flex\win_bison.exe -o %2 %3 --defines -p %1 -H
echo Renaming %2 to %5 .
move /Y %2 %5

File diff suppressed because it is too large Load diff

View file

@ -1,97 +0,0 @@
#ifndef _CMDGRAM_H_
#define _CMDGRAM_H_
typedef union {
Token< char > c;
Token< int > i;
Token< const char* > s;
Token< char* > str;
Token< double > f;
StmtNode* stmt;
ExprNode* expr;
SlotAssignNode* slist;
VarNode* var;
SlotDecl slot;
InternalSlotDecl intslot;
ObjectBlockDecl odcl;
ObjectDeclNode* od;
AssignDecl asn;
IfStmtNode* ifnode;
} YYSTYPE;
#define rwDEFINE 258
#define rwENDDEF 259
#define rwDECLARE 260
#define rwDECLARESINGLETON 261
#define rwBREAK 262
#define rwELSE 263
#define rwCONTINUE 264
#define rwGLOBAL 265
#define rwIF 266
#define rwNIL 267
#define rwRETURN 268
#define rwWHILE 269
#define rwDO 270
#define rwENDIF 271
#define rwENDWHILE 272
#define rwENDFOR 273
#define rwDEFAULT 274
#define rwFOR 275
#define rwFOREACH 276
#define rwFOREACHSTR 277
#define rwIN 278
#define rwDATABLOCK 279
#define rwSWITCH 280
#define rwCASE 281
#define rwSWITCHSTR 282
#define rwCASEOR 283
#define rwPACKAGE 284
#define rwNAMESPACE 285
#define rwCLASS 286
#define rwASSERT 287
#define ILLEGAL_TOKEN 288
#define CHRCONST 289
#define INTCONST 290
#define TTAG 291
#define VAR 292
#define IDENT 293
#define TYPEIDENT 294
#define DOCBLOCK 295
#define STRATOM 296
#define TAGATOM 297
#define FLTCONST 298
#define opINTNAME 299
#define opINTNAMER 300
#define opMINUSMINUS 301
#define opPLUSPLUS 302
#define STMT_SEP 303
#define opSHL 304
#define opSHR 305
#define opPLASN 306
#define opMIASN 307
#define opMLASN 308
#define opDVASN 309
#define opMODASN 310
#define opANDASN 311
#define opXORASN 312
#define opORASN 313
#define opSLASN 314
#define opSRASN 315
#define opCAT 316
#define opEQ 317
#define opNE 318
#define opGE 319
#define opLE 320
#define opAND 321
#define opOR 322
#define opSTREQ 323
#define opCOLONCOLON 324
#define opMDASN 325
#define opNDASN 326
#define opNTASN 327
#define opSTRNE 328
#define UNARY 329
extern YYSTYPE CMDlval;
#endif

View file

@ -0,0 +1,3 @@
call bison.bat CMD CMDgram.c CMDgram.y . CMDgram.cpp
..\..\..\bin\bison-flex\win_flex -PCMD -oCMDscan.cpp CMDscan.l