From 68e9fada3fbaef2b0861302a30e1676be1a0eedc Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 2 Oct 2017 11:02:26 -0700 Subject: [PATCH 1/2] Contextualize comments in Ruby assignment again --- src/Language/Ruby/Syntax.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 456e43fcd..5c105f47c 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -10,7 +10,7 @@ import Data.Maybe (fromMaybe) import Data.Record import Data.Functor (void) import Data.List.NonEmpty (some1) -import Data.Syntax (postContextualize, emptyTerm, parseError, handleError, infixContext, makeTerm, makeTerm', makeTerm1) +import Data.Syntax (contextualize, postContextualize, emptyTerm, parseError, handleError, infixContext, makeTerm, makeTerm', makeTerm1) import qualified Data.Syntax as Syntax import Data.Syntax.Assignment hiding (Assignment, Error) import qualified Data.Syntax.Assignment as Assignment @@ -401,7 +401,7 @@ invert term = makeTerm <$> location <*> fmap Expression.Not term -- | Match a term optionally preceded by comment(s), or a sequence of comments if the term is not present. term :: Assignment -> Assignment -term term = many comment *> term <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm) +term term = contextualize comment term <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm) -- | Match a series of terms or comments until a delimiter is matched. manyTermsTill :: Show b => Assignment.Assignment [] Grammar Term -> Assignment.Assignment [] Grammar b -> Assignment.Assignment [] Grammar [Term] From 2ee98ab96f2a525b657b0f06429c221f21ab85c2 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 2 Oct 2017 11:13:54 -0700 Subject: [PATCH 2/2] These comments are part of Context now --- test/fixtures/ruby/hash.diffA-B.txt | 17 +++++++++++------ test/fixtures/ruby/hash.diffB-A.txt | 17 +++++++++++------ test/fixtures/ruby/hash.parseA.txt | 17 +++++++++++------ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/test/fixtures/ruby/hash.diffA-B.txt b/test/fixtures/ruby/hash.diffA-B.txt index 847e9e8d4..6294f4491 100644 --- a/test/fixtures/ruby/hash.diffA-B.txt +++ b/test/fixtures/ruby/hash.diffA-B.txt @@ -20,12 +20,17 @@ {-(Integer)-})-}) {-(Hash)-} {-(Hash - {-(KeyValue - {-(Identifier)-} - {-(Integer)-})-} - {-(KeyValue - {-(TextElement)-} - {-(Integer)-})-} + {-(Context + {-(Comment)-} + {-(KeyValue + {-(Identifier)-} + {-(Integer)-})-})-} + {-(Context + {-(Comment)-} + {-(Comment)-} + {-(KeyValue + {-(TextElement)-} + {-(Integer)-})-})-} {-(Context {-(Comment)-} {-(Empty)-})-})-} diff --git a/test/fixtures/ruby/hash.diffB-A.txt b/test/fixtures/ruby/hash.diffB-A.txt index 2bb3d4edf..7b1ca75c0 100644 --- a/test/fixtures/ruby/hash.diffB-A.txt +++ b/test/fixtures/ruby/hash.diffB-A.txt @@ -20,12 +20,17 @@ {+(Integer)+})+}) {+(Hash)+} {+(Hash - {+(KeyValue - {+(Identifier)+} - {+(Integer)+})+} - {+(KeyValue - {+(TextElement)+} - {+(Integer)+})+} + {+(Context + {+(Comment)+} + {+(KeyValue + {+(Identifier)+} + {+(Integer)+})+})+} + {+(Context + {+(Comment)+} + {+(Comment)+} + {+(KeyValue + {+(TextElement)+} + {+(Integer)+})+})+} {+(Context {+(Comment)+} {+(Empty)+})+})+} diff --git a/test/fixtures/ruby/hash.parseA.txt b/test/fixtures/ruby/hash.parseA.txt index 34a002740..bcc7e907b 100644 --- a/test/fixtures/ruby/hash.parseA.txt +++ b/test/fixtures/ruby/hash.parseA.txt @@ -14,12 +14,17 @@ (Integer))) (Hash) (Hash - (KeyValue - (Identifier) - (Integer)) - (KeyValue - (TextElement) - (Integer)) + (Context + (Comment) + (KeyValue + (Identifier) + (Integer))) + (Context + (Comment) + (Comment) + (KeyValue + (TextElement) + (Integer))) (Context (Comment) (Empty)))