aboutsummaryrefslogtreecommitdiff
path: root/src/Language/SimpleShell/Parser/Expr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/SimpleShell/Parser/Expr.hs')
-rw-r--r--src/Language/SimpleShell/Parser/Expr.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Language/SimpleShell/Parser/Expr.hs b/src/Language/SimpleShell/Parser/Expr.hs
index cabf522..0f2f6c9 100644
--- a/src/Language/SimpleShell/Parser/Expr.hs
+++ b/src/Language/SimpleShell/Parser/Expr.hs
@@ -15,7 +15,6 @@ import Language.SimpleShell.Parser
( Parser
, lexeme
, symbol
- , commentFirstChars
, lookupVar
, lookupFun
)
@@ -32,7 +31,7 @@ import Control.Monad (void)
import Control.Monad.Combinators (manyTill)
import Data.Foldable (asum)
import Data.Text (Text)
-import Text.Megaparsec (takeWhile1P, oneOf, many)
+import Text.Megaparsec (anySingleBut, many)
import Text.Megaparsec.Char (char)
import qualified Text.Megaparsec.Char.Lexer as L (charLiteral, decimal)
@@ -67,16 +66,17 @@ strongTermP_
-- * parentheses
-- * string literals
-- * comments
+ -- - Thus, `takeWhile1P` is dangerous.
+ -- * This is hardly the most efficient implementation.
+ -- * A more efficient implementation would use `takeWhile1P` to parse
+ -- large chunks of input, but--as noted above--that is dangerous;
+ -- i.e., non-trivial (albeit not really hard) to do correctly.
tok :: Parser ()
tok
- = void strLitP
- <|> symbol "(" *> void (many tok) <* symbol ")"
- <|> void (lexeme $ takeWhile1P Nothing isBoring)
- <|> void (lexeme $ oneOf commentFirstChars)
- where
- isBoring :: Char -> Bool
- isBoring = not . (`elem` "()\"" ++ commentFirstChars)
+ = strongTermP_
+ <|> void nameP -- function names; for efficiency only
+ <|> void (lexeme $ anySingleBut ')') -- operators (i.a.; catchall)
-- | Parse "strong" term with fixed type.