Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move Lean.Data.Parsec to Std.Internal.Parsec #5115

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Lean/Data.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Lean.Data.Name
import Lean.Data.NameMap
import Lean.Data.OpenDecl
import Lean.Data.Options
import Lean.Data.Parsec
import Lean.Data.PersistentArray
import Lean.Data.PersistentHashMap
import Lean.Data.PersistentHashSet
Expand Down
10 changes: 5 additions & 5 deletions src/Lean/Data/Json/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Authors: Gabriel Ebner, Marc Huisinga
-/
prelude
import Lean.Data.Json.Basic
import Lean.Data.Parsec
import Lean.Data.RBMap
import Std.Internal.Parsec

namespace Lean.Json.Parser

open Lean.Parsec
open Lean.Parsec.String
open Std.Internal.Parsec
open Std.Internal.Parsec.String

@[inline]
def hexChar : Parser Nat := do
Expand Down Expand Up @@ -216,8 +216,8 @@ namespace Json

def parse (s : String) : Except String Lean.Json :=
match Json.Parser.any s.mkIterator with
| Parsec.ParseResult.success _ res => Except.ok res
| Parsec.ParseResult.error it err => Except.error s!"offset {repr it.i.byteIdx}: {err}"
| .success _ res => Except.ok res
| .error it err => Except.error s!"offset {repr it.i.byteIdx}: {err}"

end Json

Expand Down
7 changes: 4 additions & 3 deletions src/Lean/Data/Xml/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Dany Fabian
-/
prelude
import Lean.Data.Parsec
import Std.Internal.Parsec
import Lean.Data.Xml.Basic

open System
open Lean

Expand All @@ -14,8 +15,8 @@ namespace Xml

namespace Parser

open Lean.Parsec
open Lean.Parsec.String
open Std.Internal.Parsec
open Std.Internal.Parsec.String

abbrev LeanChar := Char

Expand Down
8 changes: 4 additions & 4 deletions src/Lean/Elab/Tactic/BVDecide/External.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Authors: Henrik Böving
prelude
import Lean.Elab.Tactic.BVDecide.LRAT.Parser
import Lean.CoreM
import Lean.Data.Parsec
import Std.Internal.Parsec

/-!
This module implements the logic to call CaDiCal (or CLI interface compatible SAT solvers) and
Expand All @@ -32,14 +32,14 @@ inductive SolverResult where

namespace ModelParser

open Lean.Parsec
open Lean.Parsec.ByteArray
open Std.Internal.Parsec
open Std.Internal.Parsec.ByteArray

def parsePartialAssignment : Parser (Bool × (Array (Bool × Nat))) := do
skipByteChar 'v'
let idents ← many (attempt wsLit)
let idents := idents.map (fun i => if i > 0 then (true, i.natAbs) else (false, i.natAbs))
Parsec.tryCatch
tryCatch
(skipString " 0")
(csuccess := fun _ => pure (true, idents))
(cerror := fun _ => do
Expand Down
6 changes: 3 additions & 3 deletions src/Lean/Elab/Tactic/BVDecide/LRAT/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Authors: Henrik Böving
prelude
import Init.System.IO
import Std.Tactic.BVDecide.LRAT.Actions
import Lean.Data.Parsec
import Std.Internal.Parsec

/-!
This module implements parsers and serializers for both the binary and non-binary LRAT format.
Expand All @@ -28,8 +28,8 @@ private def getPivot (clause : Array Int) : Literal Nat :=
(pivotInt.natAbs, false)


open Lean.Parsec
open Lean.Parsec.ByteArray
open Std.Internal.Parsec
open Std.Internal.Parsec.ByteArray

namespace Text

Expand Down
1 change: 1 addition & 0 deletions src/Std.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ prelude
import Std.Data
import Std.Sat
import Std.Tactic
import Std.Internal
12 changes: 12 additions & 0 deletions src/Std/Internal.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/-
Copyright (c) 2024 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving
-/
prelude
import Std.Internal.Parsec

/-!
This directory is used for components of the standard library that are either considered
implementation details or not yet ready for public consumption.
-/
6 changes: 3 additions & 3 deletions src/Lean/Data/Parsec.lean → src/Std/Internal/Parsec.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Dany Fabian
-/
prelude
import Lean.Data.Parsec.Basic
import Lean.Data.Parsec.String
import Lean.Data.Parsec.ByteArray
import Std.Internal.Parsec.Basic
import Std.Internal.Parsec.String
import Std.Internal.Parsec.ByteArray
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ prelude
import Init.NotationExtra
import Init.Data.ToString.Macro

namespace Lean
namespace Std.Internal

namespace Parsec

Expand All @@ -18,7 +18,7 @@ inductive ParseResult (α : Type) (ι : Type) where

end Parsec

def Parsec (ι : Type) (α : Type) : Type := ι → Lean.Parsec.ParseResult α ι
def Parsec (ι : Type) (α : Type) : Type := ι → Parsec.ParseResult α ι

namespace Parsec

Expand Down Expand Up @@ -144,5 +144,6 @@ def manyChars (p : Parsec ι Char) : Parsec ι String := manyCharsCore p ""
@[inline]
def many1Chars (p : Parsec ι Char) : Parsec ι String := do manyCharsCore p (← p).toString


end Parsec

end Std.Internal
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving
-/
prelude
import Lean.Data.Parsec.Basic
import Std.Internal.Parsec.Basic
import Init.Data.ByteArray.Basic
import Init.Data.String.Extra

namespace Lean
namespace Std.Internal
namespace Parsec
namespace ByteArray

Expand Down Expand Up @@ -129,4 +129,4 @@ def take (n : Nat) : Parser ByteArray := fun it =>

end ByteArray
end Parsec
end Lean
end Std.Internal
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Dany Fabian, Henrik Böving
-/
prelude
import Lean.Data.Parsec.Basic
import Std.Internal.Parsec.Basic

namespace Lean
namespace Std.Internal
namespace Parsec
namespace String

Expand Down Expand Up @@ -110,4 +110,4 @@ def take (n : Nat) : Parser String := fun it =>

end String
end Parsec
end Lean
end Std.Internal
4 changes: 2 additions & 2 deletions tests/lean/1363.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Lean.Data.Parsec
open Lean Parsec String
import Std.Internal.Parsec
open Std Internal Parsec String

@[macro_inline] -- Error
def f : Nat → Nat
Expand Down
8 changes: 4 additions & 4 deletions tests/lean/interactive/run.lean
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def Lean.Widget.GetWidgetsResponse.debugJson (r : Widget.GetWidgetsResponse) : J
)
]

open Parsec in
open Parsec.String in
open Std.Internal.Parsec in
open Std.Internal.Parsec.String in
def word : Parser String :=
many1Chars <| digit <|> asciiLetter <|> pchar '_'

open Parsec in
open Parsec.String in
open Std.Internal.Parsec in
open Std.Internal.Parsec.String in
def ident : Parser Name := do
let head ← word
let xs ← many1 (pchar '.' *> word)
Expand Down
Loading