mirror of
https://github.com/github/semantic.git
synced 2025-01-01 11:46:14 +03:00
Add Regex to syntax, fix ruby regex fixtures
This commit is contained in:
parent
a1576d68d2
commit
7f41aee5e9
@ -95,9 +95,14 @@ newtype Symbol a = Symbol { symbolContent :: ByteString }
|
||||
instance Eq1 Symbol where liftEq = genericLiftEq
|
||||
instance Show1 Symbol where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
newtype Regex a = Regex { regexContent :: ByteString }
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
instance Eq1 Regex where liftEq = genericLiftEq
|
||||
instance Show1 Regex where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
-- TODO: Heredoc-style string literals?
|
||||
-- TODO: Character literals.
|
||||
-- TODO: Regular expressions.
|
||||
|
||||
|
||||
-- Collections
|
||||
|
@ -49,6 +49,7 @@ type Syntax = '[
|
||||
, Literal.KeyValue
|
||||
, Literal.Null
|
||||
, Literal.Rational
|
||||
, Literal.Regex
|
||||
, Literal.String
|
||||
, Literal.Symbol
|
||||
, Literal.TextElement
|
||||
@ -171,7 +172,7 @@ literal =
|
||||
<|> makeTerm <$> symbol Subshell <*> (Literal.TextElement <$> source)
|
||||
<|> makeTerm <$> symbol String <*> (Literal.TextElement <$> source)
|
||||
<|> makeTerm <$> symbol ChainedString <*> children (many (term (makeTerm <$> symbol String <*> (Literal.TextElement <$> source))))
|
||||
<|> makeTerm <$> symbol Regex <*> (Literal.TextElement <$> source)
|
||||
<|> makeTerm <$> symbol Regex <*> (Literal.Regex <$> source)
|
||||
<|> makeTerm <$> symbol Symbol <*> (Literal.Symbol <$> source)
|
||||
|
||||
heredoc :: Assignment
|
||||
|
6
test/fixtures/ruby/regex.diffA-B.txt
vendored
6
test/fixtures/ruby/regex.diffA-B.txt
vendored
@ -1,4 +1,4 @@
|
||||
(Program
|
||||
{ (Regex)
|
||||
->(Regex) }
|
||||
{+(Regex)+})
|
||||
{+(Regex)+}
|
||||
{+(Regex)+}
|
||||
{-(Regex)-})
|
||||
|
4
test/fixtures/ruby/regex.diffB-A.txt
vendored
4
test/fixtures/ruby/regex.diffB-A.txt
vendored
@ -1,4 +1,4 @@
|
||||
(Program
|
||||
{ (Regex)
|
||||
->(Regex) }
|
||||
{+(Regex)+}
|
||||
{-(Regex)-}
|
||||
{-(Regex)-})
|
||||
|
Loading…
Reference in New Issue
Block a user