Skip to content

Commit

Permalink
Add syntax configuration code:continue. Use labelled loops for Zig.
Browse files Browse the repository at this point in the history
  • Loading branch information
skvadrik committed Sep 24, 2024
1 parent 6de502d commit 72a7d1b
Show file tree
Hide file tree
Showing 54 changed files with 3,714 additions and 3,624 deletions.
2 changes: 2 additions & 0 deletions bootstrap/src/default_syntax_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ const char* DEFAULT_SYNTAX_C =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue;\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:enum =\n"
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/src/default_syntax_d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ const char* DEFAULT_SYNTAX_D =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:enum =\n"
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/src/default_syntax_go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ const char* DEFAULT_SYNTAX_GO =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = topindent \"goto \" label nl;\n"
"\n"
"code:enum =\n"
Expand Down
10 changes: 6 additions & 4 deletions bootstrap/src/default_syntax_haskell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ const char* DEFAULT_SYNTAX_HASKELL =
"\n"
"code:switch_case_default = \"True\";\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:continue = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum =\n"
" \"data \" name \" = \"\n"
" [elem{0:-2}: elem \" | \"]\n"
Expand All @@ -221,10 +227,6 @@ const char* DEFAULT_SYNTAX_HASKELL =
"\n"
"code:enum_elem = name;\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/src/default_syntax_java.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ const char* DEFAULT_SYNTAX_JAVA =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum = [elem: topindent \"public static final \" type \" \" elem \" = \" init \";\" nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"code:fndef = <undefined>;\n"
"code:fncall = <undefined>;\n"
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/src/default_syntax_js.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ const char* DEFAULT_SYNTAX_JS =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \" = \" init nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"code:fndef = <undefined>;\n"
"code:fncall = <undefined>;\n"
Expand Down
10 changes: 6 additions & 4 deletions bootstrap/src/default_syntax_ocaml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ const char* DEFAULT_SYNTAX_OCAML =
"\n"
"code:switch_case_default = \"_\";\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:continue = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum =\n"
" \"type \" name \" = \"\n"
" [elem{0}: elem]\n"
Expand All @@ -228,10 +234,6 @@ const char* DEFAULT_SYNTAX_OCAML =
"\n"
"code:enum_elem = name;\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/src/default_syntax_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ const char* DEFAULT_SYNTAX_PYTHON =
" topindent \"while True:\" nl\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:continue = topindent \"continue\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum = [elem: elem \" = \" init nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/src/default_syntax_rust.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ const char* DEFAULT_SYNTAX_RUST =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \": \" type \" = \" init \";\" nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/src/default_syntax_v.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ const char* DEFAULT_SYNTAX_V =
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = topindent \"unsafe { goto \" label \" }\" nl;\n"
"\n"
"// Don't use enum in loop/switch mode, as conditions are assigned to `yystate`.\n"
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/src/default_syntax_zig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const char* DEFAULT_SYNTAX_ZIG =
"conf:indent:top = 0;\n"
"conf:label:prefix = \"yy\"; // used to generate function names\n"
"conf:label:yyfill = \"\";\n"
"conf:label:yyloop = \"\";\n"
"conf:label:yyloop = \"yyl\";\n"
"conf:label:yyNext = \"\";\n"
"conf:label:start = 0;\n"
"\n"
Expand Down Expand Up @@ -215,10 +215,12 @@ const char* DEFAULT_SYNTAX_ZIG =
"code:switch_case_default = \"else\";\n"
"\n"
"code:loop =\n"
" topindent \"while (true) {\" nl\n"
" topindent (loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (loop_label ? \" :\" label) \";\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \": \" type \" = \" init \";\" nl];\n"
Expand Down
Loading

0 comments on commit 72a7d1b

Please sign in to comment.