dhscanner-ast 0.1.0.3 → 0.1.0.4
raw patch · 3 files changed
+64/−17 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Ast: DecPackageContent :: PkgName -> DecPackageContent
- Ast: DecVarContent :: VarName -> NominalTy -> Maybe Exp -> DecVarContent
- Ast: StmtCall :: ExpCallContent -> Stmt
- Ast: StmtDecvar :: DecVarContent -> Stmt
- Ast: [decPackageName] :: DecPackageContent -> PkgName
- Ast: [decVarInitValue] :: DecVarContent -> Maybe Exp
- Ast: [decVarName] :: DecVarContent -> VarName
- Ast: [decVarNominalType] :: DecVarContent -> NominalTy
- Ast: [stmtImportName] :: StmtImportContent -> String
- Ast: data DecPackageContent
- Ast: data DecVarContent
- Ast: instance Data.Aeson.Types.FromJSON.FromJSON Ast.DecPackageContent
- Ast: instance Data.Aeson.Types.FromJSON.FromJSON Ast.DecVarContent
- Ast: instance Data.Aeson.Types.ToJSON.ToJSON Ast.DecPackageContent
- Ast: instance Data.Aeson.Types.ToJSON.ToJSON Ast.DecVarContent
- Ast: instance GHC.Classes.Eq Ast.DecPackageContent
- Ast: instance GHC.Classes.Eq Ast.DecVarContent
- Ast: instance GHC.Classes.Ord Ast.DecPackageContent
- Ast: instance GHC.Classes.Ord Ast.DecVarContent
- Ast: instance GHC.Generics.Generic Ast.DecPackageContent
- Ast: instance GHC.Generics.Generic Ast.DecVarContent
- Ast: instance GHC.Show.Show Ast.DecPackageContent
- Ast: instance GHC.Show.Show Ast.DecVarContent
+ Ast: ExpNull :: ExpNullContent -> Exp
+ Ast: ExpNullContent :: ConstNull -> ExpNullContent
+ Ast: StmtBlock :: StmtBlockContent -> Stmt
+ Ast: StmtBlockContent :: Location -> StmtBlockContent
+ Ast: StmtVardec :: StmtVardecContent -> Stmt
+ Ast: StmtVardecContent :: VarName -> NominalTy -> Maybe Exp -> Location -> StmtVardecContent
+ Ast: [expNullValue] :: ExpNullContent -> ConstNull
+ Ast: [stmtBlockLocation] :: StmtBlockContent -> Location
+ Ast: [stmtImportFromSource] :: StmtImportContent -> Maybe String
+ Ast: [stmtImportSource] :: StmtImportContent -> String
+ Ast: [stmtVardecInitValue] :: StmtVardecContent -> Maybe Exp
+ Ast: [stmtVardecLocation] :: StmtVardecContent -> Location
+ Ast: [stmtVardecName] :: StmtVardecContent -> VarName
+ Ast: [stmtVardecNominalType] :: StmtVardecContent -> NominalTy
+ Ast: data ExpNullContent
+ Ast: data StmtBlockContent
+ Ast: data StmtVardecContent
+ Ast: instance Data.Aeson.Types.FromJSON.FromJSON Ast.ExpNullContent
+ Ast: instance Data.Aeson.Types.FromJSON.FromJSON Ast.StmtBlockContent
+ Ast: instance Data.Aeson.Types.FromJSON.FromJSON Ast.StmtVardecContent
+ Ast: instance Data.Aeson.Types.ToJSON.ToJSON Ast.ExpNullContent
+ Ast: instance Data.Aeson.Types.ToJSON.ToJSON Ast.StmtBlockContent
+ Ast: instance Data.Aeson.Types.ToJSON.ToJSON Ast.StmtVardecContent
+ Ast: instance GHC.Classes.Eq Ast.ExpNullContent
+ Ast: instance GHC.Classes.Eq Ast.StmtBlockContent
+ Ast: instance GHC.Classes.Eq Ast.StmtVardecContent
+ Ast: instance GHC.Classes.Ord Ast.ExpNullContent
+ Ast: instance GHC.Classes.Ord Ast.StmtBlockContent
+ Ast: instance GHC.Classes.Ord Ast.StmtVardecContent
+ Ast: instance GHC.Generics.Generic Ast.ExpNullContent
+ Ast: instance GHC.Generics.Generic Ast.StmtBlockContent
+ Ast: instance GHC.Generics.Generic Ast.StmtVardecContent
+ Ast: instance GHC.Show.Show Ast.ExpNullContent
+ Ast: instance GHC.Show.Show Ast.StmtBlockContent
+ Ast: instance GHC.Show.Show Ast.StmtVardecContent
+ Token: ConstNull :: Location -> ConstNull
+ Token: [constNullLocation] :: ConstNull -> Location
+ Token: data ConstNull
+ Token: instance Data.Aeson.Types.FromJSON.FromJSON Token.ConstNull
+ Token: instance Data.Aeson.Types.ToJSON.ToJSON Token.ConstNull
+ Token: instance GHC.Classes.Eq Token.ConstNull
+ Token: instance GHC.Classes.Ord Token.ConstNull
+ Token: instance GHC.Generics.Generic Token.ConstNull
+ Token: instance GHC.Show.Show Token.ConstNull
- Ast: StmtImportContent :: String -> String -> Location -> StmtImportContent
+ Ast: StmtImportContent :: String -> Maybe String -> Maybe String -> Location -> StmtImportContent
- Ast: [stmtImportAlias] :: StmtImportContent -> String
+ Ast: [stmtImportAlias] :: StmtImportContent -> Maybe String
Files
- dhscanner-ast.cabal +1/−1
- src/Ast.hs +56/−16
- src/Token.hs +7/−0
dhscanner-ast.cabal view
@@ -22,7 +22,7 @@ and models both of them as plain sequential code blocks. Every file has exactly one ast that represents it. Non Haskell parogrammers note: The ast is /immutable/ (like everything else in Haskell ...) -version: 0.1.0.3 +version: 0.1.0.4 license: GPL-3.0-only license-file: LICENSE author: OrenGitHub
src/Ast.hs view
@@ -81,6 +81,7 @@ | ExpStr ExpStrContent | ExpVar ExpVarContent | ExpBool ExpBoolContent + | ExpNull ExpNullContent | ExpCall ExpCallContent | ExpBinop ExpBinopContent | ExpLambda ExpLambdaContent @@ -90,9 +91,8 @@ = StmtExp Exp | StmtIf StmtIfContent | StmtTry StmtTryContent - | StmtCall ExpCallContent | StmtFunc StmtFuncContent - | StmtDecvar DecVarContent + | StmtBlock StmtBlockContent | StmtBreak StmtBreakContent | StmtClass StmtClassContent | StmtWhile StmtWhileContent @@ -100,6 +100,7 @@ | StmtMethod StmtMethodContent | StmtAssign StmtAssignContent | StmtReturn StmtReturnContent + | StmtVardec StmtVardecContent | StmtContinue StmtContinueContent deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) @@ -170,19 +171,13 @@ } deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) -data DecPackageContent - = DecPackageContent - { - decPackageName :: Token.PkgName - } - deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) - -data DecVarContent - = DecVarContent +data StmtVardecContent + = StmtVardecContent { - decVarName :: Token.VarName, - decVarNominalType :: Token.NominalTy, - decVarInitValue :: Maybe Exp + stmtVardecName :: Token.VarName, + stmtVardecNominalType :: Token.NominalTy, + stmtVardecInitValue :: Maybe Exp, + stmtVardecLocation :: Location } deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) @@ -207,6 +202,13 @@ } deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) +data ExpNullContent + = ExpNullContent + { + expNullValue :: Token.ConstNull + } + deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) + data Operator = PLUS | MINUS @@ -265,11 +267,49 @@ } deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) +data StmtBlockContent + = StmtBlockContent + { + stmtBlockLocation :: Location + } + deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON ) + +-- | +-- ==== __Examples:__ +-- +-- * Simple source import +-- +-- @ +-- # stmtImportSource is "json" +-- # stmtImportFromSource is Nothing +-- # stmtImportAlias is Nothing +-- import json +-- @ +-- +-- * Specifying a specific name from source +-- +-- @ +-- # stmtImportSource is "urllib.parse" +-- # stmtImportFromSource is Just "urljoin" +-- # stmtImportAlias is Nothing +-- from urllib.parse import urljoin +-- @ +-- +-- * Specifying an alias for a source import +-- +-- @ +-- # stmtImportSource is "networkx" +-- # stmtImportFromSource is Nothing +-- # stmtImportAlias is Just "nx" +-- import networkx as nx +-- @ +-- data StmtImportContent = StmtImportContent { - stmtImportName :: String, - stmtImportAlias :: String, + stmtImportSource :: String, + stmtImportFromSource :: Maybe String, + stmtImportAlias :: Maybe String, stmtImportLocation :: Location } deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
src/Token.hs view
@@ -121,3 +121,10 @@ constStrLocation :: Location } deriving ( Show, Eq, Generic, ToJSON, FromJSON, Ord ) + +data ConstNull + = ConstNull + { + constNullLocation :: Location + } + deriving ( Show, Eq, Generic, ToJSON, FromJSON, Ord )