1
1
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:
Timothy Clem 2017-08-24 14:43:13 -07:00
parent a1576d68d2
commit 7f41aee5e9
4 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
(Program
{ (Regex)
->(Regex) }
{+(Regex)+})
{+(Regex)+}
{+(Regex)+}
{-(Regex)-})

View File

@ -1,4 +1,4 @@
(Program
{ (Regex)
->(Regex) }
{+(Regex)+}
{-(Regex)-}
{-(Regex)-})