Change option name
This commit is contained in:
parent
187c1fc0ce
commit
9dd4f3ee01
35
README.md
35
README.md
|
@ -1 +1,36 @@
|
||||||
# rubyhs
|
# rubyhs
|
||||||
|
|
||||||
|
A *node* is the "fully qualified name" of either 1) a function; or 2)
|
||||||
|
a module. The program should create a *reference graph*. The
|
||||||
|
reference graph shows which nodes reference other nodes. Treating
|
||||||
|
modules and functions equally allow us to express that a module calls
|
||||||
|
a function as in:
|
||||||
|
|
||||||
|
module M
|
||||||
|
f
|
||||||
|
end
|
||||||
|
|
||||||
|
as well as the opposite where a function refers to a constant:
|
||||||
|
|
||||||
|
def f
|
||||||
|
M
|
||||||
|
end
|
||||||
|
|
||||||
|
The program should ensure that references actually correspond to nodes
|
||||||
|
that we know of.
|
||||||
|
|
||||||
|
The program should maintain forward edges as well as backwards edges.
|
||||||
|
That way we can both answer the question "Which nodes does this node
|
||||||
|
transitively reference" as well as "which nodes transitively reference
|
||||||
|
this node".
|
||||||
|
|
||||||
|
Given a reference graph and a node - called the query - that program
|
||||||
|
should print out a spanning tree rooted at the query node. Cycles
|
||||||
|
should be marked. E.g. like so for two mutually defined nodes `a` and
|
||||||
|
`b`:
|
||||||
|
|
||||||
|
{
|
||||||
|
"a": {
|
||||||
|
"b": { "a": "__cycle__" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
ruby/test.rb
10
ruby/test.rb
|
@ -1,3 +1,6 @@
|
||||||
|
def h
|
||||||
|
end
|
||||||
|
|
||||||
module M
|
module M
|
||||||
def f
|
def f
|
||||||
end
|
end
|
||||||
|
@ -8,7 +11,13 @@ module M
|
||||||
h(2, a: :a)
|
h(2, a: :a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def h
|
||||||
|
end
|
||||||
|
|
||||||
module N
|
module N
|
||||||
|
def h
|
||||||
|
end
|
||||||
|
|
||||||
def f
|
def f
|
||||||
M::foo
|
M::foo
|
||||||
h
|
h
|
||||||
|
@ -31,4 +40,3 @@ end
|
||||||
f(2)
|
f(2)
|
||||||
h(2, a: 'a')
|
h(2, a: 'a')
|
||||||
h(2, a: :a)
|
h(2, a: :a)
|
||||||
|
|
||||||
|
|
|
@ -49,17 +49,16 @@ command = Command <$> targets <*> printAST
|
||||||
where
|
where
|
||||||
targets = many (Options.argument Options.str (Options.metavar "TARGET"))
|
targets = many (Options.argument Options.str (Options.metavar "TARGET"))
|
||||||
printAST = Options.switch
|
printAST = Options.switch
|
||||||
$ Options.long "quiet"
|
$ Options.long "print-ast"
|
||||||
<> Options.short 'q'
|
<> Options.help "Print AST and exit"
|
||||||
<> Options.help "Whether to be quiet"
|
|
||||||
|
|
||||||
getCommand :: IO Command
|
getCommand :: IO Command
|
||||||
getCommand = Options.execParser opts
|
getCommand = Options.execParser opts
|
||||||
where
|
where
|
||||||
opts = Options.info (Options.helper <*> command)
|
opts = Options.info (Options.helper <*> command)
|
||||||
( Options.fullDesc
|
( Options.fullDesc
|
||||||
<> Options.progDesc "Print a greeting for TARGET"
|
<> Options.progDesc "Static analysis of Ruby"
|
||||||
<> Options.header "hello - a test for optparse-applicative" )
|
<> Options.header "rubyhs - Static analysis of Ruby" )
|
||||||
|
|
||||||
decodeFail :: MonadFail m => FromJSON a => ByteString -> m a
|
decodeFail :: MonadFail m => FromJSON a => ByteString -> m a
|
||||||
decodeFail s = case eitherDecode s of
|
decodeFail s = case eitherDecode s of
|
||||||
|
|
Loading…
Reference in a new issue