Make sure that variables generated during parsing are less likely to overlap. This is not a pretty fix, but it is better than the previous system.
This commit is contained in:
parent
6d8a50d326
commit
50ddf4cddc
2 changed files with 7 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
module Guid (guid, run, GuidCounter) where
|
||||
module Guid (guid, run, runAt, GuidCounter) where
|
||||
|
||||
import Control.Monad.State (evalState, State, get, put)
|
||||
|
||||
|
@ -13,4 +13,5 @@ guid = GC $ do n <- get
|
|||
put (n + 1)
|
||||
return n
|
||||
|
||||
run x = evalState (runGC x) 0
|
||||
run = runAt 0
|
||||
runAt n x = evalState (runGC x) n
|
|
@ -98,7 +98,8 @@ recordTerm = brackets $ choice [ misc, addContext record ]
|
|||
fDefs <- (:) <$> (PVar <$> rLabel) <*> spacePrefix patternTerm
|
||||
whitespace
|
||||
e <- string "=" >> whitespace >> expr
|
||||
run $ flattenPatterns fDefs e
|
||||
n <- sourceLine <$> getPosition
|
||||
runAt (1000 * n) $ flattenPatterns fDefs e
|
||||
extract [ FnDef f args exp ] = return (f,args,exp)
|
||||
extract _ = fail "Improperly formed record field."
|
||||
record = Record <$> (mapM extract =<< commaSep field)
|
||||
|
@ -203,7 +204,8 @@ assignExpr = withPos $ do
|
|||
fDefs <- funcDef
|
||||
whitespace
|
||||
e <- string "=" >> whitespace >> expr
|
||||
run $ flattenPatterns fDefs e
|
||||
n <- sourceLine <$> getPosition
|
||||
runAt (1000 * n) $ flattenPatterns fDefs e
|
||||
|
||||
def = map Definition <$> assignExpr
|
||||
|
||||
|
|
Loading…
Reference in a new issue