mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Format script grammar source files
This commit is contained in:
parent
816126b13a
commit
08a985d183
6 changed files with 427 additions and 383 deletions
|
@ -1,7 +1,7 @@
|
|||
%{
|
||||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2015 the OpenMoHAA team
|
||||
* Copyright (C) 2025 the OpenMoHAA team
|
||||
*
|
||||
* This file is part of OpenMoHAA source code.
|
||||
*
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2025 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
|
||||
* ===========================================================================
|
||||
*
|
||||
*
|
||||
* lex.yy.cpp: original lex generated file (unimplemented)
|
||||
*/
|
||||
|
||||
#include "scriptcompiler.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%{
|
||||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2015 the OpenMoHAA team
|
||||
* Copyright (C) 2025 the OpenMoHAA team
|
||||
*
|
||||
* This file is part of OpenMoHAA source code.
|
||||
*
|
||||
|
@ -144,14 +144,13 @@ static bool UseField(void)
|
|||
return prev_yylex == TOKEN_PERIOD || prev_yylex == TOKEN_DOLLAR;
|
||||
}
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
{ \
|
||||
#define YY_INPUT(buf, result, max_size) \
|
||||
{ \
|
||||
char c; \
|
||||
int n; \
|
||||
\
|
||||
c = '*'; \
|
||||
for(n = 0; n < max_size; n++) \
|
||||
{ \
|
||||
for (n = 0; n < max_size; n++) { \
|
||||
c = *in_ptr++; \
|
||||
if (!c || c == '\n') { \
|
||||
break; \
|
||||
|
@ -160,17 +159,14 @@ static bool UseField(void)
|
|||
buf[n] = c; \
|
||||
} \
|
||||
\
|
||||
if (c == '\n') \
|
||||
{ \
|
||||
if (c == '\n') { \
|
||||
buf[n++] = c; \
|
||||
} \
|
||||
else if (!c) \
|
||||
{ \
|
||||
} else if (!c) { \
|
||||
in_ptr--; \
|
||||
} \
|
||||
\
|
||||
result = n; \
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
@ -196,14 +192,14 @@ varname [a-zA-Z0-9_\"$\\]+
|
|||
|
||||
%%
|
||||
|
||||
"/*" { BEGIN( C_COMMENT ); }
|
||||
<C_COMMENT>"*/" { BEGIN( INITIAL ); }
|
||||
"/*" { 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 ); }
|
||||
"//"[^\r\n]* { if(prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); }
|
||||
|
||||
<VARIABLES>"size" { BEGIN(INITIAL); YYLEX(TOKEN_SIZE); }
|
||||
<VARIABLES>[ \t]*\./([0-9]*[^0-9[:space:]]) { YYLEX(TOKEN_PERIOD); }
|
||||
|
@ -223,105 +219,103 @@ varname [a-zA-Z0-9_\"$\\]+
|
|||
yyreducepos(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
\"{string}\"{nonexpr} {
|
||||
BEGIN(IDENTIFIER);
|
||||
yymore();
|
||||
}
|
||||
|
||||
\"{string}\" { TextEscapeValue( yytext + 1, yyleng - 2 ); YYLEX( TOKEN_STRING ); }
|
||||
\"{string}\" { TextEscapeValue(yytext + 1, yyleng - 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 ); }
|
||||
"?" { 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 ); }
|
||||
"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_LEFT_BRACES ); }
|
||||
"}" { parsedata.braces_count--; YYLEX( TOKEN_RIGHT_BRACES ); }
|
||||
"{" { parsedata.braces_count++; YYLEX(TOKEN_LEFT_BRACES); }
|
||||
"}" { parsedata.braces_count--; YYLEX(TOKEN_RIGHT_BRACES); }
|
||||
"(" { YYLEX(TOKEN_LEFT_BRACKET); }
|
||||
")" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_BRACKET); }
|
||||
"[" { YYLEX(TOKEN_LEFT_SQUARE_BRACKET); }
|
||||
"]" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_SQUARE_BRACKET); }
|
||||
|
||||
"=" { YYLEX( TOKEN_ASSIGNMENT ); }
|
||||
":" { YYLEX( TOKEN_COLON ); }
|
||||
"::" { YYLEX( TOKEN_DOUBLE_COLON ); }
|
||||
";" { YYLEX( TOKEN_SEMICOLON ); }
|
||||
"=" { YYLEX(TOKEN_ASSIGNMENT); }
|
||||
":" { YYLEX(TOKEN_COLON); }
|
||||
"::" { YYLEX(TOKEN_DOUBLE_COLON); }
|
||||
";" { YYLEX(TOKEN_SEMICOLON); }
|
||||
|
||||
"==" { YYLEX( TOKEN_EQUALITY ); }
|
||||
"ifequal" { YYLEX( TOKEN_EQUALITY ); }
|
||||
"ifstrequal" { YYLEX( TOKEN_EQUALITY ); }
|
||||
"||" { YYLEX( TOKEN_LOGICAL_OR ); }
|
||||
"&&" { YYLEX( TOKEN_LOGICAL_AND ); }
|
||||
"==" { YYLEX(TOKEN_EQUALITY); }
|
||||
"ifequal" { YYLEX(TOKEN_EQUALITY); }
|
||||
"ifstrequal" { 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 ); }
|
||||
"ifnotequal" { YYLEX( TOKEN_INEQUALITY ); }
|
||||
"ifstrnotequal" { YYLEX( TOKEN_INEQUALITY ); }
|
||||
"<" { YYLEX( TOKEN_LESS_THAN ); }
|
||||
"ifless" { YYLEX( TOKEN_LESS_THAN ); }
|
||||
">" { YYLEX( TOKEN_GREATER_THAN ); }
|
||||
"ifgreater" { YYLEX( TOKEN_GREATER_THAN ); }
|
||||
"<=" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); }
|
||||
"iflessequal" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); }
|
||||
">=" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); }
|
||||
"ifgreaterequal" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); }
|
||||
[ \t]"-" { YYLEX( TOKEN_NEG ); }
|
||||
"|" { YYLEX(TOKEN_BITWISE_OR); }
|
||||
"^" { YYLEX(TOKEN_BITWISE_EXCL_OR); }
|
||||
"&" { YYLEX(TOKEN_BITWISE_AND); }
|
||||
"!=" { YYLEX(TOKEN_INEQUALITY); }
|
||||
"ifnotequal" { YYLEX(TOKEN_INEQUALITY); }
|
||||
"ifstrnotequal" { YYLEX(TOKEN_INEQUALITY); }
|
||||
"<" { YYLEX(TOKEN_LESS_THAN); }
|
||||
"ifless" { YYLEX(TOKEN_LESS_THAN); }
|
||||
">" { YYLEX(TOKEN_GREATER_THAN); }
|
||||
"ifgreater" { YYLEX(TOKEN_GREATER_THAN); }
|
||||
"<=" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); }
|
||||
"iflessequal" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); }
|
||||
">=" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); }
|
||||
"ifgreaterequal" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); }
|
||||
[ \t]"-" { YYLEX(TOKEN_NEG); }
|
||||
|
||||
"+" { YYLEX( TOKEN_PLUS ); }
|
||||
"+=" { YYLEX( TOKEN_PLUS_EQUALS ); }
|
||||
"++"|[ \t]"++" { YYLEX( TOKEN_INCREMENT ); }
|
||||
"-"|"-"[ \t]|[ \t]"-"[ \t] { YYLEX( TOKEN_MINUS ); }
|
||||
"-=" { YYLEX( TOKEN_MINUS_EQUALS ); }
|
||||
[ \t]"-=" { YYLEX( TOKEN_MINUS_EQUALS ); }
|
||||
"--"|[ \t]"--" { 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_PLUS); }
|
||||
"+=" { YYLEX(TOKEN_PLUS_EQUALS); }
|
||||
"++"|[ \t]"++" { YYLEX(TOKEN_INCREMENT); }
|
||||
"-"|"-"[ \t]|[ \t]"-"[ \t] { YYLEX(TOKEN_MINUS); }
|
||||
"-=" { YYLEX(TOKEN_MINUS_EQUALS); }
|
||||
[ \t]"-=" { YYLEX(TOKEN_MINUS_EQUALS); }
|
||||
"--"|[ \t]"--" { 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_PERIOD); }
|
||||
|
||||
"," { YYLEX( TOKEN_COMMA ); }
|
||||
"," { YYLEX(TOKEN_COMMA); }
|
||||
|
||||
"NULL" { YYLEX( TOKEN_NULL ); }
|
||||
"NIL" { YYLEX( TOKEN_NIL ); }
|
||||
"NULL" { YYLEX(TOKEN_NULL); }
|
||||
"NIL" { YYLEX(TOKEN_NIL); }
|
||||
|
||||
"try" { YYLEX( TOKEN_TRY ); }
|
||||
"catch" { YYLEX( TOKEN_CATCH ); }
|
||||
"switch" { YYLEX( TOKEN_SWITCH ); }
|
||||
"try" { YYLEX(TOKEN_TRY); }
|
||||
"catch" { YYLEX(TOKEN_CATCH); }
|
||||
"switch" { YYLEX(TOKEN_SWITCH); }
|
||||
|
||||
"case" { YYLEX( TOKEN_CASE ); }
|
||||
"break" { YYLEX( TOKEN_BREAK ); }
|
||||
"continue" { YYLEX( TOKEN_CONTINUE ); }
|
||||
"case" { YYLEX(TOKEN_CASE); }
|
||||
"break" { YYLEX(TOKEN_BREAK); }
|
||||
"continue" { YYLEX(TOKEN_CONTINUE); }
|
||||
|
||||
"makearray"|"makeArray" { YYLEX( TOKEN_MAKEARRAY ); }
|
||||
"endarray"|"endArray" { YYLEX( TOKEN_ENDARRAY ); }
|
||||
"makearray"|"makeArray" { YYLEX(TOKEN_MAKEARRAY); }
|
||||
"endarray"|"endArray" { YYLEX(TOKEN_ENDARRAY); }
|
||||
|
||||
[\r\n]+ { if (prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); }
|
||||
[ \t] { ; }
|
||||
|
@ -388,7 +382,8 @@ varname [a-zA-Z0-9_\"$\\]+
|
|||
//
|
||||
// Implements yywrap to always append a newline to the source
|
||||
//
|
||||
int yywrap(void) {
|
||||
int yywrap(void)
|
||||
{
|
||||
if (parseStage == PS_TYPE) {
|
||||
parseStage = PS_BODY;
|
||||
in_ptr = start_ptr;
|
||||
|
@ -397,10 +392,8 @@ int yywrap(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (parseStage == PS_BODY)
|
||||
{
|
||||
if (YY_START == C_COMMENT)
|
||||
{
|
||||
if (parseStage == PS_BODY) {
|
||||
if (YY_START == C_COMMENT) {
|
||||
Compiler.CompileError(success_pos, "unexpected end of file found in comment");
|
||||
return 1;
|
||||
}
|
||||
|
@ -413,6 +406,7 @@ int yywrap(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void yy_init_script() {
|
||||
void yy_init_script()
|
||||
{
|
||||
BEGIN(SCRIPT);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2008 the OpenMoHAA team
|
||||
Copyright (C) 2025 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2008 the OpenMoHAA team
|
||||
Copyright (C) 2025 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* ===========================================================================
|
||||
* Copyright (C) 2025 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
|
||||
* ===========================================================================
|
||||
*
|
||||
*
|
||||
* y.tab.cpp: original yacc generated file (unimplemented)
|
||||
*/
|
||||
|
||||
#include "../script/scriptcompiler.h"
|
||||
|
||||
typedef int yy_state_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue