peculiar identifiers
This commit is contained in:
@@ -1,7 +1,67 @@
|
|||||||
[ SynNone :< SimpleF
|
[ MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 1
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "..." )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 2
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
( SimpleSymbol ".." )
|
( SimpleSymbol ".." )
|
||||||
, SynNone :< SimpleF
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
( SimpleSymbol ".abc" )
|
( SimpleSymbol ".abc" )
|
||||||
, SynNone :< SimpleF
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 4
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
( SimpleSymbol "....abcc" )
|
( SimpleSymbol "....abcc" )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 5
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol ".++-" )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-dot/source.scm"
|
||||||
|
, sourceLine = Pos 6
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol ".-" )
|
||||||
]
|
]
|
||||||
@@ -1 +1,6 @@
|
|||||||
.. .abc ....abcc
|
...
|
||||||
|
..
|
||||||
|
.abc
|
||||||
|
....abcc
|
||||||
|
.++-
|
||||||
|
.-
|
||||||
|
|||||||
@@ -20,4 +20,59 @@
|
|||||||
)
|
)
|
||||||
} :< SimpleF
|
} :< SimpleF
|
||||||
( SimpleSymbol "-" )
|
( SimpleSymbol "-" )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "+." )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 4
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "+.." )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 8
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "-." )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 11
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "-...abc" )
|
||||||
|
, MkAnn
|
||||||
|
{ syntax = SynNone
|
||||||
|
, position = Just
|
||||||
|
( SourcePos
|
||||||
|
{ sourceName = "golden/read/peculiar-identifier-sign/source.scm"
|
||||||
|
, sourceLine = Pos 3
|
||||||
|
, sourceColumn = Pos 19
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} :< SimpleF
|
||||||
|
( SimpleSymbol "-abc.." )
|
||||||
]
|
]
|
||||||
@@ -1 +1,3 @@
|
|||||||
+ -
|
+ -
|
||||||
|
|
||||||
|
+. +.. -. -...abc -abc..
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{-# LANGUAGE ApplicativeDo #-}
|
||||||
module Gyehoek.Sexp.Read
|
module Gyehoek.Sexp.Read
|
||||||
( readFile
|
( readFile
|
||||||
, readString
|
, readString
|
||||||
@@ -20,6 +21,7 @@ import qualified Data.Text as T
|
|||||||
import Data.Char (GeneralCategory(..), generalCategory)
|
import Data.Char (GeneralCategory(..), generalCategory)
|
||||||
import Data.Scientific (Scientific)
|
import Data.Scientific (Scientific)
|
||||||
import Gyehoek.Jalmot
|
import Gyehoek.Jalmot
|
||||||
|
import Data.Foldable
|
||||||
|
|
||||||
|
|
||||||
readFile :: (Jalmot :> es, IOE :> es) => FilePath -> Eff es (List Datum)
|
readFile :: (Jalmot :> es, IOE :> es) => FilePath -> Eff es (List Datum)
|
||||||
@@ -104,18 +106,51 @@ verb = L.symbol sc
|
|||||||
|
|
||||||
identifier :: P Text
|
identifier :: P Text
|
||||||
identifier = label "identifier" . lexeme . choice $
|
identifier = label "identifier" . lexeme . choice $
|
||||||
[ typical-- , delimited, peculiar
|
[ typical
|
||||||
|
-- , delimited
|
||||||
|
, peculiar
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
typical = T.cons <$> initial <*> subsequent
|
typical = T.cons <$> initial <*> subsequent
|
||||||
where
|
subsequent = takeWhileP Nothing \c ->
|
||||||
subsequent = takeWhileP Nothing \c ->
|
isInitial c ||
|
||||||
isInitial c ||
|
c `hasCategory` [SpacingCombiningMark, EnclosingMark, DecimalNumber]
|
||||||
c `hasCategory` [SpacingCombiningMark, EnclosingMark, DecimalNumber]
|
|| c == '.' || c == '@' || c == '+' || c == '-'
|
||||||
|| c == '.' || c == '@' || c == '+' || c == '-'
|
initial = satisfy isInitial
|
||||||
initial = satisfy isInitial
|
|
||||||
delimited = _
|
delimited = _
|
||||||
peculiar = _
|
peculiar = peculiarSign <|> peculiarDot
|
||||||
|
|
||||||
|
-- peculiarSign과 R⁷RS의 이 production 새 개들은 같음:
|
||||||
|
-- ⟨explicit sign⟩
|
||||||
|
-- ⟨explicit sign⟩ ⟨sign subsequent⟩ ⟨subsequent⟩*
|
||||||
|
-- ⟨explicit sign⟩ . ⟨dot subsequent⟩ ⟨subsequent⟩*
|
||||||
|
-- 같음:
|
||||||
|
-- ⟨explicit sign⟩
|
||||||
|
-- ((⟨sign subsequent⟩ | . ⟨dot subsequent⟩) ⟨subsequent⟩*)?
|
||||||
|
peculiarSign = do
|
||||||
|
sign <- explicitSign
|
||||||
|
r <- fold <$> optional do
|
||||||
|
neck <- choice
|
||||||
|
[ T.singleton <$> signSubsequent
|
||||||
|
, T.cons <$> single '.' <*> (T.singleton <$> dotSubsequent)
|
||||||
|
]
|
||||||
|
subs <- subsequent
|
||||||
|
pure $ neck <> subs
|
||||||
|
pure $ T.cons sign r
|
||||||
|
|
||||||
|
-- . ⟨dot subsequent⟩ ⟨subsequent⟩*
|
||||||
|
peculiarDot = do
|
||||||
|
dot <- single '.'
|
||||||
|
dotSub <- dotSubsequent
|
||||||
|
subs <- subsequent
|
||||||
|
pure $ T.cons dot $ T.cons dotSub subs
|
||||||
|
|
||||||
|
dotSubsequent = single '.' <|> signSubsequent
|
||||||
|
<?> "dot subsequent"
|
||||||
|
explicitSign = (satisfy \c -> c == '+' || c == '-')
|
||||||
|
<?> "explicit sign"
|
||||||
|
signSubsequent = initial <|> explicitSign <|> satisfy (=='@')
|
||||||
|
<?> "sign subsequent"
|
||||||
|
|
||||||
hasCategory c xs = generalCategory c `elem` xs
|
hasCategory c xs = generalCategory c `elem` xs
|
||||||
isInitial c = (c `hasCategory`
|
isInitial c = (c `hasCategory`
|
||||||
@@ -207,7 +242,7 @@ simpleDatum = choice
|
|||||||
, SimpleNumber <$> try number
|
, SimpleNumber <$> try number
|
||||||
-- , SimpleCharacter <$> character
|
-- , SimpleCharacter <$> character
|
||||||
, SimpleString <$> string
|
, SimpleString <$> string
|
||||||
, SimpleSymbol <$> symbol
|
, SimpleSymbol <$> try symbol
|
||||||
-- , SimpleBytevector <$> bytevector
|
-- , SimpleBytevector <$> bytevector
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ data DatumF a
|
|||||||
| CompoundF (CompoundF a)
|
| CompoundF (CompoundF a)
|
||||||
| LabeledF Label a
|
| LabeledF Label a
|
||||||
| LabelRefF Label
|
| LabelRefF Label
|
||||||
|
-- | Should not be used outside of the "Gyehoek.Sexp.QQ" implementation.
|
||||||
| MetaF Text
|
| MetaF Text
|
||||||
|
-- | Should not be used outside of the "Gyehoek.Sexp.QQ" implementation.
|
||||||
| MetaSpliceF Text
|
| MetaSpliceF Text
|
||||||
deriving stock (Show, Eq, Data, Generic, Lift, Functor, Foldable, Traversable)
|
deriving stock (Show, Eq, Data, Generic, Lift, Functor, Foldable, Traversable)
|
||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
@@ -94,7 +96,12 @@ data CompoundF a
|
|||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
|
|
||||||
data Prefix
|
data Prefix
|
||||||
= Quote | Backtick | Comma | CommaAt
|
= Quote -- ^ @'@
|
||||||
|
| Backtick -- ^ @`@
|
||||||
|
| Comma -- ^ @,@
|
||||||
|
| CommaAt -- ^ @,\@@
|
||||||
|
| PoundQuote -- ^ @#'@
|
||||||
|
| PoundBacktick -- ^ @#`@
|
||||||
deriving stock (Show, Eq, Data, Generic, Lift)
|
deriving stock (Show, Eq, Data, Generic, Lift)
|
||||||
deriving anyclass (NFData)
|
deriving anyclass (NFData)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ brokenReaderTests :: List String
|
|||||||
brokenReaderTests =
|
brokenReaderTests =
|
||||||
[ "delimited-identifier"
|
[ "delimited-identifier"
|
||||||
, "string-line-continuation"
|
, "string-line-continuation"
|
||||||
, "peculiar-identifier-dot"
|
|
||||||
, "meta-splice-expression-interior-brace"
|
, "meta-splice-expression-interior-brace"
|
||||||
, "datum-comment"
|
, "datum-comment"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user