chore: raw syntax kind accesses

Sometimes just checking the kind simply is the simplest solution.
This commit is contained in:
Sebastian Ullrich 2022-06-24 14:10:04 +02:00
parent c2166fc602
commit c3585dbbbb
5 changed files with 7 additions and 7 deletions

View file

@ -108,7 +108,7 @@ private def elabParserMacroAux (prec e : TSyntax `term) (withAnonymousAntiquot :
@[builtinTermElab «leading_parser»] def elabLeadingParserMacro : TermElab :=
adaptExpander fun stx => match stx with
| `(leading_parser $[: $prec?]? $[(withAnonymousAntiquot := $anon?)]? $e) =>
elabParserMacroAux (prec?.getD (quote Parser.maxPrec)) e (anon?.all (·.isOfKind ``Parser.Term.trueVal))
elabParserMacroAux (prec?.getD (quote Parser.maxPrec)) e (anon?.all (·.raw.isOfKind ``Parser.Term.trueVal))
| _ => throwUnsupportedSyntax
private def elabTParserMacroAux (prec lhsPrec e : TSyntax `term) : TermElabM Syntax := do

View file

@ -545,8 +545,8 @@ def match_syntax.expand (stx : Syntax) : TermElabM Syntax := do
match stx with
| `(match $[$discrs:term],* with $[| $[$patss],* => $rhss]*) => do
if !patss.any (·.any (fun
| `($_@$pat) => pat.isQuot
| pat => pat.isQuot)) then
| `($_@$pat) => pat.raw.isQuot
| pat => pat.raw.isQuot)) then
-- no quotations => fall back to regular `match`
throwUnsupportedSyntax
let stx ← compileStxMatch discrs.toList (patss.map (·.toList) |>.zip rhss).toList

View file

@ -343,7 +343,7 @@ def checkRuleKind (given expected : SyntaxNodeKind) : Bool :=
def inferMacroRulesAltKind : TSyntax ``matchAlt → CommandElabM SyntaxNodeKind
| `(matchAltExpr| | $pat:term => $_) => do
if !pat.isQuot then
if !pat.raw.isQuot then
throwUnsupportedSyntax
let quoted := getQuotContent pat
pure quoted.getKind

View file

@ -1102,7 +1102,7 @@ private def isExplicitApp (stx : Syntax) : Bool :=
Example: `fun {α} (a : α) => a` -/
private def isLambdaWithImplicit (stx : Syntax) : Bool :=
match stx with
| `(fun $binders* => $_) => binders.any fun b => b.isOfKind ``Lean.Parser.Term.implicitBinder || b.isOfKind `Lean.Parser.Term.instBinder
| `(fun $binders* => $_) => binders.raw.any fun b => b.isOfKind ``Lean.Parser.Term.implicitBinder || b.isOfKind `Lean.Parser.Term.instBinder
| _ => false
private partial def dropTermParens : Syntax → Syntax := fun stx =>

View file

@ -166,7 +166,7 @@ def delabAppExplicit : Delab := do
let (fnStx, _, argStxs) ← withAppFnArgs
(do
let stx ← withOptionAtCurrPos `pp.tagAppFns tagAppFn delabAppFn
let needsExplicit := stx.getKind != ``Lean.Parser.Term.explicit
let needsExplicit := stx.raw.getKind != ``Lean.Parser.Term.explicit
let stx ← if needsExplicit then `(@$stx) else pure stx
pure (stx, paramKinds.toList, #[]))
(fun ⟨fnStx, paramKinds, argStxs⟩ => do
@ -705,7 +705,7 @@ def delabNamedPattern : Delab := do
let p ← withAppFn $ withAppArg delab
-- TODO: we should hide `h` if it has an inaccessible name and is not used in the rhs
let h ← withAppArg delab
guard x.isIdent
guard x.raw.isIdent
`($x:ident@$h:ident:$p:term)
-- Sigma and PSigma delaborators