Skip to content

Commit

Permalink
Follow TPTP SyntaxBNF
Browse files Browse the repository at this point in the history
<thf_atom_typing> ::= <untyped_atom> : <thf_top_level_type> |  (<thf_atom_typing>)
  • Loading branch information
PratherConid committed Feb 15, 2024
1 parent 2c3e8c8 commit 6f6587b
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions Auto/Parser/TPTP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -274,27 +274,28 @@ partial def addOpAndRhs (lhs : Term) (minbp : Nat) : ParserM Term := do
return ← addOpAndRhs (Term.mk op [lhs, rhs]) minbp

partial def parseTypeDecl : ParserM Term := do
if (← peek?) == some (.op "(") then
parseToken (.op "(")
let ident ← parseIdent
if (← peek?) == some (.op ":") then
parseToken (.op ":")
let ty ← parseTerm
parseToken (.op ")")
return Term.mk (.ident ident) [ty]
else
parseToken (.op ")")
return Term.mk (.ident ident) []
let ident ← parseIdent
if (← peek?) == some (.op ":") then
parseToken (.op ":")
let ty ← parseTerm
return Term.mk (.ident ident) [ty]
else
let ident ← parseIdent
if (← peek?) == some (.op ":") then
parseToken (.op ":")
let ty ← parseTerm
return Term.mk (.ident ident) [ty]
else
return Term.mk (.ident ident) []
return Term.mk (.ident ident) []
end

/--
<thf_atom_typing>
<tff_atom_typing>
-/
def parseAtomTyping : ParserM Term := do
if (← peek?) == .some (.op "(") then
parseToken (.op "(")
let decl ← parseTypeDecl
parseToken (.op ")")
return decl
else
parseTypeDecl

structure Command where
cmd : String
args : List Term
Expand All @@ -316,7 +317,7 @@ def parseCommand : ParserM Command := do
let kind ← parseIdent
parseToken (.op ",")
let val ← match kind with
| "type" => parseTypeDecl
| "type" => parseAtomTyping
| _ => parseTerm
if (← peek?) == some (.op ",") then
parseToken (.op ",")
Expand Down

0 comments on commit 6f6587b

Please sign in to comment.