magicant / flesh Goto Github PK
View Code? Open in Web Editor NEWPOSIX shell emulation library under construction
License: GNU General Public License v2.0
POSIX shell emulation library under construction
License: GNU General Public License v2.0
#75 made AliasT
a true monad, and we can refactor it even more.
AliasT
. #79getAliasT
. #79AliasT
to ReparseT
. #80substituteAlias
a monad class method. (#74 (comment))
MonadParser
and ParserT
to Flesh.Language.Parser.Class`.MonadReader
with MonadAlias
as a superclass of MonadParser
.Failures:
hspec-src/Flesh/Language/Parser/TestUtil.hs:101:
1) Flesh.Language.Parser.Lex.anyOperator, parses control operator, (..., returns expected result and state
Falsifiable (after 57 tests and 4 shrinks):
"\\\n"
Right ("(","") /= Right ("(","\\\n")
hspec-src/Flesh/Language/Parser/TestUtil.hs:101:
2) Flesh.Language.Parser.Lex.anyOperator, parses control operator, )..., returns expected result and state
Falsifiable (after 57 tests and 4 shrinks):
"\\\n"
Right (")","") /= Right (")","\\\n")
hspec-src/Flesh/Language/Parser/TestUtil.hs:101:
3) Flesh.Language.Parser.Lex.operator, parses argument control operator, (..., returns expected result and state
Falsifiable (after 57 tests and 4 shrinks):
"\\\n"
Right ("(","") /= Right ("(","\\\n")
hspec-src/Flesh/Language/Parser/TestUtil.hs:101:
4) Flesh.Language.Parser.Lex.operator, parses argument control operator, )..., returns expected result and state
Falsifiable (after 57 tests and 4 shrinks):
"\\\n"
Right (")","") /= Right (")","\\\n")
Randomized with seed 1980947583
The current instance definition for the AliasT applicative and monad is invalid because the composition law doesn't always hold.
lookahead b
is reparsed in a *> (lookahead b <* c)
but not in (a *> lookahead b) <* c
where alias substitution occurs on c
.
As defined in POSIX, any word token is subject to alias substitution if it follows another alias substitution that ends with a blank. To support this feature, the parser monad needs to be redefined.
hspec-src/Flesh/Language/Parser/LexSpec.hs:32:
1) Flesh.Language.Parser.Lex.comment fails if input does not start with #
Falsifiable (after 26 tests and 3 shrinks):
"\\\n"
Left (Soft,Error {reason = UnknownReason, position = Position {fragment =
Fragment {code = "\\\n", situation = StandardInput, lineNo = 0}, index = 2}}) /
= Left (Soft,Error {reason = UnknownReason, position = Position {fragment = Frag
ment {code = "\\\n", situation = StandardInput, lineNo = 0}, index = 0}})
Randomized with seed 1355872402
Continued form #77 (comment)
MonadInput
into MonadBuffer
and MonadReparse
.PushBackT
.MonadInput
.CursorT
.MonadInputRecord
to MonadRecord
.MonadRecord
independent of MonadInput
.ContextT
.MonadReader DefinitionSet
to MonadParser
dependencies.ParserT
to combine base monads.
ParserT
should be the only instance of MonadParser
.OneShotInputT
.LineInputT
.class Monad m => MonadInputIO m where
readNext :: m (Seq (Positioned Char))
class Monad m => MonadInput c m where
readAt :: c -> m (Either Position (c, Positioned Char))
positionAt :: c -> m Position
class Monad m => MonadBuffer m where -- currently known as MonadInput
popChar :: m (Either Position (Positioned Char))
lookahead :: m a -> m a
peekChar :: m (Either Position (Positioned Char))
currentPosition :: m Position
class Monad m => MonadReparse where
maybeReparse :: m (Maybe [Positioned Char], a) -> m a
class MonadBuffer m => MonadRecord where -- currently known as MonadInputRecord
reverseConsumedChars :: m [Positioned Char]
class (
MonadReparse m,
MonadRecord m,
MonadReader DefinitionSet m,
MonadError Failure m,
MonadPlus m)
=> MonadParser m
instance MonadInputIO ...
newtype OneShotInputT m a = OneShotInputT (m a)
instance MonadInput PositionedString (OneShotInputT m)
newtype LineInputT m a = LineInputT (StateT (Fragment, Seq (Positioned Char), Bool) m a) -- remembers if EOF is reached
instance MonadInput Int (LineInputT ...)
newtype ExceptT e m a = ExceptT (m (Either e a))
instance MonadInput (ExceptT ...)
instance MonadError ... (ExceptT ...)
m (Either F a)
newtype CursorT c m a = CursorT (StateT c m a)
instance MonadError ... (CursorT ...)
instance MonadBuffer (CursorT ...)
c -> m (Either F (a, c))
newtype PushBackT m a = PushBackT (StateT [Positioned Char] m a)
instance MonadError ... (PushBackT ...)
instance MonadBuffer (PushBackT ...)
instance MonadReparse (PushBackT ...)
[PC] -> c -> m (Either F (a, [PC], c))
newtype ReparseT m a = ReparseT (m (Maybe (Maybe (ReparseT m a), a)))
instance MonadError ... (ReparseT ...)
instance MonadBuffer (ReparseT ...)
instance MonadReparse (ReparseT ...)
[PC] -> c -> m (Either F (Maybe (Maybe ..., a), [PC], c))
newtype RecordT m a = RecordT (StateT [Positioned Char] m a)
instance MonadError ... (RecordT ...)
instance MonadBuffer (RecordT ...)
instance MonadReparse (RecordT ...)
-- instance MonadReader ... (RecordT ...)
instance MonadRecord (RecordT ...)
[PC] -> [PC] -> c -> m (Either F (Maybe (Maybe ..., a, [PC]), [PC], c))
newtype ReaderT r m a = ReaderT (r -> m a)
instance MonadError ... (ReaderT ...)
instance MonadBuffer (ReaderT ...)
instance MonadReparse (ReaderT ...)
instance MonadReader ... (ReaderT ...)
instance MonadRecord ... (ReaderT ...)
DS -> [PC] -> [PC] -> c -> m (Either F (Maybe (Maybe ..., a, [PC]), [PC], c))
newtype ParserT m a = ParserT (... m a)
instance MonadError ... (ParserT ...)
instance MonadBuffer (ParserT ...)
instance MonadReparse (ParserT ...)
instance MonadReader ... (ParserT ...)
instance MonadRecord (ParserT ...)
instance MonadPlus (ParserT ...)
instance MonadParser (ParserT ...)
-
+
=
?
#
%
UnknownReason
to human-friendly error message1>foo do
is printed as do 1>foo
, which is clearly a syntax error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.