Format script grammar source files
Some checks failed
Build branch / build-all (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled

This commit is contained in:
smallmodel 2025-04-26 19:22:34 +02:00
parent 816126b13a
commit 08a985d183
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
6 changed files with 427 additions and 383 deletions

View file

@ -1,7 +1,7 @@
%{ %{
/* /*
* =========================================================================== * ===========================================================================
* Copyright (C) 2015 the OpenMoHAA team * Copyright (C) 2025 the OpenMoHAA team
* *
* This file is part of OpenMoHAA source code. * This file is part of OpenMoHAA source code.
* *

View file

@ -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 "scriptcompiler.h"
#include <stdio.h> #include <stdio.h>

View file

@ -1,7 +1,7 @@
%{ %{
/* /*
* =========================================================================== * ===========================================================================
* Copyright (C) 2015 the OpenMoHAA team * Copyright (C) 2025 the OpenMoHAA team
* *
* This file is part of OpenMoHAA source code. * 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; 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; \ char c; \
int n; \ int n; \
\ \
c = '*'; \ c = '*'; \
for(n = 0; n < max_size; n++) \ for (n = 0; n < max_size; n++) { \
{ \
c = *in_ptr++; \ c = *in_ptr++; \
if (!c || c == '\n') { \ if (!c || c == '\n') { \
break; \ break; \
@ -160,17 +159,14 @@ static bool UseField(void)
buf[n] = c; \ buf[n] = c; \
} \ } \
\ \
if (c == '\n') \ if (c == '\n') { \
{ \
buf[n++] = c; \ buf[n++] = c; \
} \ } else if (!c) { \
else if (!c) \
{ \
in_ptr--; \ in_ptr--; \
} \ } \
\ \
result = n; \ result = n; \
} }
%} %}
@ -196,14 +192,14 @@ varname [a-zA-Z0-9_\"$\\]+
%% %%
"/*" { BEGIN( C_COMMENT ); } "/*" { BEGIN(C_COMMENT); }
<C_COMMENT>"*/" { BEGIN( INITIAL ); } <C_COMMENT>"*/" { BEGIN(INITIAL); }
<C_COMMENT>\n { ; } <C_COMMENT>\n { ; }
<C_COMMENT>. { ; } <C_COMMENT>. { ; }
"*/" { Compiler.CompileError( parsedata.pos - yyleng, "'*/' found outside of comment" ); } "*/" { Compiler.CompileError( parsedata.pos - yyleng, "'*/' found outside of comment" ); }
\\[\r\n]+ { ; } \\[\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>"size" { BEGIN(INITIAL); YYLEX(TOKEN_SIZE); }
<VARIABLES>[ \t]*\./([0-9]*[^0-9[:space:]]) { YYLEX(TOKEN_PERIOD); } <VARIABLES>[ \t]*\./([0-9]*[^0-9[:space:]]) { YYLEX(TOKEN_PERIOD); }
@ -223,105 +219,103 @@ varname [a-zA-Z0-9_\"$\\]+
yyreducepos(1); yyreducepos(1);
} }
\"{string}\"{nonexpr} { \"{string}\"{nonexpr} {
BEGIN(IDENTIFIER); BEGIN(IDENTIFIER);
yymore(); yymore();
} }
\"{string}\" { TextEscapeValue( yytext + 1, yyleng - 2 ); YYLEX( TOKEN_STRING ); } \"{string}\" { TextEscapeValue(yytext + 1, yyleng - 2); YYLEX(TOKEN_STRING); }
"?" { YYLEX( TOKEN_TERNARY ); } "?" { YYLEX(TOKEN_TERNARY); }
"if" { YYLEX( TOKEN_IF ); } "if" { YYLEX(TOKEN_IF); }
"else" { YYLEX( TOKEN_ELSE ); } "else" { YYLEX(TOKEN_ELSE); }
"while" { YYLEX( TOKEN_WHILE ); } "while" { YYLEX(TOKEN_WHILE); }
"for" { YYLEX( TOKEN_FOR ); } "for" { YYLEX(TOKEN_FOR); }
"do" { YYLEX( TOKEN_DO ); } "do" { YYLEX(TOKEN_DO); }
"game" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_game ); 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 ); } "group" { BEGIN(VARIABLES); yylval.s.val = node1_(method_group); YYLEX(TOKEN_LISTENER); }
"level" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_level ); 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 ); } "local" { BEGIN(VARIABLES); yylval.s.val = node1_(method_local); YYLEX(TOKEN_LISTENER); }
"parm" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_parm ); 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 ); } "owner" { BEGIN(VARIABLES); yylval.s.val = node1_(method_owner); YYLEX(TOKEN_LISTENER); }
"self" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_self ); 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_LEFT_BRACES); }
"}" { parsedata.braces_count--; YYLEX( TOKEN_RIGHT_BRACES ); } "}" { parsedata.braces_count--; YYLEX(TOKEN_RIGHT_BRACES); }
"(" { YYLEX(TOKEN_LEFT_BRACKET); } "(" { YYLEX(TOKEN_LEFT_BRACKET); }
")" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_BRACKET); } ")" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_BRACKET); }
"[" { YYLEX(TOKEN_LEFT_SQUARE_BRACKET); } "[" { YYLEX(TOKEN_LEFT_SQUARE_BRACKET); }
"]" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_SQUARE_BRACKET); } "]" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_SQUARE_BRACKET); }
"=" { YYLEX( TOKEN_ASSIGNMENT ); } "=" { YYLEX(TOKEN_ASSIGNMENT); }
":" { YYLEX( TOKEN_COLON ); } ":" { YYLEX(TOKEN_COLON); }
"::" { YYLEX( TOKEN_DOUBLE_COLON ); } "::" { YYLEX(TOKEN_DOUBLE_COLON); }
";" { YYLEX( TOKEN_SEMICOLON ); } ";" { YYLEX(TOKEN_SEMICOLON); }
"==" { YYLEX( TOKEN_EQUALITY ); } "==" { YYLEX(TOKEN_EQUALITY); }
"ifequal" { YYLEX( TOKEN_EQUALITY ); } "ifequal" { YYLEX(TOKEN_EQUALITY); }
"ifstrequal" { YYLEX( TOKEN_EQUALITY ); } "ifstrequal" { YYLEX(TOKEN_EQUALITY); }
"||" { YYLEX( TOKEN_LOGICAL_OR ); } "||" { YYLEX(TOKEN_LOGICAL_OR); }
"&&" { YYLEX( TOKEN_LOGICAL_AND ); } "&&" { YYLEX(TOKEN_LOGICAL_AND); }
"|" { YYLEX( TOKEN_BITWISE_OR ); } "|" { YYLEX(TOKEN_BITWISE_OR); }
"^" { YYLEX( TOKEN_BITWISE_EXCL_OR ); } "^" { YYLEX(TOKEN_BITWISE_EXCL_OR); }
"&" { YYLEX( TOKEN_BITWISE_AND ); } "&" { YYLEX(TOKEN_BITWISE_AND); }
"!=" { YYLEX( TOKEN_INEQUALITY ); } "!=" { YYLEX(TOKEN_INEQUALITY); }
"ifnotequal" { YYLEX( TOKEN_INEQUALITY ); } "ifnotequal" { YYLEX(TOKEN_INEQUALITY); }
"ifstrnotequal" { YYLEX( TOKEN_INEQUALITY ); } "ifstrnotequal" { YYLEX(TOKEN_INEQUALITY); }
"<" { YYLEX( TOKEN_LESS_THAN ); } "<" { YYLEX(TOKEN_LESS_THAN); }
"ifless" { YYLEX( TOKEN_LESS_THAN ); } "ifless" { YYLEX(TOKEN_LESS_THAN); }
">" { YYLEX( TOKEN_GREATER_THAN ); } ">" { YYLEX(TOKEN_GREATER_THAN); }
"ifgreater" { YYLEX( TOKEN_GREATER_THAN ); } "ifgreater" { YYLEX(TOKEN_GREATER_THAN); }
"<=" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); } "<=" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); }
"iflessequal" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); } "iflessequal" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); }
">=" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); } ">=" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); }
"ifgreaterequal" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); } "ifgreaterequal" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); }
[ \t]"-" { YYLEX( TOKEN_NEG ); } [ \t]"-" { YYLEX(TOKEN_NEG); }
"+" { YYLEX( TOKEN_PLUS ); } "+" { YYLEX(TOKEN_PLUS); }
"+=" { YYLEX( TOKEN_PLUS_EQUALS ); } "+=" { YYLEX(TOKEN_PLUS_EQUALS); }
"++"|[ \t]"++" { YYLEX( TOKEN_INCREMENT ); } "++"|[ \t]"++" { YYLEX(TOKEN_INCREMENT); }
"-"|"-"[ \t]|[ \t]"-"[ \t] { YYLEX( TOKEN_MINUS ); } "-"|"-"[ \t]|[ \t]"-"[ \t] { YYLEX(TOKEN_MINUS); }
"-=" { YYLEX( TOKEN_MINUS_EQUALS ); } "-=" { YYLEX(TOKEN_MINUS_EQUALS); }
[ \t]"-=" { YYLEX( TOKEN_MINUS_EQUALS ); } [ \t]"-=" { YYLEX(TOKEN_MINUS_EQUALS); }
"--"|[ \t]"--" { YYLEX( TOKEN_DECREMENT ); } "--"|[ \t]"--" { YYLEX(TOKEN_DECREMENT); }
"*" { YYLEX( TOKEN_MULTIPLY ); } "*" { YYLEX(TOKEN_MULTIPLY); }
"*=" { YYLEX( TOKEN_MULTIPLY_EQUALS ); } "*=" { YYLEX(TOKEN_MULTIPLY_EQUALS); }
"/" { YYLEX( TOKEN_DIVIDE ); } "/" { YYLEX(TOKEN_DIVIDE); }
"/=" { YYLEX( TOKEN_DIVIDE_EQUALS ); } "/=" { YYLEX(TOKEN_DIVIDE_EQUALS); }
"%" { YYLEX( TOKEN_MODULUS ); } "%" { YYLEX(TOKEN_MODULUS); }
"%=" { YYLEX( TOKEN_MODULUS_EQUALS ); } "%=" { YYLEX(TOKEN_MODULUS_EQUALS); }
"<<" { YYLEX( TOKEN_SHIFT_LEFT ); } "<<" { YYLEX(TOKEN_SHIFT_LEFT); }
"<<=" { YYLEX( TOKEN_SHIFT_LEFT_EQUALS ); } "<<=" { YYLEX(TOKEN_SHIFT_LEFT_EQUALS); }
">>" { YYLEX( TOKEN_SHIFT_RIGHT ); } ">>" { YYLEX(TOKEN_SHIFT_RIGHT); }
">>=" { YYLEX( TOKEN_SHIFT_RIGHT_EQUALS ); } ">>=" { YYLEX(TOKEN_SHIFT_RIGHT_EQUALS); }
"&=" { YYLEX( TOKEN_AND_EQUALS ); } "&=" { YYLEX(TOKEN_AND_EQUALS); }
"^=" { YYLEX( TOKEN_EXCL_OR_EQUALS ); } "^=" { YYLEX(TOKEN_EXCL_OR_EQUALS); }
"|=" { YYLEX( TOKEN_OR_EQUALS ); } "|=" { YYLEX(TOKEN_OR_EQUALS); }
[$]+ { BEGIN( VARIABLES ); YYLEX( TOKEN_DOLLAR ); } [$]+ { BEGIN( VARIABLES ); YYLEX(TOKEN_DOLLAR); }
"!" { YYLEX( TOKEN_NOT ); } "!" { YYLEX(TOKEN_NOT); }
"~" { YYLEX( TOKEN_COMPLEMENT ); } "~" { YYLEX(TOKEN_COMPLEMENT); }
"." { YYLEX( TOKEN_PERIOD ); } "." { YYLEX(TOKEN_PERIOD); }
"," { YYLEX( TOKEN_COMMA ); } "," { YYLEX(TOKEN_COMMA); }
"NULL" { YYLEX( TOKEN_NULL ); } "NULL" { YYLEX(TOKEN_NULL); }
"NIL" { YYLEX( TOKEN_NIL ); } "NIL" { YYLEX(TOKEN_NIL); }
"try" { YYLEX( TOKEN_TRY ); } "try" { YYLEX(TOKEN_TRY); }
"catch" { YYLEX( TOKEN_CATCH ); } "catch" { YYLEX(TOKEN_CATCH); }
"switch" { YYLEX( TOKEN_SWITCH ); } "switch" { YYLEX(TOKEN_SWITCH); }
"case" { YYLEX( TOKEN_CASE ); } "case" { YYLEX(TOKEN_CASE); }
"break" { YYLEX( TOKEN_BREAK ); } "break" { YYLEX(TOKEN_BREAK); }
"continue" { YYLEX( TOKEN_CONTINUE ); } "continue" { YYLEX(TOKEN_CONTINUE); }
"makearray"|"makeArray" { YYLEX( TOKEN_MAKEARRAY ); } "makearray"|"makeArray" { YYLEX(TOKEN_MAKEARRAY); }
"endarray"|"endArray" { YYLEX( TOKEN_ENDARRAY ); } "endarray"|"endArray" { YYLEX(TOKEN_ENDARRAY); }
[\r\n]+ { if (prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); } [\r\n]+ { if (prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); }
[ \t] { ; } [ \t] { ; }
@ -388,7 +382,8 @@ varname [a-zA-Z0-9_\"$\\]+
// //
// Implements yywrap to always append a newline to the source // Implements yywrap to always append a newline to the source
// //
int yywrap(void) { int yywrap(void)
{
if (parseStage == PS_TYPE) { if (parseStage == PS_TYPE) {
parseStage = PS_BODY; parseStage = PS_BODY;
in_ptr = start_ptr; in_ptr = start_ptr;
@ -397,10 +392,8 @@ int yywrap(void) {
return 0; return 0;
} }
if (parseStage == PS_BODY) if (parseStage == PS_BODY) {
{ if (YY_START == C_COMMENT) {
if (YY_START == C_COMMENT)
{
Compiler.CompileError(success_pos, "unexpected end of file found in comment"); Compiler.CompileError(success_pos, "unexpected end of file found in comment");
return 1; return 1;
} }
@ -413,6 +406,7 @@ int yywrap(void) {
return 1; return 1;
} }
void yy_init_script() { void yy_init_script()
{
BEGIN(SCRIPT); BEGIN(SCRIPT);
} }

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2008 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2008 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.

View file

@ -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" #include "../script/scriptcompiler.h"
typedef int yy_state_type; typedef int yy_state_type;