Skip to content

Commit

Permalink
chore: move includeStr elaborator
Browse files Browse the repository at this point in the history
  • Loading branch information
Vtec234 authored and leodemoura committed Aug 6, 2022
1 parent bbe11d6 commit 962a4bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/Lean/Elab.lean
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ import Lean.Elab.BuiltinCommand
import Lean.Elab.RecAppSyntax
import Lean.Elab.Eval
import Lean.Elab.Calc
import Lean.Elab.IncludeStr
18 changes: 18 additions & 0 deletions src/Lean/Elab/BuiltinTerm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Elab.Term
import Lean.Elab.Eval

namespace Lean.Elab.Term
open Meta
Expand Down Expand Up @@ -304,4 +305,21 @@ private def mkSilentAnnotationIfHole (e : Expr) : TermElabM Expr := do
withInfoContext' stx (elabTerm e expectedType?) (mkTermInfo .anonymous (expectedType? := expectedType?) stx)
| _ => throwUnsupportedSyntax

private unsafe def evalFilePathUnsafe (stx : Syntax) : TermElabM System.FilePath :=
evalTerm System.FilePath (Lean.mkConst ``System.FilePath) stx

@[implementedBy evalFilePathUnsafe]
private opaque evalFilePath (stx : Syntax) : TermElabM System.FilePath

@[builtinTermElab includeStr] def elabIncludeStr : TermElab
| `(include_str $path:term), _ => do
let path ← evalFilePath path
let ctx ← readThe Lean.Core.Context
let srcPath := System.FilePath.mk ctx.fileName
let some srcDir := srcPath.parent
| throwError "cannot compute parent directory of '{srcPath}'"
let path := srcDir / path
mkStrLit <$> IO.FS.readFile path
| _, _ => throwUnsupportedSyntax

end Lean.Elab.Term
29 changes: 0 additions & 29 deletions src/Lean/Elab/IncludeStr.lean

This file was deleted.

0 comments on commit 962a4bf

Please sign in to comment.