commit 9748cf0b895c37ac1fcc9adb74e9bbe278d533cb
parent 13d70d8ba0235a3c20647c12dbf18d25032e1276
Author: erai <erai@omiltem.net>
Date: Fri, 28 Mar 2025 02:50:05 +0000
fix typo
Diffstat:
M | cc0.c | | | 477 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- |
M | cc3.om | | | 2 | +- |
2 files changed, 473 insertions(+), 6 deletions(-)
diff --git a/cc0.c b/cc0.c
@@ -234,8 +234,24 @@ u zpeg_P_index_expr();
u zpeg_P_int();
u zpeg_P_label_stmt();
u zpeg_P_lalr();
+u zpeg_P_lalr_alternative();
+u zpeg_P_lalr_grammar();
+u zpeg_P_lalr_op();
+u zpeg_P_lalr_pattern();
+u zpeg_P_lalr_primary();
+u zpeg_P_lalr_rule();
+u zpeg_P_lalr_suffix();
u zpeg_P_le_op();
u zpeg_P_lex();
+u zpeg_P_lexer_alternative();
+u zpeg_P_lexer_charset();
+u zpeg_P_lexer_dot();
+u zpeg_P_lexer_op();
+u zpeg_P_lexer_pattern();
+u zpeg_P_lexer_primary();
+u zpeg_P_lexer_rule();
+u zpeg_P_lexer_spec();
+u zpeg_P_lexer_suffix();
u zpeg_P_loop();
u zpeg_P_loop_stmt();
u zpeg_P_lsh_op();
@@ -592,7 +608,39 @@ b210: if (vtag != 105UL) goto b212;
return (u)"P_peg_call";
b212: if (vtag != 106UL) goto b214;
return (u)"P_peg_identifier";
-b214: return 0UL;
+b214: if (vtag != 107UL) goto b216;
+ return (u)"P_lalr_primary";
+b216: if (vtag != 108UL) goto b218;
+ return (u)"P_lalr_op";
+b218: if (vtag != 109UL) goto b220;
+ return (u)"P_lalr_suffix";
+b220: if (vtag != 110UL) goto b222;
+ return (u)"P_lalr_alternative";
+b222: if (vtag != 111UL) goto b224;
+ return (u)"P_lalr_pattern";
+b224: if (vtag != 112UL) goto b226;
+ return (u)"P_lalr_rule";
+b226: if (vtag != 113UL) goto b228;
+ return (u)"P_lalr_grammar";
+b228: if (vtag != 114UL) goto b230;
+ return (u)"P_lexer_dot";
+b230: if (vtag != 115UL) goto b232;
+ return (u)"P_lexer_op";
+b232: if (vtag != 116UL) goto b234;
+ return (u)"P_lexer_charset";
+b234: if (vtag != 117UL) goto b236;
+ return (u)"P_lexer_primary";
+b236: if (vtag != 118UL) goto b238;
+ return (u)"P_lexer_suffix";
+b238: if (vtag != 119UL) goto b240;
+ return (u)"P_lexer_alternative";
+b240: if (vtag != 120UL) goto b242;
+ return (u)"P_lexer_pattern";
+b242: if (vtag != 121UL) goto b244;
+ return (u)"P_lexer_rule";
+b244: if (vtag != 122UL) goto b246;
+ return (u)"P_lexer_spec";
+b246: return 0UL;
}
u z_start(u vargc, u vargv, u venvp) {
u v3 = 0;
@@ -28237,6 +28285,8 @@ u zpeg_P_grammar(u vc) {
u v5 = 0;
u v6 = 0;
u v7 = 0;
+ u v8 = 0;
+ u v9 = 0;
zenter(vc, 0UL);
v1 = zpeg_P_sp(vc);
if (v1 == 0UL) goto b1;
@@ -28263,15 +28313,23 @@ b22: zchoice(vc);
v6 = zpeg_P_peg_grammar(vc);
if (v6 == 0UL) goto b26;
goto b9;
-b26: zfail(vc);
+b26: zchoice(vc);
+ v7 = zpeg_P_lalr_grammar(vc);
+ if (v7 == 0UL) goto b30;
+ goto b9;
+b30: zchoice(vc);
+ v8 = zpeg_P_lexer_spec(vc);
+ if (v8 == 0UL) goto b34;
+ goto b9;
+b34: zfail(vc);
zchoice(vc);
- v7 = zany(vc);
- if (v7 == 0UL) goto b33;
+ v9 = zany(vc);
+ if (v9 == 0UL) goto b41;
zfail(vc);
zfail(vc);
b1: zfail(vc);
return 0UL;
-b33: zleave(vc, 0UL);
+b41: zleave(vc, 0UL);
return 1UL;
}
u zpeg_P_gt_op(u vc) {
@@ -28463,6 +28521,176 @@ b1: zfail(vc);
b5: zleave(vc, 90UL);
return 1UL;
}
+u zpeg_P_lalr_alternative(u vc) {
+ u v1 = 0;
+ zenter(vc, 110UL);
+b3: zchoice(vc);
+ v1 = zpeg_P_lalr_suffix(vc);
+ if (v1 == 0UL) goto b4;
+ zcommit(vc);
+ goto b3;
+b4: zleave(vc, 110UL);
+ return 1UL;
+}
+u zpeg_P_lalr_grammar(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ u v8 = 0;
+ zenter(vc, 113UL);
+ v1 = zliteral(vc, (u)"lalr");
+ if (v1 == 0UL) goto b1;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b1;
+ v3 = zliteral(vc, (u)"{");
+ if (v3 == 0UL) goto b1;
+ v4 = zpeg_P_sp(vc);
+ if (v4 == 0UL) goto b1;
+ v5 = zpeg_P_lalr_rule(vc);
+ if (v5 == 0UL) goto b1;
+b13: zchoice(vc);
+ v6 = zpeg_P_lalr_rule(vc);
+ if (v6 == 0UL) goto b14;
+ zcommit(vc);
+ goto b13;
+b14: v7 = zliteral(vc, (u)"}");
+ if (v7 == 0UL) goto b1;
+ v8 = zpeg_P_sp(vc);
+ if (v8 == 0UL) goto b1;
+ zleave(vc, 113UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lalr_op(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ zenter(vc, 108UL);
+ zchoice(vc);
+ v1 = zliteral(vc, (u)"*");
+ if (v1 == 0UL) goto b5;
+b4: zcommit(vc);
+ zleave(vc, 108UL);
+ return 1UL;
+b5: zchoice(vc);
+ v2 = zliteral(vc, (u)"+");
+ if (v2 == 0UL) goto b9;
+ goto b4;
+b9: zchoice(vc);
+ v3 = zliteral(vc, (u)"?");
+ if (v3 == 0UL) goto b13;
+ goto b4;
+b13: zfail(vc);
+ zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lalr_pattern(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ zenter(vc, 111UL);
+ v1 = zpeg_P_lalr_alternative(vc);
+ if (v1 == 0UL) goto b1;
+b5: zchoice(vc);
+ v2 = zliteral(vc, (u)"|");
+ if (v2 == 0UL) goto b6;
+ v3 = zpeg_P_sp(vc);
+ if (v3 == 0UL) goto b6;
+ v4 = zpeg_P_lalr_alternative(vc);
+ if (v4 == 0UL) goto b6;
+ zcommit(vc);
+ goto b5;
+b6: zleave(vc, 111UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lalr_primary(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ zenter(vc, 107UL);
+ zchoice(vc);
+ v1 = zliteral(vc, (u)"(");
+ if (v1 == 0UL) goto b5;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b5;
+ v3 = zpeg_P_lalr_pattern(vc);
+ if (v3 == 0UL) goto b5;
+ v4 = zliteral(vc, (u)")");
+ if (v4 == 0UL) goto b5;
+ v5 = zpeg_P_sp(vc);
+ if (v5 == 0UL) goto b5;
+b4: zcommit(vc);
+ zleave(vc, 107UL);
+ return 1UL;
+b5: zchoice(vc);
+ v6 = zpeg_P_ident(vc);
+ if (v6 == 0UL) goto b17;
+ v7 = zpeg_P_sp(vc);
+ if (v7 == 0UL) goto b17;
+ goto b4;
+b17: zfail(vc);
+ zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lalr_rule(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ zenter(vc, 112UL);
+ v1 = zpeg_P_ident(vc);
+ if (v1 == 0UL) goto b1;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b1;
+ v3 = zliteral(vc, (u)"=");
+ if (v3 == 0UL) goto b1;
+ v4 = zpeg_P_sp(vc);
+ if (v4 == 0UL) goto b1;
+ v5 = zpeg_P_lalr_pattern(vc);
+ if (v5 == 0UL) goto b1;
+ v6 = zliteral(vc, (u)";");
+ if (v6 == 0UL) goto b1;
+ v7 = zpeg_P_sp(vc);
+ if (v7 == 0UL) goto b1;
+ zleave(vc, 112UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lalr_suffix(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ zenter(vc, 109UL);
+ v1 = zpeg_P_lalr_primary(vc);
+ if (v1 == 0UL) goto b1;
+b5: zchoice(vc);
+ v2 = zpeg_P_lalr_op(vc);
+ if (v2 == 0UL) goto b6;
+ v3 = zpeg_P_sp(vc);
+ if (v3 == 0UL) goto b6;
+ zcommit(vc);
+ goto b5;
+b6: zleave(vc, 109UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
u zpeg_P_le_op(u vc) {
u v1 = 0;
zenter(vc, 31UL);
@@ -28489,6 +28717,245 @@ b1: zfail(vc);
b5: zleave(vc, 89UL);
return 1UL;
}
+u zpeg_P_lexer_alternative(u vc) {
+ u v1 = 0;
+ zenter(vc, 119UL);
+b3: zchoice(vc);
+ v1 = zpeg_P_lexer_suffix(vc);
+ if (v1 == 0UL) goto b4;
+ zcommit(vc);
+ goto b3;
+b4: zleave(vc, 119UL);
+ return 1UL;
+}
+u zpeg_P_lexer_charset(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ zenter(vc, 116UL);
+ v1 = zliteral(vc, (u)"[[");
+ if (v1 == 0UL) goto b1;
+b5: zchoice(vc);
+ zchoice(vc);
+ zchoice(vc);
+ v2 = zliteral(vc, (u)"]");
+ if (v2 == 0UL) goto b12;
+ zfail(vc);
+ zfail(vc);
+b10: zchoice(vc);
+ v5 = zliteral(vc, (u)"\134");
+ if (v5 == 0UL) goto b26;
+ v6 = zany(vc);
+ if (v6 == 0UL) goto b26;
+b9: zcommit(vc);
+ zcommit(vc);
+ goto b5;
+b26: zfail(vc);
+ v7 = zliteral(vc, (u)"]]");
+ if (v7 == 0UL) goto b1;
+ zleave(vc, 116UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+b12: zchoice(vc);
+ v3 = zliteral(vc, (u)"\134");
+ if (v3 == 0UL) goto b18;
+ zfail(vc);
+ zfail(vc);
+ goto b10;
+b18: v4 = zany(vc);
+ if (v4 == 0UL) goto b10;
+ goto b9;
+}
+u zpeg_P_lexer_dot(u vc) {
+ u v1 = 0;
+ zenter(vc, 114UL);
+ v1 = zliteral(vc, (u)".");
+ if (v1 == 0UL) goto b1;
+ zleave(vc, 114UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_op(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ zenter(vc, 115UL);
+ zchoice(vc);
+ v1 = zliteral(vc, (u)"*");
+ if (v1 == 0UL) goto b5;
+b4: zcommit(vc);
+ zleave(vc, 115UL);
+ return 1UL;
+b5: zchoice(vc);
+ v2 = zliteral(vc, (u)"+");
+ if (v2 == 0UL) goto b9;
+ goto b4;
+b9: zchoice(vc);
+ v3 = zliteral(vc, (u)"?");
+ if (v3 == 0UL) goto b13;
+ goto b4;
+b13: zfail(vc);
+ zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_pattern(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ zenter(vc, 120UL);
+ v1 = zpeg_P_lexer_alternative(vc);
+ if (v1 == 0UL) goto b1;
+b5: zchoice(vc);
+ v2 = zliteral(vc, (u)"|");
+ if (v2 == 0UL) goto b6;
+ v3 = zpeg_P_sp(vc);
+ if (v3 == 0UL) goto b6;
+ v4 = zpeg_P_lexer_alternative(vc);
+ if (v4 == 0UL) goto b6;
+ zcommit(vc);
+ goto b5;
+b6: zleave(vc, 120UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_primary(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ u v8 = 0;
+ u v9 = 0;
+ u v10 = 0;
+ u v11 = 0;
+ zenter(vc, 117UL);
+ zchoice(vc);
+ v1 = zliteral(vc, (u)"(");
+ if (v1 == 0UL) goto b5;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b5;
+ v3 = zpeg_P_lexer_pattern(vc);
+ if (v3 == 0UL) goto b5;
+ v4 = zliteral(vc, (u)")");
+ if (v4 == 0UL) goto b5;
+ v5 = zpeg_P_sp(vc);
+ if (v5 == 0UL) goto b5;
+b4: zcommit(vc);
+ zleave(vc, 117UL);
+ return 1UL;
+b5: zchoice(vc);
+ v6 = zpeg_P_lexer_dot(vc);
+ if (v6 == 0UL) goto b17;
+ v7 = zpeg_P_sp(vc);
+ if (v7 == 0UL) goto b17;
+ goto b4;
+b17: zchoice(vc);
+ v8 = zpeg_P_str(vc);
+ if (v8 == 0UL) goto b23;
+ v9 = zpeg_P_sp(vc);
+ if (v9 == 0UL) goto b23;
+ goto b4;
+b23: zchoice(vc);
+ v10 = zpeg_P_lexer_charset(vc);
+ if (v10 == 0UL) goto b29;
+ v11 = zpeg_P_sp(vc);
+ if (v11 == 0UL) goto b29;
+ goto b4;
+b29: zfail(vc);
+ zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_rule(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ zenter(vc, 121UL);
+ v1 = zpeg_P_ident(vc);
+ if (v1 == 0UL) goto b1;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b1;
+ v3 = zliteral(vc, (u)"=");
+ if (v3 == 0UL) goto b1;
+ v4 = zpeg_P_sp(vc);
+ if (v4 == 0UL) goto b1;
+ v5 = zpeg_P_lexer_pattern(vc);
+ if (v5 == 0UL) goto b1;
+ v6 = zliteral(vc, (u)";");
+ if (v6 == 0UL) goto b1;
+ v7 = zpeg_P_sp(vc);
+ if (v7 == 0UL) goto b1;
+ zleave(vc, 121UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_spec(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ u v4 = 0;
+ u v5 = 0;
+ u v6 = 0;
+ u v7 = 0;
+ u v8 = 0;
+ zenter(vc, 122UL);
+ v1 = zliteral(vc, (u)"lexer");
+ if (v1 == 0UL) goto b1;
+ v2 = zpeg_P_sp(vc);
+ if (v2 == 0UL) goto b1;
+ v3 = zliteral(vc, (u)"{");
+ if (v3 == 0UL) goto b1;
+ v4 = zpeg_P_sp(vc);
+ if (v4 == 0UL) goto b1;
+ v5 = zpeg_P_lexer_rule(vc);
+ if (v5 == 0UL) goto b1;
+b13: zchoice(vc);
+ v6 = zpeg_P_lexer_rule(vc);
+ if (v6 == 0UL) goto b14;
+ zcommit(vc);
+ goto b13;
+b14: v7 = zliteral(vc, (u)"}");
+ if (v7 == 0UL) goto b1;
+ v8 = zpeg_P_sp(vc);
+ if (v8 == 0UL) goto b1;
+ zleave(vc, 122UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
+u zpeg_P_lexer_suffix(u vc) {
+ u v1 = 0;
+ u v2 = 0;
+ u v3 = 0;
+ zenter(vc, 118UL);
+ v1 = zpeg_P_lexer_primary(vc);
+ if (v1 == 0UL) goto b1;
+b5: zchoice(vc);
+ v2 = zpeg_P_lexer_op(vc);
+ if (v2 == 0UL) goto b6;
+ v3 = zpeg_P_sp(vc);
+ if (v3 == 0UL) goto b6;
+ zcommit(vc);
+ goto b5;
+b6: zleave(vc, 118UL);
+ return 1UL;
+b1: zfail(vc);
+ return 0UL;
+}
u zpeg_P_loop(u vc) {
u v1 = 0;
u v2 = 0;
diff --git a/cc3.om b/cc3.om
@@ -160,7 +160,7 @@ peg_grammar {
lexer_dot = ".";
lexer_op = "*" / "+" / "?";
lexer_charset = "[[" ( !"]" !"\\" . / "\\" . )* "]]";
- lexer_primary = "(" sp lexer_pattern ")" sp / lexer_dot sp / str sp / lexer_dot sp / lexer_charset sp;
+ lexer_primary = "(" sp lexer_pattern ")" sp / lexer_dot sp / str sp / lexer_charset sp;
lexer_suffix = lexer_primary (lexer_op sp)*;
lexer_alternative = lexer_suffix*;
lexer_pattern = lexer_alternative ("|" sp lexer_alternative)*;