chore: accept unregistered syntax kinds in stage 1

This commit is contained in:
Sebastian Ullrich 2022-04-15 13:41:43 +02:00 committed by Leonardo de Moura
parent 712967c6f6
commit e1fbc04c3b
3 changed files with 7 additions and 5 deletions

View file

@ -60,6 +60,9 @@ def toolchain :=
else
""
@[extern c inline "LEAN_IS_STAGE0"]
constant Internal.isStage0 (u : Unit) : Bool
/- Valid identifier names -/
def isGreek (c : Char) : Bool :=
0x391 ≤ c.val && c.val ≤ 0x3dd

View file

@ -404,7 +404,9 @@ def addSyntaxNodeKind (env : Environment) (k : SyntaxNodeKind) : Environment :=
def isValidSyntaxNodeKind (env : Environment) (k : SyntaxNodeKind) : Bool :=
let kinds := (parserExtension.getState env).kinds
kinds.contains k
-- accept any constant in stage 1 (i.e. when compiled by stage 0) so that
-- we can add a built-in parser and its elaborator in the same stage
kinds.contains k || (Internal.isStage0 () && env.contains k)
def getSyntaxNodeKinds (env : Environment) : List SyntaxNodeKind :=
let kinds := (parserExtension.getState env).kinds

View file

@ -56,9 +56,6 @@ end SearchPath
builtin_initialize searchPathRef : IO.Ref SearchPath ← IO.mkRef {}
@[extern c inline "LEAN_IS_STAGE0"]
private constant isStage0 (u : Unit) : Bool
@[export lean_get_prefix]
def getBuildDir : IO FilePath := do
return (← IO.appDir).parent |>.get!
@ -67,7 +64,7 @@ def getBuildDir : IO FilePath := do
def getLibDir (leanSysroot : FilePath) : IO FilePath := do
let mut buildDir := leanSysroot
-- use stage1 stdlib with stage0 executable (which should never be distributed outside of the build directory)
if isStage0 () then
if Internal.isStage0 () then
buildDir := buildDir / ".." / "stage1"
return buildDir / "lib" / "lean"