Fix function stealing 'goto def's

This commit is contained in:
Kirill Andreev 2020-07-08 18:55:11 +04:00
parent 29bc1721d1
commit ba3c0a76d9
No known key found for this signature in database
GPG Key ID: CF7DA79DE4785A47
3 changed files with 27 additions and 13 deletions

View File

@ -685,7 +685,7 @@ fun_call = do
subtree "fun_call" do subtree "fun_call" do
ranged do ranged do
pure Apply pure Apply
<*> ranged do pure Ident <*> inside "f" function_id <*> inside "f" function_id
<*> inside "arguments" arguments <*> inside "arguments" arguments
arguments :: Parser [Pascal ASTInfo] arguments :: Parser [Pascal ASTInfo]
@ -694,16 +694,17 @@ arguments =
many do inside "argument" expr many do inside "argument" expr
function_id :: Parser (Pascal ASTInfo) function_id :: Parser (Pascal ASTInfo)
function_id = select function_id = ranged do
[ qname pure Ident <*> select
, do [ qname
subtree "module_field" do , do
ranged do subtree "module_field" do
pure QualifiedName ranged do
<*> inside "module" capitalName pure QualifiedName
<*> do pure <$> ranged do <*> inside "module" capitalName
pure At <*> inside "method" do name <|> name' <*> do pure <$> ranged do
] pure At <*> inside "method" do name <|> name'
]
opCall :: Parser (Pascal ASTInfo) opCall :: Parser (Pascal ASTInfo)
opCall = do opCall = do
@ -848,7 +849,7 @@ typeTuple = do
-- example = "../../../src/test/contracts/amount.ligo" -- example = "../../../src/test/contracts/amount.ligo"
-- example = "../../../src/test/contracts/annotation.ligo" -- example = "../../../src/test/contracts/annotation.ligo"
-- example = "../../../src/test/contracts/arithmetic.ligo" -- example = "../../../src/test/contracts/arithmetic.ligo"
-- example = "../../../src/test/contracts/assign.ligo" example = "../../../src/test/contracts/assign.ligo"
-- example = "../../../src/test/contracts/attributes.ligo" -- example = "../../../src/test/contracts/attributes.ligo"
-- example = "../../../src/test/contracts/bad_timestamp.ligo" -- example = "../../../src/test/contracts/bad_timestamp.ligo"
-- example = "../../../src/test/contracts/bad_type_operator.ligo" -- example = "../../../src/test/contracts/bad_type_operator.ligo"
@ -864,7 +865,7 @@ typeTuple = do
-- example = "../../../src/test/contracts/failwith.ligo" -- example = "../../../src/test/contracts/failwith.ligo"
-- example = "../../../src/test/contracts/loop.ligo" -- example = "../../../src/test/contracts/loop.ligo"
-- example = "../../../src/test/contracts/redeclaration.ligo" -- example = "../../../src/test/contracts/redeclaration.ligo"
example = "../../../src/test/contracts/includer.ligo" -- example = "../../../src/test/contracts/includer.ligo"
-- example = "../../../src/test/contracts/application.ligo" -- example = "../../../src/test/contracts/application.ligo"
-- example = "../../../src/test/contracts/application.ligo" -- example = "../../../src/test/contracts/application.ligo"
-- example = "../../../src/test/contracts/application.ligo" -- example = "../../../src/test/contracts/application.ligo"

View File

@ -36,6 +36,7 @@ module Parser
( -- * Parser type ( -- * Parser type
Parser Parser
, runParser , runParser
, runParser'
, debugParser , debugParser
-- * Combinators -- * Combinators
@ -62,6 +63,8 @@ module Parser
-- * Comments and ranges -- * Comments and ranges
, ASTInfo(..) , ASTInfo(..)
, Source(..)
, module ParseTree
) where ) where
import Control.Monad.Writer hiding (Product) import Control.Monad.Writer hiding (Product)
@ -117,6 +120,12 @@ runParser parser fin = do
(Cons Set.empty (Cons Set.empty
Nil))) Nil)))
runParser'
:: Parser a
-> Source
-> IO a
runParser' parser fin = fst <$> runParser parser fin
restart :: Stubbed a ASTInfo => Parser a -> FilePath -> Parser a restart :: Stubbed a ASTInfo => Parser a -> FilePath -> Parser a
restart p fin = do restart p fin = do
dir <- get' @FilePath dir <- get' @FilePath

View File

@ -7,6 +7,7 @@ module Range
, HasRange(..) , HasRange(..)
, diffRange , diffRange
, cutOut , cutOut
, point
) )
where where
@ -21,6 +22,9 @@ import Pretty
import Lattice import Lattice
import Product import Product
point :: Int -> Int -> Range
point l c = Range (l, c, 0) (l, c, 0) ""
-- | A continious location in text. -- | A continious location in text.
data Range = Range data Range = Range
{ rStart :: (Int, Int, Int) -- ^ [Start: line, col, byte-offset... { rStart :: (Int, Int, Int) -- ^ [Start: line, col, byte-offset...