chore: use notationItem to remove $noprec* hack

This commit is contained in:
Leonardo de Moura 2020-06-10 16:58:55 -07:00
parent d9f71c6921
commit 77ce102baf
3 changed files with 125 additions and 94 deletions

View file

@ -320,7 +320,7 @@ match prec? with
fun stx =>
match_syntax stx with
| `(notation:$prec $items* => $rhs) => expandNotationAux stx prec items rhs
| `(notation $noprec* $items* => $rhs) => expandNotationAux stx none items rhs
| `(notation $items:notationItem* => $rhs) => expandNotationAux stx none items rhs
| _ => Macro.throwUnsupported
/- Convert `macro` argument into a `syntax` command item -/

View file

@ -320,7 +320,7 @@ match prec? with
fun stx =>
match_syntax stx with
| `(notation:$prec $items* => $rhs) => expandNotationAux stx prec items rhs
| `(notation $noprec* $items* => $rhs) => expandNotationAux stx none items rhs
| `(notation $items:notationItem* => $rhs) => expandNotationAux stx none items rhs
| _ => Macro.throwUnsupported
/- Convert `macro` argument into a `syntax` command item -/

View file

@ -13688,30 +13688,30 @@ return x_7;
lean_object* l_Lean_Elab_Command_expandNotation(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
uint8_t x_4; lean_object* x_53; uint8_t x_54;
x_53 = l_Lean_Parser_Command_notation___elambda__1___closed__2;
uint8_t x_4; lean_object* x_52; uint8_t x_53;
x_52 = l_Lean_Parser_Command_notation___elambda__1___closed__2;
lean_inc(x_1);
x_54 = l_Lean_Syntax_isOfKind(x_1, x_53);
if (x_54 == 0)
x_53 = l_Lean_Syntax_isOfKind(x_1, x_52);
if (x_53 == 0)
{
uint8_t x_55;
x_55 = 0;
x_4 = x_55;
goto block_52;
uint8_t x_54;
x_54 = 0;
x_4 = x_54;
goto block_51;
}
else
{
lean_object* x_56; lean_object* x_57; lean_object* x_58; uint8_t x_59;
x_56 = l_Lean_Syntax_getArgs(x_1);
x_57 = lean_array_get_size(x_56);
lean_object* x_55; lean_object* x_56; lean_object* x_57; uint8_t x_58;
x_55 = l_Lean_Syntax_getArgs(x_1);
x_56 = lean_array_get_size(x_55);
lean_dec(x_55);
x_57 = lean_unsigned_to_nat(5u);
x_58 = lean_nat_dec_eq(x_56, x_57);
lean_dec(x_56);
x_58 = lean_unsigned_to_nat(5u);
x_59 = lean_nat_dec_eq(x_57, x_58);
lean_dec(x_57);
x_4 = x_59;
goto block_52;
x_4 = x_58;
goto block_51;
}
block_52:
block_51:
{
if (x_4 == 0)
{
@ -13726,109 +13726,140 @@ return x_6;
}
else
{
lean_object* x_7; lean_object* x_8; uint8_t x_9; lean_object* x_46; uint8_t x_47;
lean_object* x_7; lean_object* x_8; lean_object* x_9; uint8_t x_10; uint8_t x_11;
x_7 = lean_unsigned_to_nat(1u);
x_8 = l_Lean_Syntax_getArg(x_1, x_7);
x_46 = l_Lean_nullKind___closed__2;
x_9 = l_Lean_nullKind___closed__2;
lean_inc(x_8);
x_47 = l_Lean_Syntax_isOfKind(x_8, x_46);
if (x_47 == 0)
x_10 = l_Lean_Syntax_isOfKind(x_8, x_9);
if (x_10 == 0)
{
uint8_t x_48;
x_48 = 0;
x_9 = x_48;
goto block_45;
uint8_t x_47;
x_47 = 0;
x_11 = x_47;
goto block_46;
}
else
{
lean_object* x_49; lean_object* x_50; uint8_t x_51;
x_49 = l_Lean_Syntax_getArgs(x_8);
x_50 = lean_array_get_size(x_49);
lean_object* x_48; lean_object* x_49; uint8_t x_50;
x_48 = l_Lean_Syntax_getArgs(x_8);
x_49 = lean_array_get_size(x_48);
lean_dec(x_48);
x_50 = lean_nat_dec_eq(x_49, x_7);
lean_dec(x_49);
x_51 = lean_nat_dec_eq(x_50, x_7);
lean_dec(x_50);
x_9 = x_51;
goto block_45;
x_11 = x_50;
goto block_46;
}
block_45:
block_46:
{
if (x_9 == 0)
if (x_11 == 0)
{
lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16;
if (x_10 == 0)
{
lean_object* x_12; lean_object* x_13;
lean_dec(x_8);
x_10 = lean_unsigned_to_nat(2u);
x_11 = l_Lean_Syntax_getArg(x_1, x_10);
x_12 = lean_unsigned_to_nat(4u);
x_13 = l_Lean_Syntax_getArg(x_1, x_12);
x_14 = l_Lean_Syntax_getArgs(x_11);
lean_dec(x_11);
x_15 = lean_box(0);
x_16 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_15, x_14, x_13, x_2, x_3);
lean_dec(x_2);
lean_dec(x_1);
return x_16;
x_12 = lean_box(1);
x_13 = lean_alloc_ctor(1, 2, 0);
lean_ctor_set(x_13, 0, x_12);
lean_ctor_set(x_13, 1, x_3);
return x_13;
}
else
{
lean_object* x_17; lean_object* x_18; lean_object* x_19; uint8_t x_20;
x_17 = lean_unsigned_to_nat(0u);
x_18 = l_Lean_Syntax_getArg(x_8, x_17);
lean_object* x_14; lean_object* x_15; lean_object* x_16; uint8_t x_17;
x_14 = l_Lean_Syntax_getArgs(x_8);
lean_dec(x_8);
x_19 = l_Lean_Parser_precedence___elambda__1___closed__2;
lean_inc(x_18);
x_20 = l_Lean_Syntax_isOfKind(x_18, x_19);
if (x_20 == 0)
x_15 = lean_array_get_size(x_14);
lean_dec(x_14);
x_16 = lean_unsigned_to_nat(0u);
x_17 = lean_nat_dec_eq(x_15, x_16);
lean_dec(x_15);
if (x_17 == 0)
{
lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27;
lean_dec(x_18);
x_21 = lean_unsigned_to_nat(2u);
x_22 = l_Lean_Syntax_getArg(x_1, x_21);
x_23 = lean_unsigned_to_nat(4u);
x_24 = l_Lean_Syntax_getArg(x_1, x_23);
x_25 = l_Lean_Syntax_getArgs(x_22);
lean_dec(x_22);
x_26 = lean_box(0);
x_27 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_26, x_25, x_24, x_2, x_3);
lean_object* x_18; lean_object* x_19;
lean_dec(x_2);
lean_dec(x_1);
return x_27;
x_18 = lean_box(1);
x_19 = lean_alloc_ctor(1, 2, 0);
lean_ctor_set(x_19, 0, x_18);
lean_ctor_set(x_19, 1, x_3);
return x_19;
}
else
{
lean_object* x_28; lean_object* x_29; lean_object* x_30; uint8_t x_31;
x_28 = l_Lean_Syntax_getArgs(x_18);
x_29 = lean_array_get_size(x_28);
lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26;
x_20 = lean_unsigned_to_nat(2u);
x_21 = l_Lean_Syntax_getArg(x_1, x_20);
x_22 = lean_unsigned_to_nat(4u);
x_23 = l_Lean_Syntax_getArg(x_1, x_22);
x_24 = l_Lean_Syntax_getArgs(x_21);
lean_dec(x_21);
x_25 = lean_box(0);
x_26 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_25, x_24, x_23, x_2, x_3);
lean_dec(x_1);
return x_26;
}
}
}
else
{
lean_object* x_27; lean_object* x_28; lean_object* x_29; uint8_t x_30;
x_27 = lean_unsigned_to_nat(0u);
x_28 = l_Lean_Syntax_getArg(x_8, x_27);
lean_dec(x_8);
x_29 = l_Lean_Parser_precedence___elambda__1___closed__2;
lean_inc(x_28);
x_30 = l_Lean_Syntax_isOfKind(x_28, x_29);
if (x_30 == 0)
{
lean_object* x_31; lean_object* x_32;
lean_dec(x_28);
x_30 = lean_unsigned_to_nat(2u);
x_31 = lean_nat_dec_eq(x_29, x_30);
lean_dec(x_29);
if (x_31 == 0)
{
lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; lean_object* x_36; lean_object* x_37;
lean_dec(x_18);
x_32 = l_Lean_Syntax_getArg(x_1, x_30);
x_33 = lean_unsigned_to_nat(4u);
x_34 = l_Lean_Syntax_getArg(x_1, x_33);
x_35 = l_Lean_Syntax_getArgs(x_32);
lean_dec(x_32);
x_36 = lean_box(0);
x_37 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_36, x_35, x_34, x_2, x_3);
lean_dec(x_2);
lean_dec(x_1);
return x_37;
x_31 = lean_box(1);
x_32 = lean_alloc_ctor(1, 2, 0);
lean_ctor_set(x_32, 0, x_31);
lean_ctor_set(x_32, 1, x_3);
return x_32;
}
else
{
lean_object* x_38; lean_object* x_39; lean_object* x_40; lean_object* x_41; lean_object* x_42; lean_object* x_43; lean_object* x_44;
x_38 = l_Lean_Syntax_getArg(x_18, x_7);
lean_dec(x_18);
x_39 = l_Lean_Syntax_getArg(x_1, x_30);
x_40 = lean_unsigned_to_nat(4u);
x_41 = l_Lean_Syntax_getArg(x_1, x_40);
x_42 = l_Lean_Syntax_getArgs(x_39);
lean_dec(x_39);
x_43 = lean_alloc_ctor(1, 1, 0);
lean_ctor_set(x_43, 0, x_38);
x_44 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_43, x_42, x_41, x_2, x_3);
lean_object* x_33; lean_object* x_34; lean_object* x_35; uint8_t x_36;
x_33 = l_Lean_Syntax_getArgs(x_28);
x_34 = lean_array_get_size(x_33);
lean_dec(x_33);
x_35 = lean_unsigned_to_nat(2u);
x_36 = lean_nat_dec_eq(x_34, x_35);
lean_dec(x_34);
if (x_36 == 0)
{
lean_object* x_37; lean_object* x_38;
lean_dec(x_28);
lean_dec(x_2);
lean_dec(x_1);
return x_44;
x_37 = lean_box(1);
x_38 = lean_alloc_ctor(1, 2, 0);
lean_ctor_set(x_38, 0, x_37);
lean_ctor_set(x_38, 1, x_3);
return x_38;
}
else
{
lean_object* x_39; lean_object* x_40; lean_object* x_41; lean_object* x_42; lean_object* x_43; lean_object* x_44; lean_object* x_45;
x_39 = l_Lean_Syntax_getArg(x_28, x_7);
lean_dec(x_28);
x_40 = l_Lean_Syntax_getArg(x_1, x_35);
x_41 = lean_unsigned_to_nat(4u);
x_42 = l_Lean_Syntax_getArg(x_1, x_41);
x_43 = l_Lean_Syntax_getArgs(x_40);
lean_dec(x_40);
x_44 = lean_alloc_ctor(1, 1, 0);
lean_ctor_set(x_44, 0, x_39);
x_45 = l___private_Lean_Elab_Syntax_7__expandNotationAux(x_1, x_44, x_43, x_42, x_2, x_3);
lean_dec(x_1);
return x_45;
}
}
}