mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Moved script stuff to their matching directory
This commit is contained in:
parent
16d9a6f8b0
commit
cf18c3a96f
21 changed files with 475 additions and 540 deletions
269
code/parser/bison_source.txt
Normal file
269
code/parser/bison_source.txt
Normal file
|
@ -0,0 +1,269 @@
|
|||
%{
|
||||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2015 the OpenMoHAA team
|
||||
*
|
||||
* This file is part of OpenMoHAA source code.
|
||||
*
|
||||
* OpenMoHAA source code 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.
|
||||
*
|
||||
* OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* ===========================================================================
|
||||
*
|
||||
*
|
||||
* yyParser.*: BISON Parser for MoHScript.
|
||||
*/
|
||||
|
||||
#include "scriptcompiler.h"
|
||||
#include "yyParser.h"
|
||||
#include "yyLexer.h"
|
||||
|
||||
int yyerror( const char *msg );
|
||||
|
||||
extern int prev_yylex;
|
||||
|
||||
extern yyparsedata parsedata;
|
||||
|
||||
#define YYLLOC node_pos( parsedata.pos - yyleng )
|
||||
|
||||
%}
|
||||
|
||||
%output "../../../code/globalcpp/parser/yyParser.cpp"
|
||||
%defines "../../../code/globalcpp/parser/yyParser.h"
|
||||
|
||||
%error-verbose
|
||||
|
||||
%expect 306
|
||||
|
||||
%token END 0
|
||||
%token TOKEN_EOL
|
||||
|
||||
%left TOKEN_COMMA
|
||||
|
||||
%union {
|
||||
stype_t s;
|
||||
}
|
||||
|
||||
%right TOKEN_ASSIGNMENT
|
||||
TOKEN_PLUS_EQUALS TOKEN_MINUS_EQUALS TOKEN_MULTIPLY_EQUALS TOKEN_DIVIDE_EQUALS TOKEN_MODULUS_EQUALS
|
||||
TOKEN_AND_EQUALS TOKEN_EXCL_OR_EQUALS TOKEN_OR_EQUALS
|
||||
TOKEN_SHIFT_LEFT_EQUALS TOKEN_SHIFT_RIGHT_EQUALS
|
||||
TOKEN_TERNARY
|
||||
|
||||
%left TOKEN_LOGICAL_OR
|
||||
%left TOKEN_LOGICAL_AND
|
||||
|
||||
%left TOKEN_BITWISE_OR
|
||||
%left TOKEN_BITWISE_EXCL_OR
|
||||
%left TOKEN_BITWISE_AND
|
||||
|
||||
%left TOKEN_EQUALITY TOKEN_INEQUALITY
|
||||
%left TOKEN_LESS_THAN TOKEN_LESS_THAN_OR_EQUAL TOKEN_GREATER_THAN TOKEN_GREATER_THAN_OR_EQUAL
|
||||
|
||||
%left TOKEN_SHIFT_LEFT TOKEN_SHIFT_RIGHT
|
||||
%left TOKEN_PLUS TOKEN_MINUS
|
||||
%left TOKEN_MULTIPLY TOKEN_DIVIDE TOKEN_MODULUS
|
||||
|
||||
%token <s> TOKEN_LISTENER
|
||||
|
||||
%right TOKEN_NEG TOKEN_NOT TOKEN_COMPLEMENT
|
||||
|
||||
%token <s> TOKEN_FLOAT TOKEN_INTEGER TOKEN_IDENTIFIER TOKEN_STRING TOKEN_NIL TOKEN_NULL
|
||||
|
||||
%token TOKEN_LBRACKET TOKEN_RBRACKET
|
||||
|
||||
%token TOKEN_COLON TOKEN_SEMICOLON TOKEN_DOLLAR TOKEN_DOUBLE_COLON TOKEN_NUMBER
|
||||
|
||||
%left <s> TOKEN_LSQUARE TOKEN_RSQUARE TOKEN_LPAREN TOKEN_RPAREN TOKEN_INCREMENT TOKEN_DECREMENT TOKEN_PERIOD
|
||||
|
||||
%token TOKEN_MAKEARRAY TOKEN_ENDARRAY
|
||||
TOKEN_CATCH TOKEN_TRY
|
||||
TOKEN_DO TOKEN_FOR TOKEN_IF TOKEN_ELSE TOKEN_SWITCH TOKEN_WHILE
|
||||
TOKEN_BREAK TOKEN_CASE TOKEN_CONTINUE
|
||||
TOKEN_SIZE
|
||||
TOKEN_END TOKEN_RETURN
|
||||
|
||||
%type <s.val> event_parameter_list event_parameter_list_need
|
||||
%type <s.val> statement_list statement makearray_statement_list makearray_statement
|
||||
%type <s.val> compound_statement
|
||||
%type <s.val> expr
|
||||
%type <s.val> func_prim_expr
|
||||
%type <s.val> prim_expr
|
||||
%type <s.val> nonident_prim_expr
|
||||
%type <s.val> number
|
||||
%type <s> identifier_prim
|
||||
|
||||
%start program
|
||||
|
||||
%%
|
||||
|
||||
program:
|
||||
newline statement_list { parsedata.val = node1( sval_statement_list, $2 ); }
|
||||
;
|
||||
|
||||
statement_list:
|
||||
statement_list statement newline { $$ = append_node( $1, $2 ); }
|
||||
//| statement_list error TOKEN_EOL { yyerrok; }
|
||||
| statement newline { $$ = linked_list_end( $1 ); }
|
||||
| newline { $$ = node0( sval_none ); }
|
||||
;
|
||||
|
||||
statement:
|
||||
TOKEN_IDENTIFIER event_parameter_list TOKEN_COLON { $$ = node3( sval_label, $1.val, $2, YYLLOC ); }
|
||||
| TOKEN_PLUS TOKEN_IDENTIFIER event_parameter_list TOKEN_COLON { $$ = node3( sval_label, $2.val, $3, YYLLOC ); }
|
||||
| TOKEN_MINUS TOKEN_IDENTIFIER event_parameter_list TOKEN_COLON { $$ = node3( sval_privatelabel, $2.val, $3, YYLLOC ); }
|
||||
| TOKEN_CASE prim_expr event_parameter_list TOKEN_COLON { $$ = node3( sval_case, $2, $3, YYLLOC ); }
|
||||
| compound_statement
|
||||
| TOKEN_IF prim_expr newline statement[S] newline { $$ = node3( sval_if, $2, $S, YYLLOC ); }
|
||||
| TOKEN_IF prim_expr newline statement[S1] newline TOKEN_ELSE newline statement[S2] { $$ = node4( sval_ifelse, $2, $S1, $S2, YYLLOC ); }
|
||||
| TOKEN_WHILE prim_expr newline statement { $$ = node4( sval_while, $2, $4, node0( sval_none ), YYLLOC ); }
|
||||
| TOKEN_FOR TOKEN_LPAREN statement[SINIT] TOKEN_SEMICOLON expr[E] TOKEN_SEMICOLON statement_list[INC] TOKEN_RPAREN newline statement[S]
|
||||
{
|
||||
sval_u while_stmt = node4( sval_while, $E, $S, node1( sval_statement_list, $INC ), YYLLOC );
|
||||
$$ = node1( sval_statement_list, append_node( linked_list_end( $SINIT ), while_stmt ) );
|
||||
}
|
||||
| TOKEN_FOR TOKEN_LPAREN TOKEN_SEMICOLON expr[E] TOKEN_SEMICOLON statement_list[INC] TOKEN_RPAREN newline statement[S]
|
||||
{
|
||||
$$ = node4( sval_while, $E, $S, node1( sval_statement_list, $INC ), YYLLOC );
|
||||
}
|
||||
| TOKEN_DO newline statement[S] newline TOKEN_WHILE prim_expr[E] { $$ = node3( sval_do, $S, $E, YYLLOC ); }
|
||||
| TOKEN_TRY newline compound_statement newline TOKEN_CATCH newline compound_statement { $$ = node3( sval_catch, $3, $7, YYLLOC ); }
|
||||
| TOKEN_SWITCH prim_expr newline compound_statement { $$ = node3( sval_switch, $2, $4, YYLLOC ); }
|
||||
| TOKEN_BREAK { $$ = node1( sval_break, YYLLOC ); }
|
||||
| TOKEN_CONTINUE { $$ = node1( sval_continue, YYLLOC ); }
|
||||
| TOKEN_IDENTIFIER event_parameter_list { $$ = node3( sval_cmd, $1.val, node1( sval_none, $2 ), node_pos( $1.sourcePos ) ); }
|
||||
//| TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node3( sval_cmd, node_string( parsetree_string( str( $1.stringValue ) + "::" + $3.stringValue ) ), node1( sval_none, $4 ), $1.sourcePos ); }
|
||||
| nonident_prim_expr TOKEN_IDENTIFIER event_parameter_list { $$ = node4( sval_cmd_method, $1, $2.val, node1( sval_none, $3 ), node_pos( $2.sourcePos ) ); }
|
||||
//| nonident_prim_expr TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node4( sval_cmd_method, $1, node_string( parsetree_string( str( $2.stringValue ) + "::" + $4.stringValue ) ), node1( sval_none, $5 ), $2.sourcePos ); }
|
||||
| nonident_prim_expr TOKEN_ASSIGNMENT expr { $$ = node3( sval_assignment, $1, $3, YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_PLUS_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_PLUS ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_MINUS_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_MINUS ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_MULTIPLY_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_MULTIPLY ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_DIVIDE_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_DIVIDE ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_MODULUS_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_PERCENTAGE ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_AND_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_BITWISE_AND ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_EXCL_OR_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_BITWISE_EXCL_OR ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_OR_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_BITWISE_OR ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_SHIFT_LEFT_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_SHIFT_LEFT ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_SHIFT_RIGHT_EQUALS expr { $$ = node3( sval_assignment, $1, node4( sval_operation, node1b( OP_BIN_SHIFT_RIGHT ), $1, $3, YYLLOC ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_INCREMENT { $$ = node3( sval_assignment, $1, node2( sval_func1, node1b( OP_UN_INC ), $1 ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_DECREMENT { $$ = node3( sval_assignment, $1, node2( sval_func1, node1b( OP_UN_DEC ), $1 ), YYLLOC ); }
|
||||
| statement TOKEN_SEMICOLON
|
||||
;
|
||||
|
||||
compound_statement:
|
||||
TOKEN_LBRACKET newline statement_list newline TOKEN_RBRACKET { $$ = node1( sval_statement_list, $3 ); }
|
||||
;
|
||||
|
||||
expr:
|
||||
expr TOKEN_LOGICAL_AND newline expr { $$ = node3( sval_and, $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_LOGICAL_OR newline expr { $$ = node3( sval_or, $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_BITWISE_AND newline expr { $$ = node4( sval_operation, node1b( OP_BIN_BITWISE_AND ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_BITWISE_EXCL_OR newline expr { $$ = node4( sval_operation, node1b( OP_BIN_BITWISE_EXCL_OR ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_BITWISE_OR newline expr { $$ = node4( sval_operation, node1b( OP_BIN_BITWISE_OR ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_EQUALITY newline expr { $$ = node4( sval_operation, node1b( OP_BIN_EQUALITY ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_INEQUALITY newline expr { $$ = node4( sval_operation, node1b( OP_BIN_INEQUALITY ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_LESS_THAN newline expr { $$ = node4( sval_operation, node1b( OP_BIN_LESS_THAN ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_GREATER_THAN newline expr { $$ = node4( sval_operation, node1b( OP_BIN_GREATER_THAN ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_LESS_THAN_OR_EQUAL newline expr { $$ = node4( sval_operation, node1b( OP_BIN_LESS_THAN_OR_EQUAL ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_GREATER_THAN_OR_EQUAL newline expr { $$ = node4( sval_operation, node1b( OP_BIN_GREATER_THAN_OR_EQUAL ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_PLUS newline expr { $$ = node4( sval_operation, node1b( OP_BIN_PLUS ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_MINUS newline expr { $$ = node4( sval_operation, node1b( OP_BIN_MINUS ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_MULTIPLY newline expr { $$ = node4( sval_operation, node1b( OP_BIN_MULTIPLY ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_DIVIDE newline expr { $$ = node4( sval_operation, node1b( OP_BIN_DIVIDE ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_MODULUS newline expr { $$ = node4( sval_operation, node1b( OP_BIN_PERCENTAGE ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_SHIFT_LEFT newline expr { $$ = node4( sval_operation, node1b( OP_BIN_SHIFT_LEFT ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_SHIFT_RIGHT newline expr { $$ = node4( sval_operation, node1b( OP_BIN_SHIFT_RIGHT ), $1, $4, YYLLOC ); }
|
||||
| expr TOKEN_TERNARY expr TOKEN_COLON expr { $$ = node4( sval_ifelse, $1, $3, $5, YYLLOC ); }
|
||||
| nonident_prim_expr
|
||||
| func_prim_expr
|
||||
| identifier_prim { $$ = node1( sval_store_string, $1.val ); }
|
||||
;
|
||||
|
||||
func_prim_expr:
|
||||
TOKEN_IDENTIFIER event_parameter_list_need { $$ = node3( sval_cmd_default_ret, $1.val, node1( sval_none, $2 ), node_pos( $1.sourcePos ) ); }
|
||||
//| TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list_need { $$ = node3( sval_cmd_default_ret, node_string( parsetree_string( str( $1.val.stringValue ) + "::" + $3.val.stringValue ) ), node1( sval_none, $4 ), $1.sourcePos ); }
|
||||
| nonident_prim_expr TOKEN_IDENTIFIER event_parameter_list { $$ = node4( sval_cmd_method_ret, $1, $2.val, node1( sval_none, $3 ), node_pos( $2.sourcePos ) ); }
|
||||
//| nonident_prim_expr TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node4( sval_cmd_method_ret, $1, node_string( parsetree_string( str( $2.val.stringValue ) + "::" + $4.val.stringValue ) ), node1( sval_none, $5 ), $2.sourcePos ); }
|
||||
| TOKEN_NEG func_prim_expr { $$ = node3( sval_func1, node1b( OP_UN_MINUS ), $2, YYLLOC ); }
|
||||
| TOKEN_COMPLEMENT func_prim_expr { $$ = node3( sval_func1, node1b( OP_UN_COMPLEMENT ), $2, YYLLOC ); }
|
||||
| TOKEN_NOT func_prim_expr { $$ = node2( sval_not, $2, YYLLOC ); }
|
||||
| TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON prim_expr { $$ = node3( sval_constarray, node2( sval_store_string, $1.val, node_pos( $1.sourcePos ) ), $3, YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_DOUBLE_COLON prim_expr { $$ = node3( sval_constarray, $1, $3, YYLLOC ); }
|
||||
| TOKEN_MAKEARRAY newline makearray_statement_list newline TOKEN_ENDARRAY { $$ = node1( sval_makearray, $3 ); }
|
||||
;
|
||||
|
||||
event_parameter_list:
|
||||
{ $$ = node0( sval_none ); }
|
||||
| event_parameter_list prim_expr { $$ = append_node( $1, $2 ); }
|
||||
| prim_expr { $$ = linked_list_end( $1 ); }
|
||||
;
|
||||
|
||||
event_parameter_list_need:
|
||||
event_parameter_list_need prim_expr { $$ = append_node( $1, $2 ); }
|
||||
| prim_expr { $$ = linked_list_end( $1 ); }
|
||||
;
|
||||
|
||||
prim_expr:
|
||||
nonident_prim_expr
|
||||
| identifier_prim { $$ = node1( sval_store_string, $1.val ); }
|
||||
| prim_expr TOKEN_DOUBLE_COLON prim_expr { $$ = node3( sval_constarray, $1, $3, YYLLOC ); }
|
||||
;
|
||||
|
||||
nonident_prim_expr:
|
||||
TOKEN_DOLLAR TOKEN_LPAREN expr TOKEN_RPAREN { $$ = node3( sval_func1, node1b( OP_UN_TARGETNAME ), $3, YYLLOC ); }
|
||||
| TOKEN_DOLLAR TOKEN_IDENTIFIER { $$ = node3( sval_func1, node1b( OP_UN_TARGETNAME ), node1( sval_store_string, $2.val ), YYLLOC ); }
|
||||
| TOKEN_DOLLAR TOKEN_STRING { $$ = node3( sval_func1, node1b( OP_UN_TARGETNAME ), node1( sval_store_string, $2.val ), YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_PERIOD TOKEN_IDENTIFIER { $$ = node3( sval_field, $1, $3.val, node_pos( $3.sourcePos ) ); }
|
||||
| nonident_prim_expr TOKEN_PERIOD TOKEN_STRING { $$ = node3( sval_field, $1, $3.val, node_pos( $3.sourcePos ) ); }
|
||||
| nonident_prim_expr TOKEN_PERIOD TOKEN_SIZE { $$ = node3( sval_func1, node1b( OP_UN_SIZE ), $1, YYLLOC ); }
|
||||
| nonident_prim_expr TOKEN_LSQUARE expr TOKEN_RSQUARE { $$ = node3( sval_array, $1, $3, $1 ); }
|
||||
| TOKEN_STRING { $$ = node1( sval_store_string, $1.val ); }
|
||||
| number
|
||||
| TOKEN_LPAREN expr expr expr TOKEN_RPAREN { $$ = node4( sval_calc_vector, $2, $3, $4, YYLLOC ); }
|
||||
| TOKEN_LISTENER { $$ = node2( sval_store_method, $1.val, YYLLOC ); }
|
||||
| TOKEN_LPAREN expr TOKEN_RPAREN { $$ = $2; }
|
||||
| TOKEN_LPAREN TOKEN_RPAREN { $$ = node0( sval_none ); }
|
||||
| TOKEN_NEG nonident_prim_expr { $$ = node3( sval_func1, node1b( OP_UN_MINUS ), $2, YYLLOC ); }
|
||||
| TOKEN_COMPLEMENT nonident_prim_expr { $$ = node3( sval_func1, node1b( OP_UN_COMPLEMENT ), $2, YYLLOC ); }
|
||||
| TOKEN_NOT nonident_prim_expr { $$ = node2( sval_not, $2, YYLLOC ); }
|
||||
| TOKEN_NULL { $$ = node1( sval_store_null, YYLLOC ); }
|
||||
| TOKEN_NIL { $$ = node1( sval_store_nil, YYLLOC ); }
|
||||
;
|
||||
|
||||
number:
|
||||
TOKEN_FLOAT { $$ = node1( sval_store_float, $1.val ); }
|
||||
| TOKEN_INTEGER { $$ = node1( sval_store_integer, $1.val ); }
|
||||
;
|
||||
|
||||
identifier_prim:
|
||||
TOKEN_IDENTIFIER
|
||||
;
|
||||
|
||||
makearray_statement_list:
|
||||
{ $$ = node0( sval_none ); }
|
||||
| makearray_statement_list makearray_statement newline { $$ = append_node( $1, node1( sval_makearray, $2 ) ); }
|
||||
| makearray_statement newline { $$ = linked_list_end( node1( sval_makearray, $1 ) ); }
|
||||
;
|
||||
|
||||
makearray_statement:
|
||||
prim_expr { $$ = linked_list_end( $1 ); }
|
||||
| makearray_statement prim_expr { $$ = append_node( $1, $2 ); }
|
||||
;
|
||||
|
||||
newline:
|
||||
{}
|
||||
| TOKEN_EOL
|
||||
;
|
||||
|
||||
%%
|
285
code/parser/lex_source.txt
Normal file
285
code/parser/lex_source.txt
Normal file
|
@ -0,0 +1,285 @@
|
|||
%{
|
||||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2015 the OpenMoHAA team
|
||||
*
|
||||
* This file is part of OpenMoHAA source code.
|
||||
*
|
||||
* OpenMoHAA source code 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.
|
||||
*
|
||||
* OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* ===========================================================================
|
||||
*
|
||||
*
|
||||
* yyLexer.*: FLEX Lexical grammar for MoHScript.
|
||||
*/
|
||||
|
||||
#include "scriptcompiler.h"
|
||||
#include "yyParser.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void fprintf2( FILE *f, const char *format, ... )
|
||||
{
|
||||
va_list va;
|
||||
static char buffer[ 4200 ];
|
||||
|
||||
va_start( va, format );
|
||||
vsprintf( buffer, format, va );
|
||||
va_end( va );
|
||||
|
||||
glbs.Printf( buffer );
|
||||
}
|
||||
|
||||
#define fprintf fprintf2
|
||||
|
||||
int prev_yylex = 0;
|
||||
|
||||
extern yyparsedata parsedata;
|
||||
|
||||
#define YYLLOCSET { yylval.s.sourcePos = parsedata.pos - yyleng; }
|
||||
#define YYLEX(n) { prev_yylex = n; return n; }
|
||||
|
||||
#define YY_USER_ACTION parsedata.pos; parsedata.pos += yyleng;
|
||||
#define YY_FATAL_ERROR( n ) yylexerror( n )
|
||||
|
||||
void yylexerror( const char *msg )
|
||||
{
|
||||
glbs.Printf( "%s\n%s", msg, yytext );
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void TextEscapeValue( char *str, size_t len )
|
||||
{
|
||||
char *to = parsetree_malloc( len + 1 );
|
||||
|
||||
yylval.s.val.stringValue = to;
|
||||
|
||||
while( len )
|
||||
{
|
||||
if( *str == '\\' )
|
||||
{
|
||||
len--;
|
||||
|
||||
if( !len )
|
||||
break;
|
||||
|
||||
str++;
|
||||
if( *str == 'n' )
|
||||
{
|
||||
*to = '\n';
|
||||
}
|
||||
else if( *str == 't' )
|
||||
{
|
||||
*to = '\t';
|
||||
}
|
||||
else if( *str == '"' )
|
||||
{
|
||||
*to = '\"';
|
||||
}
|
||||
else
|
||||
{
|
||||
*to = *str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*to = *str;
|
||||
}
|
||||
|
||||
len--;
|
||||
str++;
|
||||
to++;
|
||||
}
|
||||
|
||||
*to = 0;
|
||||
}
|
||||
|
||||
|
||||
static void TextValue( char *str, size_t len )
|
||||
{
|
||||
yylval.s.val.stringValue = parsetree_malloc( len + 1 );
|
||||
strncpy( yylval.s.val.stringValue, str, len );
|
||||
yylval.s.val.stringValue[ len ] = 0;
|
||||
}
|
||||
|
||||
static bool UseField( void )
|
||||
{
|
||||
//return prev_yylex == TOKEN_PERIOD || prev_yylex == TOKEN_DOLLAR;
|
||||
return ( !strncmp( yytext, "game.", 5 ) ||
|
||||
!strncmp( yytext, "group.", 6 ) ||
|
||||
!strncmp( yytext, "level.", 6 ) ||
|
||||
!strncmp( yytext, "local.", 6 ) ||
|
||||
!strncmp( yytext, "parm.", 5 ) ||
|
||||
!strncmp( yytext, "owner.", 6 ) ||
|
||||
!strncmp( yytext, "self.", 5 ) ||
|
||||
*yytext == '$' || *yytext == '-' || *yytext == '/' );
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/*%option debug*/
|
||||
|
||||
%option outfile="../../../code/globalcpp/parser/yyLexer.cpp" header-file="../../../code/globalcpp/parser/yyLexer.h"
|
||||
%option warn nodefault
|
||||
|
||||
%option noyywrap never-interactive
|
||||
%option yylineno
|
||||
|
||||
%x C_COMMENT
|
||||
%x C_LINE_COMMENT
|
||||
%x VARIABLES
|
||||
%x IDENTIFIER
|
||||
|
||||
%%
|
||||
|
||||
"/*" { BEGIN( C_COMMENT ); }
|
||||
<C_COMMENT>"*/" { BEGIN( INITIAL ); }
|
||||
<C_COMMENT>\n { ; }
|
||||
<C_COMMENT>. { ; }
|
||||
"*/" { Compiler.CompileError( parsedata.pos - yyleng, "'*/' found outside of comment" ); }
|
||||
|
||||
|
||||
\\[\r\n]+ { ; }
|
||||
"//"[^\r\n]* { if( prev_yylex != TOKEN_EOL ) YYLEX( TOKEN_EOL ); }
|
||||
|
||||
<VARIABLES>[\r\n]* { BEGIN( INITIAL ); YYLEX( TOKEN_EOL ); }
|
||||
<VARIABLES>"size" { YYLEX( TOKEN_SIZE ); }
|
||||
<VARIABLES>"." { YYLEX( TOKEN_PERIOD ); }
|
||||
<VARIABLES>\"([^\\\"]|\\.)*\" { YYLLOCSET; TextEscapeValue( yytext + 1, strlen( yytext ) - 2 ); YYLEX( TOKEN_STRING ); }
|
||||
<VARIABLES>[a-zA-Z0-9_\"]+ { YYLLOCSET; TextValue( yytext, strlen( yytext ) ); YYLEX( TOKEN_IDENTIFIER ); }
|
||||
<VARIABLES>. {
|
||||
for ( int i = yyleng - 1; i >= 0; --i )
|
||||
unput( yytext[ i ] );
|
||||
|
||||
parsedata.pos -= yyleng;
|
||||
|
||||
BEGIN( INITIAL );
|
||||
}
|
||||
|
||||
[\r\n]* { if( prev_yylex != TOKEN_EOL ) YYLEX( TOKEN_EOL ); }
|
||||
[ \t]* { ; }
|
||||
|
||||
\"([^\\\"]|\\.)*\" { YYLLOCSET; TextEscapeValue( yytext + 1, strlen( yytext ) - 2 ); YYLEX( TOKEN_STRING ); }
|
||||
|
||||
|
||||
"?" { YYLEX( TOKEN_TERNARY ); }
|
||||
"if" { YYLEX( TOKEN_IF ); }
|
||||
"else" { YYLEX( TOKEN_ELSE ); }
|
||||
"while" { YYLEX( TOKEN_WHILE ); }
|
||||
"for" { YYLEX( TOKEN_FOR ); }
|
||||
"do" { YYLEX( TOKEN_DO ); }
|
||||
|
||||
"game"? { BEGIN( VARIABLES ); yylval.s.val = node1_( method_game ); YYLEX( TOKEN_LISTENER ); }
|
||||
"group" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_group ); YYLEX( TOKEN_LISTENER ); }
|
||||
"level" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_level ); YYLEX( TOKEN_LISTENER ); }
|
||||
"local" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_local ); YYLEX( TOKEN_LISTENER ); }
|
||||
"parm" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_parm ); YYLEX( TOKEN_LISTENER ); }
|
||||
"owner" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_owner ); YYLEX( TOKEN_LISTENER ); }
|
||||
"self" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_self ); YYLEX( TOKEN_LISTENER ); }
|
||||
|
||||
"{" { parsedata.braces_count++; YYLEX( TOKEN_LBRACKET ); }
|
||||
"}" { parsedata.braces_count--; YYLEX( TOKEN_RBRACKET ); }
|
||||
"(" { YYLLOCSET; YYLEX( TOKEN_LPAREN ); }
|
||||
")" { BEGIN( VARIABLES ); YYLLOCSET; YYLEX( TOKEN_RPAREN ); }
|
||||
"[" { YYLEX( TOKEN_LSQUARE ); }
|
||||
"]" { BEGIN( VARIABLES ); YYLEX( TOKEN_RSQUARE ); }
|
||||
|
||||
"=" { YYLEX( TOKEN_ASSIGNMENT ); }
|
||||
":" { YYLEX( TOKEN_COLON ); }
|
||||
"::" { YYLEX( TOKEN_DOUBLE_COLON ); }
|
||||
";" { YYLEX( TOKEN_SEMICOLON ); }
|
||||
|
||||
"==" { YYLEX( TOKEN_EQUALITY ); }
|
||||
"||" { YYLEX( TOKEN_LOGICAL_OR ); }
|
||||
"&&" { YYLEX( TOKEN_LOGICAL_AND ); }
|
||||
|
||||
"|" { YYLEX( TOKEN_BITWISE_OR ); }
|
||||
"^" { YYLEX( TOKEN_BITWISE_EXCL_OR ); }
|
||||
"&" { YYLEX( TOKEN_BITWISE_AND ); }
|
||||
"!=" { YYLEX( TOKEN_INEQUALITY ); }
|
||||
"<" { YYLEX( TOKEN_LESS_THAN ); }
|
||||
">" { YYLEX( TOKEN_GREATER_THAN ); }
|
||||
"<=" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); }
|
||||
">=" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); }
|
||||
[ ]"-" { YYLEX( TOKEN_NEG ); }
|
||||
|
||||
"+" { YYLEX( TOKEN_PLUS ); }
|
||||
"+=" { YYLEX( TOKEN_PLUS_EQUALS ); }
|
||||
"++"|[ ]"++" { YYLEX( TOKEN_INCREMENT ); }
|
||||
"-"|"-"[ ]|[ ]"-"[ ] { YYLEX( TOKEN_MINUS ); }
|
||||
"-=" { YYLEX( TOKEN_MINUS_EQUALS ); }
|
||||
[ ]"-=" { YYLEX( TOKEN_MINUS_EQUALS ); }
|
||||
"--"|[ ]"--" { YYLEX( TOKEN_DECREMENT ); }
|
||||
"*" { YYLEX( TOKEN_MULTIPLY ); }
|
||||
"*=" { YYLEX( TOKEN_MULTIPLY_EQUALS ); }
|
||||
"/" { YYLEX( TOKEN_DIVIDE ); }
|
||||
"/=" { YYLEX( TOKEN_DIVIDE_EQUALS ); }
|
||||
"%" { YYLEX( TOKEN_MODULUS ); }
|
||||
"%=" { YYLEX( TOKEN_MODULUS_EQUALS ); }
|
||||
"<<" { YYLEX( TOKEN_SHIFT_LEFT ); }
|
||||
"<<=" { YYLEX( TOKEN_SHIFT_LEFT_EQUALS ); }
|
||||
">>" { YYLEX( TOKEN_SHIFT_RIGHT ); }
|
||||
">>=" { YYLEX( TOKEN_SHIFT_RIGHT_EQUALS ); }
|
||||
"&=" { YYLEX( TOKEN_AND_EQUALS ); }
|
||||
"^=" { YYLEX( TOKEN_EXCL_OR_EQUALS ); }
|
||||
"|=" { YYLEX( TOKEN_OR_EQUALS ); }
|
||||
"$" { BEGIN( VARIABLES ); YYLEX( TOKEN_DOLLAR ); }
|
||||
"!" { YYLEX( TOKEN_NOT ); }
|
||||
"~" { YYLEX( TOKEN_COMPLEMENT ); }
|
||||
|
||||
"." { YYLEX( TOKEN_PERIOD ); }
|
||||
|
||||
"," { YYLEX( TOKEN_COMMA ); }
|
||||
"#" { YYLEX( TOKEN_NUMBER ); }
|
||||
|
||||
"NULL" { YYLEX( TOKEN_NULL ); }
|
||||
"NIL" { YYLEX( TOKEN_NIL ); }
|
||||
|
||||
[0-9]+ { YYLLOCSET; sscanf( yytext, "%d", &yylval.s.val.intValue ); YYLEX( TOKEN_INTEGER ); }
|
||||
[0-9\.]+|[0-9\.]+("e+"|"e-")+[0-9\.] { YYLLOCSET; sscanf( yytext, "%f", &yylval.s.val.floatValue ); YYLEX( TOKEN_FLOAT ); }
|
||||
|
||||
"try" { YYLEX( TOKEN_TRY ); }
|
||||
"catch" { YYLEX( TOKEN_CATCH ); }
|
||||
"switch" { YYLEX( TOKEN_SWITCH ); }
|
||||
|
||||
"case" { YYLEX( TOKEN_CASE ); }
|
||||
"break" { YYLEX( TOKEN_BREAK ); }
|
||||
"continue" { YYLEX( TOKEN_CONTINUE ); }
|
||||
|
||||
"makearray"|"makeArray" { YYLEX( TOKEN_MAKEARRAY ); }
|
||||
"endarray"|"endArray" { YYLEX( TOKEN_ENDARRAY ); }
|
||||
|
||||
[a-zA-Z0-9_\./\\-]+ {
|
||||
if( UseField() )
|
||||
{
|
||||
parsedata.pos -= yyleng;
|
||||
REJECT;
|
||||
}
|
||||
else
|
||||
{
|
||||
YYLLOCSET;
|
||||
TextEscapeValue( yytext, yyleng );
|
||||
YYLEX( TOKEN_IDENTIFIER );
|
||||
}
|
||||
}
|
||||
|
||||
. { yylexerror( "bad token:\n" ); }
|
||||
|
||||
%{
|
||||
|
||||
#undef fprintf
|
||||
|
||||
%}
|
||||
|
||||
%%
|
334
code/parser/parsetree.cpp
Normal file
334
code/parser/parsetree.cpp
Normal file
|
@ -0,0 +1,334 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2008 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code 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.
|
||||
|
||||
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// parsetree.cpp: Abstract Syntax Layer for Lexer/Parser
|
||||
|
||||
#include "glb_local.h"
|
||||
#include "parsetree.h"
|
||||
#include <mem_tempalloc.h>
|
||||
|
||||
MEM_TempAlloc parsetree_allocator;
|
||||
|
||||
yyparsedata parsedata;
|
||||
sval_u node_none = { 0 };
|
||||
|
||||
char *str_replace( char *orig, char *rep, char *with ) {
|
||||
char *result; // the return string
|
||||
char *ins; // the next insert point
|
||||
char *tmp; // varies
|
||||
size_t len_rep; // length of rep
|
||||
size_t len_with; // length of with
|
||||
size_t len_front; // distance between rep and end of last rep
|
||||
int count; // number of replacements
|
||||
|
||||
if( !orig )
|
||||
return NULL;
|
||||
if( !rep )
|
||||
rep = "";
|
||||
len_rep = strlen( rep );
|
||||
if( !with )
|
||||
with = "";
|
||||
len_with = strlen( with );
|
||||
|
||||
ins = orig;
|
||||
for( count = 0; tmp = strstr( ins, rep ); ++count ) {
|
||||
ins = tmp + len_rep;
|
||||
}
|
||||
|
||||
// first time through the loop, all the variable are set correctly
|
||||
// from here on,
|
||||
// tmp points to the end of the result string
|
||||
// ins points to the next occurrence of rep in orig
|
||||
// orig points to the remainder of orig after "end of rep"
|
||||
tmp = result = ( char * )parsetree_allocator.Alloc( strlen( orig ) + ( len_with - len_rep ) * count + 1 );
|
||||
|
||||
if( !result )
|
||||
return NULL;
|
||||
|
||||
while( count-- ) {
|
||||
ins = strstr( orig, rep );
|
||||
len_front = ins - orig;
|
||||
tmp = strncpy( tmp, orig, len_front ) + len_front;
|
||||
tmp = strcpy( tmp, with ) + len_with;
|
||||
orig += len_front + len_rep; // move to next "end of rep"
|
||||
}
|
||||
strcpy( tmp, orig );
|
||||
return result;
|
||||
}
|
||||
|
||||
void parsetree_freeall()
|
||||
{
|
||||
parsetree_allocator.FreeAll();
|
||||
|
||||
if( showopcodes->integer )
|
||||
{
|
||||
glbs.DPrintf( "%d bytes freed\n", parsedata.total_length );
|
||||
}
|
||||
}
|
||||
|
||||
void parsetree_init()
|
||||
{
|
||||
parsedata.total_length = 0;
|
||||
}
|
||||
|
||||
size_t parsetree_length()
|
||||
{
|
||||
return parsedata.total_length;
|
||||
}
|
||||
|
||||
#if 0
|
||||
char *parsetree_string( const char *string )
|
||||
{
|
||||
//char *pszString = ( char * )parsetree_allocator.Alloc( strlen( string ) + 1 );
|
||||
//strcpy( pszString, string );
|
||||
|
||||
char *buffer = str_replace( ( char * )string, "\\\"", "\"" );
|
||||
|
||||
if( buffer )
|
||||
{
|
||||
char *ptr = buffer;
|
||||
|
||||
if( ptr[ 0 ] == '"' )
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
|
||||
int len = strlen( buffer );
|
||||
|
||||
if( buffer[ len - 1 ] == '"' )
|
||||
{
|
||||
buffer[ len - 1 ] = 0;
|
||||
}
|
||||
|
||||
buffer = ptr;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern size_t yyleng;
|
||||
extern size_t prev_yyleng;
|
||||
|
||||
char *parsetree_malloc( size_t s )
|
||||
{
|
||||
parsedata.total_length += s;
|
||||
return ( char * )parsetree_allocator.Alloc( s );
|
||||
}
|
||||
|
||||
sval_u append_lists( sval_u val1, sval_u val2 )
|
||||
{
|
||||
val1.node[ 1 ].node[ 1 ] = val2.node[ 0 ];
|
||||
val1.node[ 1 ] = val2.node[ 1 ];
|
||||
|
||||
return val1;
|
||||
}
|
||||
|
||||
sval_u append_node( sval_u val1, sval_u val2 )
|
||||
{
|
||||
sval_u *node;
|
||||
|
||||
node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 2 );
|
||||
|
||||
node[ 1 ].node = NULL;
|
||||
node[ 0 ] = val2;
|
||||
|
||||
val1.node[ 1 ].node[ 1 ].node = node;
|
||||
val1.node[ 1 ].node = node;
|
||||
|
||||
return val1;
|
||||
}
|
||||
|
||||
sval_u prepend_node( sval_u val1, sval_u val2 )
|
||||
{
|
||||
sval_u *node;
|
||||
|
||||
node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 2 );
|
||||
|
||||
node[ 0 ] = val1;
|
||||
node[ 1 ] = val2;
|
||||
|
||||
val2.node = node;
|
||||
|
||||
return val2;
|
||||
}
|
||||
|
||||
sval_u linked_list_end( sval_u val )
|
||||
{
|
||||
sval_u *node;
|
||||
sval_u end;
|
||||
|
||||
node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 2 );
|
||||
|
||||
node[ 0 ] = val;
|
||||
node[ 1 ].node = NULL;
|
||||
|
||||
end.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 2 );
|
||||
|
||||
end.node[ 0 ].node = node;
|
||||
end.node[ 1 ].node = node;
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
sval_u node1_( int val1 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.intValue = val1;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node1b( int val1 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.byteValue = val1;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node_pos( unsigned int pos )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.sourcePosValue = pos;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node_string( char *text )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.stringValue = text;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node0( int type )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
if( type == sval_none )
|
||||
{
|
||||
// memory optimization
|
||||
val.node = &node_none;
|
||||
}
|
||||
else
|
||||
{
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 1 );
|
||||
|
||||
val.node[ 0 ].node = NULL;
|
||||
val.node[ 0 ].type = type;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node1( int type, sval_u val1 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 2 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node2( int type, sval_u val1, sval_u val2 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 3 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
val.node[ 2 ] = val2;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node3( int type, sval_u val1, sval_u val2, sval_u val3 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 4 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
val.node[ 2 ] = val2;
|
||||
val.node[ 3 ] = val3;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node4( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 5 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
val.node[ 2 ] = val2;
|
||||
val.node[ 3 ] = val3;
|
||||
val.node[ 4 ] = val4;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node5( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 6 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
val.node[ 2 ] = val2;
|
||||
val.node[ 3 ] = val3;
|
||||
val.node[ 4 ] = val4;
|
||||
val.node[ 5 ] = val5;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sval_u node6( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5, sval_u val6 )
|
||||
{
|
||||
sval_u val;
|
||||
|
||||
val.node = ( sval_u * )parsetree_malloc( sizeof( sval_u ) * 7 );
|
||||
|
||||
val.node[ 0 ].type = type;
|
||||
val.node[ 1 ] = val1;
|
||||
val.node[ 2 ] = val2;
|
||||
val.node[ 3 ] = val3;
|
||||
val.node[ 4 ] = val4;
|
||||
val.node[ 5 ] = val5;
|
||||
val.node[ 6 ] = val6;
|
||||
|
||||
return val;
|
||||
}
|
147
code/parser/parsetree.h
Normal file
147
code/parser/parsetree.h
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2008 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code 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.
|
||||
|
||||
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// parsetree.h: Abstract Syntax Layer for Lexer/Parser
|
||||
|
||||
#ifndef __PARSETREE_H__
|
||||
#define __PARSETREE_H__
|
||||
|
||||
#if defined ( GAME_DLL )
|
||||
#define showopcodes g_showopcodes
|
||||
#elif defined( CGAME_DLL )
|
||||
#define showopcodes cg_showopcodes
|
||||
#else
|
||||
#define showopcodes g_showopcodes
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
sval_none,
|
||||
sval_next,
|
||||
sval_statement_list,
|
||||
sval_label,
|
||||
sval_case,
|
||||
sval_negative,
|
||||
sval_assignment,
|
||||
sval_if,
|
||||
sval_ifelse,
|
||||
sval_while,
|
||||
sval_and,
|
||||
sval_or,
|
||||
sval_cmd_method,
|
||||
sval_cmd_method_ret,
|
||||
sval_cmd,
|
||||
sval_cmd_default_ret,
|
||||
sval_field,
|
||||
sval_store_method,
|
||||
sval_store_string,
|
||||
sval_store_integer,
|
||||
sval_store_float,
|
||||
sval_calc_vector,
|
||||
sval_store_null,
|
||||
sval_store_nil,
|
||||
sval_func1,
|
||||
sval_operation,
|
||||
sval_not,
|
||||
sval_array,
|
||||
sval_constarray,
|
||||
sval_makearray,
|
||||
sval_catch,
|
||||
sval_switch,
|
||||
sval_break,
|
||||
sval_continue,
|
||||
sval_do,
|
||||
sval_privatelabel,
|
||||
sval_define
|
||||
} sval_type_e;
|
||||
|
||||
typedef union sval_u {
|
||||
int type;
|
||||
char *stringValue;
|
||||
float floatValue;
|
||||
int intValue;
|
||||
char charValue;
|
||||
unsigned char byteValue;
|
||||
unsigned char *posValue;
|
||||
int MaxVarStackOffset;
|
||||
int HasExternal;
|
||||
union sval_u *node;
|
||||
unsigned int sourcePosValue;
|
||||
} sval_t;
|
||||
|
||||
typedef struct {
|
||||
sval_t val;
|
||||
unsigned int sourcePos;
|
||||
} stype_t;
|
||||
|
||||
void parsetree_freeall();
|
||||
void parsetree_init();
|
||||
size_t parsetree_length();
|
||||
char *parsetree_malloc( size_t s );
|
||||
|
||||
|
||||
sval_u append_lists( sval_u val1, sval_u val2 );
|
||||
sval_u append_node( sval_u val1, sval_u val2 );
|
||||
sval_u prepend_node( sval_u val1, sval_u val2 );
|
||||
|
||||
sval_u linked_list_end( sval_u val );
|
||||
|
||||
sval_u node1_( int val1 );
|
||||
sval_u node1b( int val1 );
|
||||
sval_u node_pos( unsigned int pos );
|
||||
sval_u node_string( char *text );
|
||||
|
||||
sval_u node0( int type );
|
||||
sval_u node1( int type, sval_u val1 );
|
||||
sval_u node2( int type, sval_u val1, sval_u val2 );
|
||||
sval_u node3( int type, sval_u val1, sval_u val2, sval_u val3 );
|
||||
sval_u node4( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4 );
|
||||
sval_u node5( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5 );
|
||||
sval_u node6( int type, sval_u val1, sval_u val2, sval_u val3, sval_u val4, sval_u val5, sval_u val6 );
|
||||
|
||||
struct yyexception {
|
||||
int yylineno;
|
||||
str yytext;
|
||||
str yytoken;
|
||||
|
||||
yyexception() { yylineno = 0; }
|
||||
};
|
||||
|
||||
struct yyparsedata {
|
||||
size_t total_length;
|
||||
|
||||
int braces_count;
|
||||
int line_count;
|
||||
unsigned int pos;
|
||||
sval_t val;
|
||||
|
||||
char *sourceBuffer;
|
||||
class GameScript *gameScript;
|
||||
|
||||
yyexception exc;
|
||||
|
||||
yyparsedata() { total_length = 0, braces_count = 0, line_count = 0, pos = 0; val = sval_t(); sourceBuffer = NULL; gameScript = NULL; }
|
||||
};
|
||||
|
||||
extern yyparsedata parsedata;
|
||||
|
||||
#endif
|
2766
code/parser/yyLexer.cpp
Normal file
2766
code/parser/yyLexer.cpp
Normal file
File diff suppressed because it is too large
Load diff
408
code/parser/yyLexer.h
Normal file
408
code/parser/yyLexer.h
Normal file
|
@ -0,0 +1,408 @@
|
|||
#ifndef yyHEADER_H
|
||||
#define yyHEADER_H 1
|
||||
#define yyIN_HEADER 1
|
||||
|
||||
#line 5 "../../../code/globalcpp/parser/yyLexer.h"
|
||||
|
||||
#line 7 "../../../code/globalcpp/parser/yyLexer.h"
|
||||
|
||||
#define YY_INT_ALIGNED short int
|
||||
|
||||
/* A lexical scanner generated by flex */
|
||||
|
||||
#define FLEX_SCANNER
|
||||
#define YY_FLEX_MAJOR_VERSION 2
|
||||
#define YY_FLEX_MINOR_VERSION 6
|
||||
#define YY_FLEX_SUBMINOR_VERSION 3
|
||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||
#define FLEX_BETA
|
||||
#endif
|
||||
|
||||
#define yy_create_buffer yy_create_buffer
|
||||
|
||||
#define yy_delete_buffer yy_delete_buffer
|
||||
|
||||
#define yy_scan_buffer yy_scan_buffer
|
||||
|
||||
#define yy_scan_string yy_scan_string
|
||||
|
||||
#define yy_scan_bytes yy_scan_bytes
|
||||
|
||||
#define yy_init_buffer yy_init_buffer
|
||||
|
||||
#define yy_flush_buffer yy_flush_buffer
|
||||
|
||||
#define yy_load_buffer_state yy_load_buffer_state
|
||||
|
||||
#define yy_switch_to_buffer yy_switch_to_buffer
|
||||
|
||||
#define yypush_buffer_state yypush_buffer_state
|
||||
|
||||
#define yypop_buffer_state yypop_buffer_state
|
||||
|
||||
#define yyensure_buffer_stack yyensure_buffer_stack
|
||||
|
||||
#define yylex yylex
|
||||
|
||||
#define yyrestart yyrestart
|
||||
|
||||
#define yylex_init yylex_init
|
||||
|
||||
#define yylex_init_extra yylex_init_extra
|
||||
|
||||
#define yylex_destroy yylex_destroy
|
||||
|
||||
#define yyget_debug yyget_debug
|
||||
|
||||
#define yyset_debug yyset_debug
|
||||
|
||||
#define yyget_extra yyget_extra
|
||||
|
||||
#define yyset_extra yyset_extra
|
||||
|
||||
#define yyget_in yyget_in
|
||||
|
||||
#define yyset_in yyset_in
|
||||
|
||||
#define yyget_out yyget_out
|
||||
|
||||
#define yyset_out yyset_out
|
||||
|
||||
#define yyget_leng yyget_leng
|
||||
|
||||
#define yyget_text yyget_text
|
||||
|
||||
#define yyget_lineno yyget_lineno
|
||||
|
||||
#define yyset_lineno yyset_lineno
|
||||
|
||||
#define yywrap yywrap
|
||||
|
||||
#define yyalloc yyalloc
|
||||
|
||||
#define yyrealloc yyrealloc
|
||||
|
||||
#define yyfree yyfree
|
||||
|
||||
#define yytext yytext
|
||||
|
||||
#define yyleng yyleng
|
||||
|
||||
#define yyin yyin
|
||||
|
||||
#define yyout yyout
|
||||
|
||||
#define yy_flex_debug yy_flex_debug
|
||||
|
||||
#define yylineno yylineno
|
||||
|
||||
/* First, we deal with platform-specific or compiler-specific issues. */
|
||||
|
||||
/* begin standard C headers. */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* end standard C headers. */
|
||||
|
||||
/* flex integer type definitions */
|
||||
|
||||
#ifndef FLEXINT_H
|
||||
#define FLEXINT_H
|
||||
|
||||
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
|
||||
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
|
||||
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
|
||||
* if you want the limit (max/min) macros for int types.
|
||||
*/
|
||||
#ifndef __STDC_LIMIT_MACROS
|
||||
#define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
typedef int8_t flex_int8_t;
|
||||
typedef uint8_t flex_uint8_t;
|
||||
typedef int16_t flex_int16_t;
|
||||
typedef uint16_t flex_uint16_t;
|
||||
typedef int32_t flex_int32_t;
|
||||
typedef uint32_t flex_uint32_t;
|
||||
#else
|
||||
typedef signed char flex_int8_t;
|
||||
typedef short int flex_int16_t;
|
||||
typedef int flex_int32_t;
|
||||
typedef unsigned char flex_uint8_t;
|
||||
typedef unsigned short int flex_uint16_t;
|
||||
typedef unsigned int flex_uint32_t;
|
||||
|
||||
/* Limits of integral types. */
|
||||
#ifndef INT8_MIN
|
||||
#define INT8_MIN (-128)
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
#define INT16_MIN (-32767-1)
|
||||
#endif
|
||||
#ifndef INT32_MIN
|
||||
#define INT32_MIN (-2147483647-1)
|
||||
#endif
|
||||
#ifndef INT8_MAX
|
||||
#define INT8_MAX (127)
|
||||
#endif
|
||||
#ifndef INT16_MAX
|
||||
#define INT16_MAX (32767)
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX (2147483647)
|
||||
#endif
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX (255U)
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX (65535U)
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX (4294967295U)
|
||||
#endif
|
||||
|
||||
#endif /* ! C99 */
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
||||
|
||||
/* TODO: this is always defined, so inline it */
|
||||
#define yyconst const
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define yynoreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
#define yynoreturn
|
||||
#endif
|
||||
|
||||
/* Size of default input buffer. */
|
||||
#ifndef YY_BUF_SIZE
|
||||
#ifdef __ia64__
|
||||
/* On IA-64, the buffer size is 16k, not 8k.
|
||||
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
|
||||
* Ditto for the __ia64__ case accordingly.
|
||||
*/
|
||||
#define YY_BUF_SIZE 32768
|
||||
#else
|
||||
#define YY_BUF_SIZE 16384
|
||||
#endif /* __ia64__ */
|
||||
#endif
|
||||
|
||||
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
|
||||
#define YY_TYPEDEF_YY_BUFFER_STATE
|
||||
typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
||||
#endif
|
||||
|
||||
#ifndef YY_TYPEDEF_YY_SIZE_T
|
||||
#define YY_TYPEDEF_YY_SIZE_T
|
||||
typedef size_t yy_size_t;
|
||||
#endif
|
||||
|
||||
extern int yyleng;
|
||||
|
||||
extern FILE *yyin, *yyout;
|
||||
|
||||
#ifndef YY_STRUCT_YY_BUFFER_STATE
|
||||
#define YY_STRUCT_YY_BUFFER_STATE
|
||||
struct yy_buffer_state
|
||||
{
|
||||
FILE *yy_input_file;
|
||||
|
||||
char *yy_ch_buf; /* input buffer */
|
||||
char *yy_buf_pos; /* current position in input buffer */
|
||||
|
||||
/* Size of input buffer in bytes, not including room for EOB
|
||||
* characters.
|
||||
*/
|
||||
int yy_buf_size;
|
||||
|
||||
/* Number of characters read into yy_ch_buf, not including EOB
|
||||
* characters.
|
||||
*/
|
||||
int yy_n_chars;
|
||||
|
||||
/* Whether we "own" the buffer - i.e., we know we created it,
|
||||
* and can realloc() it to grow it, and should free() it to
|
||||
* delete it.
|
||||
*/
|
||||
int yy_is_our_buffer;
|
||||
|
||||
/* Whether this is an "interactive" input source; if so, and
|
||||
* if we're using stdio for input, then we want to use getc()
|
||||
* instead of fread(), to make sure we stop fetching input after
|
||||
* each newline.
|
||||
*/
|
||||
int yy_is_interactive;
|
||||
|
||||
/* Whether we're considered to be at the beginning of a line.
|
||||
* If so, '^' rules will be active on the next match, otherwise
|
||||
* not.
|
||||
*/
|
||||
int yy_at_bol;
|
||||
|
||||
int yy_bs_lineno; /**< The line count. */
|
||||
int yy_bs_column; /**< The column count. */
|
||||
|
||||
/* Whether to try to fill the input buffer when we reach the
|
||||
* end of it.
|
||||
*/
|
||||
int yy_fill_buffer;
|
||||
|
||||
int yy_buffer_status;
|
||||
|
||||
};
|
||||
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
||||
|
||||
void yyrestart ( FILE *input_file );
|
||||
void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
|
||||
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
|
||||
void yy_delete_buffer ( YY_BUFFER_STATE b );
|
||||
void yy_flush_buffer ( YY_BUFFER_STATE b );
|
||||
void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
|
||||
void yypop_buffer_state ( void );
|
||||
|
||||
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
|
||||
YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
|
||||
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
|
||||
|
||||
void *yyalloc ( yy_size_t );
|
||||
void *yyrealloc ( void *, yy_size_t );
|
||||
void yyfree ( void * );
|
||||
|
||||
/* Begin user sect3 */
|
||||
|
||||
#define yywrap() (/*CONSTCOND*/1)
|
||||
#define YY_SKIP_YYWRAP
|
||||
|
||||
extern int yylineno;
|
||||
|
||||
extern char *yytext;
|
||||
#ifdef yytext_ptr
|
||||
#undef yytext_ptr
|
||||
#endif
|
||||
#define yytext_ptr yytext
|
||||
|
||||
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
|
||||
#define INITIAL 0
|
||||
#define C_COMMENT 1
|
||||
#define C_LINE_COMMENT 2
|
||||
#define VARIABLES 3
|
||||
#define IDENTIFIER 4
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef YY_NO_UNISTD_H
|
||||
/* Special case for "unistd.h", since it is non-ANSI. We include it way
|
||||
* down here because we want the user's section 1 to have been scanned first.
|
||||
* The user has a chance to override it with an option.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef YY_EXTRA_TYPE
|
||||
#define YY_EXTRA_TYPE void *
|
||||
#endif
|
||||
|
||||
/* Accessor methods to globals.
|
||||
These are made visible to non-reentrant scanners for convenience. */
|
||||
|
||||
int yylex_destroy ( void );
|
||||
|
||||
int yyget_debug ( void );
|
||||
|
||||
void yyset_debug ( int debug_flag );
|
||||
|
||||
YY_EXTRA_TYPE yyget_extra ( void );
|
||||
|
||||
void yyset_extra ( YY_EXTRA_TYPE user_defined );
|
||||
|
||||
FILE *yyget_in ( void );
|
||||
|
||||
void yyset_in ( FILE * _in_str );
|
||||
|
||||
FILE *yyget_out ( void );
|
||||
|
||||
void yyset_out ( FILE * _out_str );
|
||||
|
||||
int yyget_leng ( void );
|
||||
|
||||
char *yyget_text ( void );
|
||||
|
||||
int yyget_lineno ( void );
|
||||
|
||||
void yyset_lineno ( int _line_number );
|
||||
|
||||
/* Macros after this point can all be overridden by user definitions in
|
||||
* section 1.
|
||||
*/
|
||||
|
||||
#ifndef YY_SKIP_YYWRAP
|
||||
#ifdef __cplusplus
|
||||
extern "C" int yywrap ( void );
|
||||
#else
|
||||
extern int yywrap ( void );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef yytext_ptr
|
||||
static void yy_flex_strncpy ( char *, const char *, int );
|
||||
#endif
|
||||
|
||||
#ifdef YY_NEED_STRLEN
|
||||
static int yy_flex_strlen ( const char * );
|
||||
#endif
|
||||
|
||||
#ifndef YY_NO_INPUT
|
||||
|
||||
#endif
|
||||
|
||||
/* Amount of stuff to slurp up with each read. */
|
||||
#ifndef YY_READ_BUF_SIZE
|
||||
#ifdef __ia64__
|
||||
/* On IA-64, the buffer size is 16k, not 8k */
|
||||
#define YY_READ_BUF_SIZE 16384
|
||||
#else
|
||||
#define YY_READ_BUF_SIZE 8192
|
||||
#endif /* __ia64__ */
|
||||
#endif
|
||||
|
||||
/* Number of entries by which start-condition stack grows. */
|
||||
#ifndef YY_START_STACK_INCR
|
||||
#define YY_START_STACK_INCR 25
|
||||
#endif
|
||||
|
||||
/* Default declaration of generated scanner - a define so the user can
|
||||
* easily add parameters.
|
||||
*/
|
||||
#ifndef YY_DECL
|
||||
#define YY_DECL_IS_OURS 1
|
||||
|
||||
extern int yylex (void);
|
||||
|
||||
#define YY_DECL int yylex (void)
|
||||
#endif /* !YY_DECL */
|
||||
|
||||
/* yy_get_previous_state - get the state just before the EOB char was reached */
|
||||
|
||||
#undef YY_NEW_FILE
|
||||
#undef YY_FLUSH_BUFFER
|
||||
#undef yy_set_bol
|
||||
#undef yy_new_buffer
|
||||
#undef yy_set_interactive
|
||||
#undef YY_DO_BEFORE_ACTION
|
||||
|
||||
#ifdef YY_DECL_IS_OURS
|
||||
#undef YY_DECL_IS_OURS
|
||||
#undef YY_DECL
|
||||
#endif
|
||||
|
||||
#line 285 "..\\..\\..\\code\\globalcpp\\parser\\yyLexer.l"
|
||||
|
||||
|
||||
#line 406 "../../../code/globalcpp/parser/yyLexer.h"
|
||||
#undef yyIN_HEADER
|
||||
#endif /* yyHEADER_H */
|
2677
code/parser/yyParser.cpp
Normal file
2677
code/parser/yyParser.cpp
Normal file
File diff suppressed because it is too large
Load diff
159
code/parser/yyParser.h
Normal file
159
code/parser/yyParser.h
Normal file
|
@ -0,0 +1,159 @@
|
|||
/* A Bison parser, made by GNU Bison 2.7. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2012 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 <http://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. */
|
||||
|
||||
#ifndef YY_YY_CODE_GLOBALCPP_PARSER_YYPARSER_H_INCLUDED
|
||||
# define YY_YY_CODE_GLOBALCPP_PARSER_YYPARSER_H_INCLUDED
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int yydebug;
|
||||
#endif
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
END = 0,
|
||||
TOKEN_EOL = 258,
|
||||
TOKEN_COMMA = 259,
|
||||
TOKEN_TERNARY = 260,
|
||||
TOKEN_SHIFT_RIGHT_EQUALS = 261,
|
||||
TOKEN_SHIFT_LEFT_EQUALS = 262,
|
||||
TOKEN_OR_EQUALS = 263,
|
||||
TOKEN_EXCL_OR_EQUALS = 264,
|
||||
TOKEN_AND_EQUALS = 265,
|
||||
TOKEN_MODULUS_EQUALS = 266,
|
||||
TOKEN_DIVIDE_EQUALS = 267,
|
||||
TOKEN_MULTIPLY_EQUALS = 268,
|
||||
TOKEN_MINUS_EQUALS = 269,
|
||||
TOKEN_PLUS_EQUALS = 270,
|
||||
TOKEN_ASSIGNMENT = 271,
|
||||
TOKEN_LOGICAL_OR = 272,
|
||||
TOKEN_LOGICAL_AND = 273,
|
||||
TOKEN_BITWISE_OR = 274,
|
||||
TOKEN_BITWISE_EXCL_OR = 275,
|
||||
TOKEN_BITWISE_AND = 276,
|
||||
TOKEN_INEQUALITY = 277,
|
||||
TOKEN_EQUALITY = 278,
|
||||
TOKEN_GREATER_THAN_OR_EQUAL = 279,
|
||||
TOKEN_GREATER_THAN = 280,
|
||||
TOKEN_LESS_THAN_OR_EQUAL = 281,
|
||||
TOKEN_LESS_THAN = 282,
|
||||
TOKEN_SHIFT_RIGHT = 283,
|
||||
TOKEN_SHIFT_LEFT = 284,
|
||||
TOKEN_MINUS = 285,
|
||||
TOKEN_PLUS = 286,
|
||||
TOKEN_MODULUS = 287,
|
||||
TOKEN_DIVIDE = 288,
|
||||
TOKEN_MULTIPLY = 289,
|
||||
TOKEN_LISTENER = 290,
|
||||
TOKEN_COMPLEMENT = 291,
|
||||
TOKEN_NOT = 292,
|
||||
TOKEN_NEG = 293,
|
||||
TOKEN_FLOAT = 294,
|
||||
TOKEN_INTEGER = 295,
|
||||
TOKEN_IDENTIFIER = 296,
|
||||
TOKEN_STRING = 297,
|
||||
TOKEN_NIL = 298,
|
||||
TOKEN_NULL = 299,
|
||||
TOKEN_LBRACKET = 300,
|
||||
TOKEN_RBRACKET = 301,
|
||||
TOKEN_COLON = 302,
|
||||
TOKEN_SEMICOLON = 303,
|
||||
TOKEN_DOLLAR = 304,
|
||||
TOKEN_DOUBLE_COLON = 305,
|
||||
TOKEN_NUMBER = 306,
|
||||
TOKEN_PERIOD = 307,
|
||||
TOKEN_DECREMENT = 308,
|
||||
TOKEN_INCREMENT = 309,
|
||||
TOKEN_RPAREN = 310,
|
||||
TOKEN_LPAREN = 311,
|
||||
TOKEN_RSQUARE = 312,
|
||||
TOKEN_LSQUARE = 313,
|
||||
TOKEN_MAKEARRAY = 314,
|
||||
TOKEN_ENDARRAY = 315,
|
||||
TOKEN_CATCH = 316,
|
||||
TOKEN_TRY = 317,
|
||||
TOKEN_DO = 318,
|
||||
TOKEN_FOR = 319,
|
||||
TOKEN_IF = 320,
|
||||
TOKEN_ELSE = 321,
|
||||
TOKEN_SWITCH = 322,
|
||||
TOKEN_WHILE = 323,
|
||||
TOKEN_BREAK = 324,
|
||||
TOKEN_CASE = 325,
|
||||
TOKEN_CONTINUE = 326,
|
||||
TOKEN_SIZE = 327,
|
||||
TOKEN_END = 328,
|
||||
TOKEN_RETURN = 329
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
/* Line 2058 of yacc.c */
|
||||
#line 53 "..\\..\\..\\code\\globalcpp\\parser\\yyParser.yy"
|
||||
|
||||
stype_t s;
|
||||
|
||||
|
||||
/* Line 2058 of yacc.c */
|
||||
#line 137 "../../../code/globalcpp/parser/yyParser.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int yyparse (void *YYPARSE_PARAM);
|
||||
#else
|
||||
int yyparse ();
|
||||
#endif
|
||||
#else /* ! YYPARSE_PARAM */
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int yyparse (void);
|
||||
#else
|
||||
int yyparse ();
|
||||
#endif
|
||||
#endif /* ! YYPARSE_PARAM */
|
||||
|
||||
#endif /* !YY_YY_CODE_GLOBALCPP_PARSER_YYPARSER_H_INCLUDED */
|
Loading…
Add table
Add a link
Reference in a new issue