From 335cb3194f8e1ce7943f1b45b270d95b1cbb20bc Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 25 Apr 2017 15:05:04 -0400 Subject: [PATCH] :fire: State assignment. --- src/Data/Syntax/Assignment.hs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Data/Syntax/Assignment.hs b/src/Data/Syntax/Assignment.hs index 1af63a835..feb8f4c02 100644 --- a/src/Data/Syntax/Assignment.hs +++ b/src/Data/Syntax/Assignment.hs @@ -2,7 +2,6 @@ module Data.Syntax.Assignment ( Assignment , get -, state , Location , location , symbol @@ -39,7 +38,6 @@ type Assignment node = Freer (AssignmentF node) data AssignmentF node a where Get :: AssignmentF node node - State :: AssignmentF (Node grammar) (AssignmentState grammar) Location :: AssignmentF node Location Source :: AssignmentF symbol ByteString Children :: Assignment symbol a -> AssignmentF symbol a @@ -52,12 +50,6 @@ data AssignmentF node a where get :: Assignment (Record fields) (Record fields) get = Get `Then` return --- | Zero-width production of the current state. --- --- Since this is zero-width, care must be taken not to repeat it without chaining on other rules. I.e. 'many (state *> b)' is fine, but 'many state' is not. -state :: Assignment (Node grammar) (AssignmentState grammar) -state = State `Then` return - -- | Zero-width production of the current location. -- -- If assigning at the end of input or at the end of a list of children, the loccation will be returned as an empty Range and SourceSpan at the current offset. Otherwise, it will be the Range and SourceSpan of the current node. @@ -126,7 +118,6 @@ runAssignment :: (Symbol grammar, Eq grammar, Show grammar) => Assignment (Node runAssignment = iterFreer (\ assignment yield state -> case (assignment, dropAnonymous state) of -- Nullability: some rules, e.g. 'pure a' and 'many a', should match at the end of input. Either side of an alternation may be nullable, ergo Alt can match at the end of input. (Alt a b, state) -> yield a state <|> yield b state -- FIXME: Symbol `Alt` Symbol `Alt` Symbol is inefficient, should build and match against an IntMap instead. - (State, state) -> yield state state (assignment, AssignmentState offset _ source (subtree@(Rose node@(_ :. range :. span :. Nil) children) : _)) -> case assignment of Get -> yield node state Location -> yield (range :. span :. Nil) state @@ -167,7 +158,6 @@ instance Alternative (Assignment symbol) where instance Show symbol => Show1 (AssignmentF symbol) where liftShowsPrec sp sl d a = case a of Get -> showString "Get" - State -> showString "State" . sp d (AssignmentState 0 (Info.SourcePos 0 0) (Source.Source "") []) Location -> showString "Location" . sp d (Info.Range 0 0 :. Info.SourceSpan (Info.SourcePos 0 0) (Info.SourcePos 0 0) :. Nil) Source -> showString "Source" . showChar ' ' . sp d "" Children a -> showsUnaryWith (liftShowsPrec sp sl) "Children" d a