Skip to content

Commit

Permalink
Add a Python3 syntax model, based on the official Python BNF. See #80.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsh committed Nov 6, 2023
1 parent 3ad8bc2 commit 6c51a7f
Show file tree
Hide file tree
Showing 4 changed files with 1,410 additions and 1 deletion.
8 changes: 8 additions & 0 deletions hydra-haskell/src/main/haskell/Hydra/Dsl/Grammars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ plus = G.PatternPlus
regex :: String -> G.Pattern
regex = G.PatternRegex . G.Regex

-- | A helper which matches patterns like "foo.bar.quux" or "one; two; three; four"
sep :: G.Pattern -> G.Pattern -> G.Pattern
sep separator pat = list[pat, star(list[separator, pat])]

-- | A helper which matches patterns like "foo.bar.quux" or "foo.bar.quux." (i.e. trailing separators are allowed)
sepp :: G.Pattern -> G.Pattern -> G.Pattern
sepp separator pat = list[pat, star(list[separator, pat]), opt(separator)]

star :: G.Pattern -> G.Pattern
star = G.PatternStar

Expand Down
2 changes: 2 additions & 0 deletions hydra-haskell/src/main/haskell/Hydra/Sources/Tier4/All.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Hydra.Sources.Tier4.Langs.Protobuf.Any
import Hydra.Sources.Tier4.Langs.Protobuf.Language
import Hydra.Sources.Tier4.Langs.Protobuf.Proto3
import Hydra.Sources.Tier4.Langs.Protobuf.SourceContext
import Hydra.Sources.Tier4.Langs.Python.Python3
import Hydra.Sources.Tier4.Langs.Rdf.Syntax
import Hydra.Sources.Tier4.Langs.RelationalModel
import Hydra.Sources.Tier4.Langs.Scala.Meta
Expand Down Expand Up @@ -61,6 +62,7 @@ tier4LangModules = [
protobufAnyModule,
protobufLanguageModule,
protobufSourceContextModule,
python3Module,
rdfSyntaxModule,
relationalModelModule,
scalaMetaModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cypherNs = Namespace "hydra/langs/cypher/openCypher"
cypher = typeref cypherNs

openCypherModule :: Module Kv
openCypherModule = Module cypherNs elements [hydraCoreModule] $
openCypherModule = Module cypherNs elements [] [hydraCoreModule] $
Just "An OpenCypher query model based on the M23 EBNF grammar. See https://opencypher.org/resources."
where
def = datatype cypherNs
Expand Down
Loading

0 comments on commit 6c51a7f

Please sign in to comment.