enhance developer mode
This commit is contained in:
@ -36,9 +36,9 @@ RGX_INT_HEX 0[xX][0-9a-fA-F]+
|
||||
RGX_INT_DEC [0-9]+
|
||||
RGX_DEFAULT (.|\n)
|
||||
|
||||
%x COMMENT_BLOCK_STATE
|
||||
%s DEVBLOCK_ON_STATE
|
||||
%x DEVBLOCK_OFF_STATE
|
||||
%x COMMENT_STATE
|
||||
%x DEV_OFF_STATE
|
||||
%s DEV_ON_STATE
|
||||
|
||||
%%
|
||||
|
||||
@ -46,24 +46,28 @@ RGX_DEFAULT (.|\n)
|
||||
ctx->loc.step();
|
||||
%}
|
||||
|
||||
[ \t\r] { ctx->loc.step(); }
|
||||
|
||||
\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
[ \t\r] { ctx->loc.step(); }
|
||||
\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
|
||||
"//".*
|
||||
|
||||
"/*" { BEGIN(COMMENT_BLOCK_STATE); }
|
||||
<COMMENT_BLOCK_STATE>.
|
||||
<COMMENT_BLOCK_STATE>\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
<COMMENT_BLOCK_STATE>"*/" { BEGIN(INITIAL); }
|
||||
"/*" { BEGIN(COMMENT_STATE); }
|
||||
<COMMENT_STATE>.
|
||||
<COMMENT_STATE>\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
<COMMENT_STATE>"*/" { BEGIN(INITIAL); }
|
||||
<COMMENT_STATE><<EOF>> { throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); }
|
||||
<INITIAL>"*/" { throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); }
|
||||
|
||||
"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
||||
<DEVBLOCK_OFF_STATE>.
|
||||
<DEVBLOCK_OFF_STATE>\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
<DEVBLOCK_OFF_STATE,DEVBLOCK_ON_STATE>"#/" { BEGIN(INITIAL); }
|
||||
<DEV_ON_STATE>"/#" { throw h1::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); }
|
||||
<DEV_ON_STATE>"#/" { BEGIN(INITIAL); return h1::parser::make_DEVEND(ctx->loc); }
|
||||
<DEV_ON_STATE><<EOF>> { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); }
|
||||
|
||||
<INITIAL>"*/" { throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); }
|
||||
<INITIAL>"#/" { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); }
|
||||
"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return h1::parser::make_DEVBEGIN(ctx->loc); }
|
||||
<DEV_OFF_STATE>.
|
||||
<DEV_OFF_STATE>\n { ctx->loc.lines(yyleng); ctx->loc.step(); }
|
||||
<DEV_OFF_STATE>"#/" { BEGIN(INITIAL); }
|
||||
<DEV_OFF_STATE><<EOF>> { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); }
|
||||
<INITIAL>"#/" { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); }
|
||||
|
||||
"#inline" { return h1::parser::make_INLINE(ctx->loc); }
|
||||
"#include" { return h1::parser::make_INCLUDE(ctx->loc); }
|
||||
|
@ -45,6 +45,8 @@ using namespace xsk::gsc;
|
||||
xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* ctx);
|
||||
}
|
||||
|
||||
%token DEVBEGIN "/#"
|
||||
%token DEVEND "#/"
|
||||
%token INLINE "#inline"
|
||||
%token INCLUDE "#include"
|
||||
%token USINGTREE "#using_animtree"
|
||||
@ -147,6 +149,7 @@ xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* c
|
||||
%type <ast::decl_constant::ptr> decl_constant
|
||||
%type <ast::decl_thread::ptr> decl_thread
|
||||
%type <ast::stmt> stmt
|
||||
%type <ast::stmt_list::ptr> stmt_dev
|
||||
%type <ast::stmt_list::ptr> stmt_block
|
||||
%type <ast::stmt_list::ptr> stmt_list
|
||||
%type <ast::stmt_expr::ptr> stmt_expr
|
||||
@ -277,7 +280,9 @@ include
|
||||
;
|
||||
|
||||
declaration
|
||||
: decl_usingtree { $$.as_usingtree = std::move($1); }
|
||||
: DEVBEGIN { $$.as_dev_begin = std::make_unique<ast::decl_dev_begin>(@$); }
|
||||
| DEVEND { $$.as_dev_end = std::make_unique<ast::decl_dev_end>(@$); }
|
||||
| decl_usingtree { $$.as_usingtree = std::move($1); }
|
||||
| decl_constant { $$.as_constant = std::move($1); }
|
||||
| decl_thread { $$.as_thread = std::move($1); }
|
||||
;
|
||||
@ -298,7 +303,8 @@ decl_thread
|
||||
;
|
||||
|
||||
stmt
|
||||
: stmt_block { $$.as_list = std::move($1); }
|
||||
: stmt_dev { $$.as_list = std::move($1); }
|
||||
| stmt_block { $$.as_list = std::move($1); }
|
||||
| stmt_call { $$.as_call = std::move($1); }
|
||||
| stmt_assign { $$.as_assign = std::move($1); }
|
||||
| stmt_endon { $$.as_endon = std::move($1); }
|
||||
@ -325,6 +331,11 @@ stmt
|
||||
| stmt_prof_end { $$.as_prof_end = std::move($1); }
|
||||
;
|
||||
|
||||
stmt_dev
|
||||
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
|
||||
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
|
||||
;
|
||||
|
||||
stmt_block
|
||||
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
|
||||
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
|
||||
|
Reference in New Issue
Block a user