This repository was archived by the owner on Apr 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
semantic-analysis/src/Analysis/Syntax Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44{-# LANGUAGE KindSignatures #-}
55{-# LANGUAGE LambdaCase #-}
66{-# LANGUAGE PatternSynonyms #-}
7+ {-# LANGUAGE ViewPatterns #-}
78-- | This belongs in @semantic-python@ instead of @semantic-analysis@, but for the sake of expedience…
89module Analysis.Syntax.Python
910( -- * Syntax
@@ -17,6 +18,7 @@ module Analysis.Syntax.Python
1718, pattern Throw''
1819, pattern Import''
1920, pattern Function''
21+ , pattern Call''
2022 -- * Abstract interpretation
2123, eval0
2224, eval
@@ -108,6 +110,25 @@ pattern Import'' i = Import' i T.:$: T.Nil
108110pattern Function'' :: Name -> [Name ] -> T. Term Python v -> T. Term Python v
109111pattern Function'' n as b = Function' n as T. :$: T. Cons b T. Nil
110112
113+ pattern Call''
114+ :: T. Term Python v
115+ -> [T. Term Python v ]
116+ -> T. Term Python v
117+ pattern Call'' f as <- Call' T. :$: T. Cons f (T. Cons (fromArgs -> as) T. Nil )
118+ where Call'' f as = Call' T. :$: T. Cons f (T. Cons (foldr ACons'' ANil'' as) T. Nil )
119+
120+ fromArgs :: T. Term Python v -> [T. Term Python v ]
121+ fromArgs = \ case
122+ ANil'' -> []
123+ ACons'' a as -> a: fromArgs as
124+ _ -> fail " unexpected constructor in spine of argument list"
125+
126+ pattern ANil'' :: T. Term Python v
127+ pattern ANil'' = ANil' T. :$: T. Nil
128+
129+ pattern ACons'' :: T. Term Python v -> T. Term Python v -> T. Term Python v
130+ pattern ACons'' a as = ACons' T. :$: T. Cons a (T. Cons as T. Nil )
131+
111132
112133-- Abstract interpretation
113134
You can’t perform that action at this time.
0 commit comments