Browse Source

skeleton structure and initial python grammar for imports (for

reference)
master
wes 7 years ago
parent
commit
ab40fc8a34
  1. 9
      src/Analyze.hs
  2. 6
      src/IndexCode.hs
  3. 18
      src/Parse/Python.hs

9
src/Analyze.hs

@ -0,0 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
module Analyze () where
import qualified Filesystem.Path.CurrentOS as FP
import Parse.Python
getDependencies :: FP.FilePath -> [FP.FilePath]
getDependencies = undefined

6
src/IndexCode.hs

@ -15,9 +15,6 @@ import qualified Filesystem.Path.CurrentOS as FP
import qualified Control.Concurrent.Async as CA
import qualified Data.Text as T
notHidden :: FP.FilePath -> Bool
notHidden fname = (T.head $ decodeFile $ FP.filename fname) /= '.'
decodeFile :: FP.FilePath -> T.Text
decodeFile fname =
case FP.toText fname of
@ -31,6 +28,9 @@ recurse files subdirs
subs <- CA.mapConcurrently lsRecursive subdirs
return $ files >< (join subs)
notHidden :: FP.FilePath -> Bool
notHidden fname = (T.head $ decodeFile $ FP.filename fname) /= '.'
getUnhidden :: S.Seq FP.FilePath -> S.Seq FP.FilePath
getUnhidden = S.filter notHidden

18
src/Parse/Python.hs

@ -0,0 +1,18 @@
{-# LANGUAGE OverloadedStrings #-}
module Parse.Python () where
-- Responsible for parsing python import statements
{-
- import_stmt: import_name | import_from
- import_name: 'import' dotted_as_names
- note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
- import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
- 'import' ('*' | '(' import_as_names ')' | import_as_names))
- import_as_name: NAME ['as' NAME]
- dotted_as_name: dotted_name ['as' NAME]
- import_as_names: import_as_name (',' import_as_name)* [',']
- dotted_as_names: dotted_as_name (',' dotted_as_name)*
- dotted_name: NAME ('.' NAME)*
-}
Loading…
Cancel
Save