Add devblock support in IW5
This commit is contained in:
committed by
Xenxo Espasandín
parent
a015ab8708
commit
b3f47d640d
@ -1,11 +1,12 @@
|
||||
generate: IW5
|
||||
|
||||
clean:
|
||||
rm -rf ./parser.hpp
|
||||
rm -rf ./parser.cpp
|
||||
rm -rf ./lexer.hpp
|
||||
rm -rf ./lexer.cpp
|
||||
|
||||
IW5: lexer.lpp parser.ypp
|
||||
flex lexer.lpp
|
||||
bison parser.ypp -Wcounterexamples
|
||||
generate: IW5
|
||||
|
||||
clean:
|
||||
rm -rf ./parser.hpp
|
||||
rm -rf ./parser.cpp
|
||||
rm -rf ./lexer.hpp
|
||||
rm -rf ./lexer.cpp
|
||||
|
||||
IW5: lexer.lpp parser.ypp
|
||||
flex lexer.lpp
|
||||
bison parser.ypp -Wcounterexamples
|
||||
mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/iw5/xsk/
|
||||
|
@ -35,7 +35,12 @@ RGX_INT_DEC [0-9]+
|
||||
RGX_DEFAULT (.|\n)
|
||||
|
||||
%x COMMENT_BLOCK_STATE
|
||||
%x DEVELOPER_BLOCK_STATE
|
||||
/*
|
||||
this is an inclusive start condition, so rules not explicitly specifying "DEVBLOCK_ON_STATE" will also match
|
||||
http://dinosaur.compilertools.net/flex/flex_11.html
|
||||
*/
|
||||
%s DEVBLOCK_ON_STATE
|
||||
%x DEVBLOCK_OFF_STATE
|
||||
|
||||
%%
|
||||
|
||||
@ -54,10 +59,16 @@ RGX_DEFAULT (.|\n)
|
||||
<COMMENT_BLOCK_STATE>\n { loc.lines(yyleng); loc.step(); }
|
||||
<COMMENT_BLOCK_STATE>"*/" { BEGIN(INITIAL); }
|
||||
|
||||
"/#" { BEGIN(DEVELOPER_BLOCK_STATE); }
|
||||
<DEVELOPER_BLOCK_STATE>.
|
||||
<DEVELOPER_BLOCK_STATE>\n { loc.lines(yyleng); loc.step(); }
|
||||
<DEVELOPER_BLOCK_STATE>"#/" { BEGIN(INITIAL); }
|
||||
"/#" { BEGIN(devblock_mode == xsk::gsc::dev_blocks::on ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
||||
/* ignore everything if we're in devblock-off state */
|
||||
<DEVBLOCK_OFF_STATE>.
|
||||
<DEVBLOCK_OFF_STATE>\n { loc.lines(yyleng); loc.step(); }
|
||||
/* always exit devblock state when seeing #/ */
|
||||
<DEVBLOCK_OFF_STATE,DEVBLOCK_ON_STATE>"#/" { BEGIN(INITIAL); }
|
||||
|
||||
/* for better errors */
|
||||
<INITIAL>"*/" { throw iw5::parser::syntax_error(loc, "unmatched multiline comment end ('*/')"); }
|
||||
<INITIAL>"#/" { throw iw5::parser::syntax_error(loc, "unmatched devblock end ('#/')"); }
|
||||
|
||||
"breakpoint" { return iw5::parser::make_BREAKPOINT(loc); }
|
||||
"prof_begin" { return iw5::parser::make_PROFBEGIN(loc); }
|
||||
|
@ -24,16 +24,18 @@
|
||||
|
||||
%lex-param { yyscan_t yyscanner }
|
||||
%lex-param { xsk::gsc::location& loc }
|
||||
%lex-param { xsk::gsc::dev_blocks devblock_mode }
|
||||
|
||||
%parse-param { yyscan_t yyscanner }
|
||||
%parse-param { xsk::gsc::location& loc }
|
||||
%parse-param { xsk::gsc::program_ptr& ast }
|
||||
%parse-param { xsk::gsc::dev_blocks devblock_mode }
|
||||
|
||||
%code requires
|
||||
{
|
||||
#include "iw5.hpp"
|
||||
typedef void *yyscan_t;
|
||||
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc)
|
||||
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode)
|
||||
}
|
||||
|
||||
%code top
|
||||
@ -42,7 +44,7 @@ typedef void *yyscan_t;
|
||||
#include "parser.hpp"
|
||||
#include "lexer.hpp"
|
||||
using namespace xsk::gsc;
|
||||
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc);
|
||||
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode);
|
||||
}
|
||||
|
||||
%token BREAKPOINT "breakpoint"
|
||||
|
Reference in New Issue
Block a user