Skip to content

Commit

Permalink
Combine strings and integer_like into primitives (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara authored Jul 19, 2024
1 parent b233dbc commit 9f85146
Show file tree
Hide file tree
Showing 48 changed files with 1,742 additions and 1,688 deletions.
41 changes: 21 additions & 20 deletions explorerscript/antlr/ExplorerScript.g4
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,42 @@ elseif_block: ELSEIF NOT? OPEN_PAREN if_header (OR if_header)* CLOSE_PAREN OPEN_
else_block: ELSE OPEN_BRACE stmt* CLOSE_BRACE;
if_header: (if_h_op | if_h_bit | if_h_negatable | if_h_scn | operation);
if_h_negatable: NOT? (DEBUG | EDIT | VARIATION);
if_h_op: integer_like conditional_operator ( value_of | integer_like );
if_h_bit: NOT? integer_like OPEN_BRACKET INTEGER CLOSE_BRACKET;
if_h_op: primitive conditional_operator ( value_of | primitive );
if_h_bit: NOT? primitive OPEN_BRACKET INTEGER CLOSE_BRACKET;
if_h_scn: scn_var conditional_operator OPEN_BRACKET INTEGER COMMA INTEGER CLOSE_BRACKET;

switch_block: SWITCH OPEN_PAREN switch_header CLOSE_PAREN OPEN_BRACE (default | single_case_block)* CLOSE_BRACE;
message_switch_block: (MESSAGE_SWITCH_TALK | MESSAGE_SWITCH_MONOLOGUE) OPEN_PAREN integer_like CLOSE_PAREN OPEN_BRACE (default | single_case_block)* CLOSE_BRACE;
message_switch_block: (MESSAGE_SWITCH_TALK | MESSAGE_SWITCH_MONOLOGUE) OPEN_PAREN primitive CLOSE_PAREN OPEN_BRACE (default | single_case_block)* CLOSE_BRACE;
// Either a list of statements (regular switch+case/default) or just one string (message_Switch* + case/default)
single_case_block: CASE case_header COLON (stmt* | string);
default: DEFAULT COLON (stmt* | string);
single_case_block: CASE case_header COLON (stmt* | primitive);
default: DEFAULT COLON (stmt* | primitive);

switch_header: integer_like | operation | switch_h_scn | switch_h_random | switch_h_dungeon_mode | switch_h_sector;
switch_header: primitive | operation | switch_h_scn | switch_h_random | switch_h_dungeon_mode | switch_h_sector;
switch_h_scn: scn_var OPEN_BRACKET INTEGER CLOSE_BRACKET;
switch_h_random: RANDOM OPEN_PAREN integer_like CLOSE_PAREN;
switch_h_dungeon_mode: DUNGEON_MODE OPEN_PAREN integer_like CLOSE_PAREN;
switch_h_random: RANDOM OPEN_PAREN primitive CLOSE_PAREN;
switch_h_dungeon_mode: DUNGEON_MODE OPEN_PAREN primitive CLOSE_PAREN;
switch_h_sector: SECTOR OPEN_PAREN CLOSE_PAREN;

case_header: integer_like | case_h_menu | case_h_menu2 | case_h_op;
case_h_menu: MENU OPEN_PAREN string CLOSE_PAREN;
case_h_menu2: MENU2 OPEN_PAREN integer_like CLOSE_PAREN;
case_h_op: conditional_operator ( value_of | integer_like );
case_header: primitive | case_h_menu | case_h_menu2 | case_h_op;
case_h_menu: MENU OPEN_PAREN primitive CLOSE_PAREN;
case_h_menu2: MENU2 OPEN_PAREN primitive CLOSE_PAREN;
case_h_op: conditional_operator ( value_of | primitive );

forever_block: FOREVER OPEN_BRACE stmt* CLOSE_BRACE;
for_block: FOR OPEN_PAREN simple_stmt if_header ';' simple_stmt CLOSE_PAREN OPEN_BRACE stmt* CLOSE_BRACE;
while_block: WHILE NOT? OPEN_PAREN if_header CLOSE_PAREN OPEN_BRACE stmt* CLOSE_BRACE;

assignment: assignment_regular | assignment_clear | assignment_initial | assignment_reset | assignment_adv_log | assignment_dungeon_mode | assignment_scn;
assignment_regular: integer_like (OPEN_BRACKET INTEGER CLOSE_BRACKET)? assign_operator (integer_like | value_of);
assignment_clear: CLEAR integer_like;
assignment_initial: INIT integer_like;
assignment_regular: primitive (OPEN_BRACKET INTEGER CLOSE_BRACKET)? assign_operator (primitive | value_of);
assignment_clear: CLEAR primitive;
assignment_initial: INIT primitive;
assignment_reset: RESET (DUNGEON_RESULT | scn_var);
assignment_adv_log: ADVENTURE_LOG ASSIGN integer_like;
assignment_dungeon_mode: DUNGEON_MODE OPEN_PAREN integer_like CLOSE_PAREN ASSIGN integer_like;
assignment_scn: integer_like ASSIGN SCN OPEN_BRACKET INTEGER COMMA INTEGER CLOSE_BRACKET;
assignment_adv_log: ADVENTURE_LOG ASSIGN primitive;
assignment_dungeon_mode: DUNGEON_MODE OPEN_PAREN primitive CLOSE_PAREN ASSIGN primitive;
assignment_scn: primitive ASSIGN SCN OPEN_BRACKET INTEGER COMMA INTEGER CLOSE_BRACKET;

value_of: VALUE OPEN_PAREN integer_like CLOSE_PAREN;
scn_var: SCN OPEN_PAREN integer_like CLOSE_PAREN;
value_of: VALUE OPEN_PAREN primitive CLOSE_PAREN;
scn_var: SCN OPEN_PAREN primitive CLOSE_PAREN;

conditional_operator
: OP_FALSE
Expand Down Expand Up @@ -140,6 +140,7 @@ JUMP: 'jump';
CALL: 'call';

IMPORT: 'import';
CONST: 'const';
MACRO: 'macro';
IF: 'if';
ELSEIF: 'elseif';
Expand Down
6 changes: 4 additions & 2 deletions explorerscript/antlr/ExplorerScript.interp

Large diffs are not rendered by default.

242 changes: 122 additions & 120 deletions explorerscript/antlr/ExplorerScript.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -20,73 +20,74 @@ NOT=19
JUMP=20
CALL=21
IMPORT=22
MACRO=23
IF=24
ELSEIF=25
ELSE=26
FOREVER=27
WITH=28
SWITCH=29
RETURN=30
END=31
HOLD=32
CONTINUE=33
BREAK=34
BREAK_LOOP=35
VALUE=36
DEBUG=37
EDIT=38
VARIATION=39
RANDOM=40
SECTOR=41
DUNGEON_MODE=42
MENU2=43
MENU=44
CASE=45
DEFAULT=46
CLEAR=47
RESET=48
INIT=49
SCN=50
DUNGEON_RESULT=51
ADVENTURE_LOG=52
MESSAGE_SWITCH_TALK=53
MESSAGE_SWITCH_MONOLOGUE=54
WHILE=55
OPEN_BRACKET=56
CLOSE_BRACKET=57
STRING_LITERAL=58
MULTILINE_STRING_LITERAL=59
FOR_TARGET=60
CORO=61
DEF=62
FOR_ACTOR=63
FOR_OBJECT=64
FOR_PERFORMER=65
ALIAS=66
FOR=67
PREVIOUS=68
POSITION=69
IDENTIFIER=70
VARIABLE=71
MACRO_CALL=72
INTEGER=73
DECIMAL_INTEGER=74
OCT_INTEGER=75
HEX_INTEGER=76
BIN_INTEGER=77
OPEN_PAREN=78
CLOSE_PAREN=79
COMMA=80
COLON=81
PLUS=82
AT=83
PARAGRAPH=84
OPEN_BRACE=85
CLOSE_BRACE=86
DECIMAL=87
SKIP_=88
UNKNOWN_CHAR=89
CONST=23
MACRO=24
IF=25
ELSEIF=26
ELSE=27
FOREVER=28
WITH=29
SWITCH=30
RETURN=31
END=32
HOLD=33
CONTINUE=34
BREAK=35
BREAK_LOOP=36
VALUE=37
DEBUG=38
EDIT=39
VARIATION=40
RANDOM=41
SECTOR=42
DUNGEON_MODE=43
MENU2=44
MENU=45
CASE=46
DEFAULT=47
CLEAR=48
RESET=49
INIT=50
SCN=51
DUNGEON_RESULT=52
ADVENTURE_LOG=53
MESSAGE_SWITCH_TALK=54
MESSAGE_SWITCH_MONOLOGUE=55
WHILE=56
OPEN_BRACKET=57
CLOSE_BRACKET=58
STRING_LITERAL=59
MULTILINE_STRING_LITERAL=60
FOR_TARGET=61
CORO=62
DEF=63
FOR_ACTOR=64
FOR_OBJECT=65
FOR_PERFORMER=66
ALIAS=67
FOR=68
PREVIOUS=69
POSITION=70
IDENTIFIER=71
VARIABLE=72
MACRO_CALL=73
INTEGER=74
DECIMAL_INTEGER=75
OCT_INTEGER=76
HEX_INTEGER=77
BIN_INTEGER=78
OPEN_PAREN=79
CLOSE_PAREN=80
COMMA=81
COLON=82
PLUS=83
AT=84
PARAGRAPH=85
OPEN_BRACE=86
CLOSE_BRACE=87
DECIMAL=88
SKIP_=89
UNKNOWN_CHAR=90
';'=1
'FALSE'=2
'TRUE'=3
Expand All @@ -109,56 +110,57 @@ UNKNOWN_CHAR=89
'jump'=20
'call'=21
'import'=22
'macro'=23
'if'=24
'elseif'=25
'else'=26
'forever'=27
'with'=28
'switch'=29
'return'=30
'end'=31
'hold'=32
'continue'=33
'break'=34
'break_loop'=35
'value'=36
'debug'=37
'edit'=38
'variation'=39
'random'=40
'sector'=41
'dungeon_mode'=42
'menu2'=43
'menu'=44
'case'=45
'default'=46
'clear'=47
'reset'=48
'init'=49
'scn'=50
'dungeon_result'=51
'adventure_log'=52
'message_SwitchTalk'=53
'message_SwitchMonologue'=54
'while'=55
'['=56
']'=57
'coro'=61
'def'=62
'for_actor'=63
'for_object'=64
'for_performer'=65
'alias'=66
'for'=67
'previous'=68
'Position'=69
'('=78
')'=79
','=80
':'=81
'+'=82
'@'=83
'§'=84
'{'=85
'}'=86
'const'=23
'macro'=24
'if'=25
'elseif'=26
'else'=27
'forever'=28
'with'=29
'switch'=30
'return'=31
'end'=32
'hold'=33
'continue'=34
'break'=35
'break_loop'=36
'value'=37
'debug'=38
'edit'=39
'variation'=40
'random'=41
'sector'=42
'dungeon_mode'=43
'menu2'=44
'menu'=45
'case'=46
'default'=47
'clear'=48
'reset'=49
'init'=50
'scn'=51
'dungeon_result'=52
'adventure_log'=53
'message_SwitchTalk'=54
'message_SwitchMonologue'=55
'while'=56
'['=57
']'=58
'coro'=62
'def'=63
'for_actor'=64
'for_object'=65
'for_performer'=66
'alias'=67
'for'=68
'previous'=69
'Position'=70
'('=79
')'=80
','=81
':'=82
'+'=83
'@'=84
'§'=85
'{'=86
'}'=87
5 changes: 4 additions & 1 deletion explorerscript/antlr/ExplorerScriptLexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit 9f85146

Please sign in to comment.