summaryrefslogtreecommitdiff
path: root/source/Syntax/Token.hs
diff options
context:
space:
mode:
authorSimon-Kor <52245124+Simon-Kor@users.noreply.github.com>2024-09-23 03:14:06 +0200
committerGitHub <noreply@github.com>2024-09-23 03:14:06 +0200
commit8fd49ae84e8cc4524c19b20fa0aabb4e77a46cd5 (patch)
tree9848da3e57979a5a7e14ec99ee103cfa079e6fcb /source/Syntax/Token.hs
parent18c79bcb98fb376f15b2b3e00972530df61b26a9 (diff)
parentf6b22fd533bd61e9dbcb6374295df321de99b1f2 (diff)
Abgabe
Submission of Formalisation
Diffstat (limited to 'source/Syntax/Token.hs')
-rw-r--r--source/Syntax/Token.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/Syntax/Token.hs b/source/Syntax/Token.hs
index cb3f4cb..53e1e6a 100644
--- a/source/Syntax/Token.hs
+++ b/source/Syntax/Token.hs
@@ -189,6 +189,7 @@ toks = whitespace *> goNormal id <* eof
Nothing -> pure (f [])
Just t@Located{unLocated = BeginEnv "math"} -> goMath (f . (t:))
Just t@Located{unLocated = BeginEnv "align*"} -> goMath (f . (t:))
+ --Just t@Located{unLocated = BeginEnv "cases"} -> goMath (f . (t:))
Just t -> goNormal (f . (t:))
goText f = do
r <- optional textToken
@@ -204,6 +205,7 @@ toks = whitespace *> goNormal id <* eof
Nothing -> pure (f [])
Just t@Located{unLocated = EndEnv "math"} -> goNormal (f . (t:))
Just t@Located{unLocated = EndEnv "align*"} -> goNormal (f . (t:))
+ --Just t@Located{unLocated = EndEnv "cases"} -> goNormal (f . (t:))
Just t@Located{unLocated = BeginEnv "text"} -> goText (f . (t:))
Just t@Located{unLocated = BeginEnv "explanation"} -> goText (f . (t:))
Just t -> goMath (f . (t:))
@@ -219,12 +221,12 @@ toks = whitespace *> goNormal id <* eof
-- | Parses a single normal mode token.
tok :: Lexer (Located Token)
tok =
- word <|> var <|> symbol <|> mathBegin <|> alignBegin <|> begin <|> end <|> opening <|> closing <|> label <|> ref <|> command
+ word <|> var <|> symbol <|> mathBegin <|> alignBegin <|> casesBegin <|> begin <|> end <|> opening <|> closing <|> label <|> ref <|> command
-- | Parses a single math mode token.
mathToken :: Lexer (Located Token)
mathToken =
- var <|> symbol <|> number <|> begin <|> alignEnd <|> end <|> opening <|> closing <|> beginText <|> beginExplanation <|> mathEnd <|> command
+ var <|> symbol <|> number <|> begin <|> alignEnd <|> casesEnd <|> end <|> opening <|> closing <|> beginText <|> beginExplanation <|> mathEnd <|> command
beginText :: Lexer (Located Token)
beginText = lexeme do
@@ -277,6 +279,11 @@ alignBegin = guardM isTextMode *> lexeme do
setMathMode
pure (BeginEnv "align*")
+casesBegin :: Lexer (Located Token)
+casesBegin = guardM isTextMode *> lexeme do
+ Char.string "\\begin{cases}"
+ --setMathMode
+ pure (BeginEnv "cases")
-- | Parses a single end math token.
mathEnd :: Lexer (Located Token)
@@ -291,6 +298,12 @@ alignEnd = guardM isMathMode *> lexeme do
setTextMode
pure (EndEnv "align*")
+casesEnd :: Lexer (Located Token)
+casesEnd = guardM isMathMode *> lexeme do
+ Char.string "\\end{cases}"
+ --setTextMode
+ pure (EndEnv "cases")
+
-- | Parses a word. Words are returned casefolded, since we want to ignore their case later on.
word :: Lexer (Located Token)