From: pimjager Date: Tue, 1 Mar 2016 10:25:49 +0000 (+0100) Subject: Comments kunnen nu eindigen met een EOF ipv newline X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=ca00099482644c76d6d918f536f69db32ac85058;p=cc1516.git Comments kunnen nu eindigen met een EOF ipv newline --- diff --git a/src/example.spl b/src/example.spl index 58d037e..2a1f3ab 100644 --- a/src/example.spl +++ b/src/example.spl @@ -93,3 +93,4 @@ squareOddNumbers(list) :: [Int] -> [Int] { } return list; } +//deze comment eindigt met EOF ipv newline \ No newline at end of file diff --git a/src/lex.icl b/src/lex.icl index fd4b564..63a14e0 100644 --- a/src/lex.icl +++ b/src/lex.icl @@ -21,7 +21,7 @@ lexProgram = some lexToken <* many (satisfy isSpace) <* eof lexToken :: Parser Char TokenValue lexToken = //Comments - (list (fromString "//") >>| until top (item '\n') >>| lexToken) <|> + (list (fromString "//") >>| until top ((item '\n' >>| return Void) <|> eof) >>| lexToken) <|> (list (fromString "/*") >>| until top (list (fromString "*/")) >>| lexToken) <|> //Keyword tokens (lexKw "var" VarToken) <|> diff --git a/src/yard.dcl b/src/yard.dcl index 38ce368..bc4f940 100644 --- a/src/yard.dcl +++ b/src/yard.dcl @@ -18,6 +18,8 @@ instance Alternative (Parser a) instance toString Error +//(`until`) infix 1 + runParser :: (Parser a b) [a] -> (Either Error b, [a]) () :: (Parser a b) (String, Int) -> Parser a b fail :: Parser a b