chore: add Macro.State.Extra
This commit is contained in:
parent
1151ef9af0
commit
0838b95105
2 changed files with 9 additions and 1 deletions
|
|
@ -2042,8 +2042,15 @@ inductive Exception where
|
|||
| error : Syntax → String → Exception
|
||||
| unsupportedSyntax : Exception
|
||||
|
||||
constant State.ExtraPointed : PointedType.{0}
|
||||
|
||||
def State.Extra : Type := State.ExtraPointed.type
|
||||
instance : Inhabited State.Extra where
|
||||
default := State.ExtraPointed.val
|
||||
|
||||
structure State where
|
||||
macroScope : MacroScope
|
||||
extra : State.Extra
|
||||
deriving Inhabited
|
||||
|
||||
end Macro
|
||||
|
|
|
|||
|
|
@ -161,7 +161,8 @@ private def expandMacro? (env : Environment) (stx : Syntax) : MacroM (Option Syn
|
|||
currMacroScope := ← MonadMacroAdapter.getCurrMacroScope,
|
||||
mainModule := env.mainModule,
|
||||
currRecDepth := ← MonadRecDepth.getRecDepth,
|
||||
maxRecDepth := ← MonadRecDepth.getMaxRecDepth } { macroScope := (← MonadMacroAdapter.getNextMacroScope) } with
|
||||
maxRecDepth := ← MonadRecDepth.getMaxRecDepth }
|
||||
{ macroScope := (← MonadMacroAdapter.getNextMacroScope), extra := arbitrary } with
|
||||
| EStateM.Result.error Macro.Exception.unsupportedSyntax _ => throwUnsupportedSyntax
|
||||
| EStateM.Result.error (Macro.Exception.error ref msg) _ => throwErrorAt ref msg
|
||||
| EStateM.Result.ok a s => MonadMacroAdapter.setNextMacroScope s.macroScope; pure a
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue