Skip to content

Commit 9aa1e19

Browse files
authored
fix: keep track of pexpr data (#226)
When a non-fully-qualified name occurred directly as one of: * the entire body of a definition/theorem * an argument to notation (e.g., `a` in `a + 1`) mathport did not keep track of the pexpr containing the fully-qualified name, and as a result, would not in general translate it to the aligned Lean 4 version. Fix this by passing along the pexpr data.
1 parent a40154c commit 9aa1e19

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: Mathport/Syntax/Parse.lean

+8-8
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ mutual
295295
| none => throw s!"getBinder parse error, unknown kind {k}"
296296

297297
partial def getArg : AstId → M (Spanned Arg) :=
298-
withNode fun
299-
| "exprs", _, args => Arg.exprs <$> args.mapM getExpr
300-
| "binders", _, args => Arg.binders <$> args.mapM getBinder
301-
| k, v, args => if k.startsWith "binder"
298+
withNodeP fun
299+
| "exprs", _, args, _ => Arg.exprs <$> args.mapM getExpr
300+
| "binders", _, args, _ => Arg.binders <$> args.mapM getBinder
301+
| k, v, args, pexpr => if k.startsWith "binder"
302302
then Arg.binder <$> getBinder_aux k v args
303-
else Arg.expr <$> getExpr_aux k v args none
303+
else Arg.expr <$> getExpr_aux k v args pexpr
304304

305305
partial def getExpr_aux : String → Name → Array AstId → Option ExprId → M Expr
306306
| "notation", v, args, _ => match v with
@@ -554,9 +554,9 @@ def getAttr : AstId → M (Spanned Attribute) := withNode fun
554554

555555
open DeclVal in
556556
def getDeclVal : AstId → M (Spanned DeclVal) :=
557-
withNode fun
558-
| "eqns", _, args => eqns <$> args.mapM getArm
559-
| k, v, args => expr <$> getExpr_aux k v args none
557+
withNodeP fun
558+
| "eqns", _, args, _ => eqns <$> args.mapM getArm
559+
| k, v, args, pexpr => expr <$> getExpr_aux k v args pexpr
560560

561561
open Modifier in
562562
def getModifier : AstId → M (Spanned Modifier) := withNode fun

0 commit comments

Comments
 (0)