Drop parseVarWithoutAssignment
Additionally sorts gitignore and adds attempted decoding of lists back to the REPL
This commit is contained in:
		
							
								
								
									
										14
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,11 +1,11 @@ | ||||
| bin/ | ||||
| /result | ||||
| /config.dhall | ||||
| /Dockerfile | ||||
| .stack-work/ | ||||
| *.swp | ||||
| dist* | ||||
| *.txt | ||||
| *~ | ||||
| .env | ||||
| .stack-work/ | ||||
| /Dockerfile | ||||
| /config.dhall | ||||
| /result | ||||
| WD | ||||
| *.hs.txt | ||||
| bin/ | ||||
| dist* | ||||
|  | ||||
| @ -54,16 +54,9 @@ parseFunction = do | ||||
|  | ||||
| parseAtomicBase :: Parser TricuAST | ||||
| parseAtomicBase = choice | ||||
|     [ try parseVarWithoutAssignment | ||||
|     , parseTreeLeaf | ||||
|     [ parseTreeLeaf | ||||
|     , parseGrouped | ||||
|     ] | ||||
| parseVarWithoutAssignment :: Parser TricuAST | ||||
| parseVarWithoutAssignment = do | ||||
|     LIdentifier name <- satisfy isIdentifier | ||||
|     if (name == "t" || name == "__result") | ||||
|     then fail $ "Reserved keyword: " ++ name ++ " cannot be assigned." | ||||
|     else notFollowedBy (satisfy (== LAssign)) *> return (SVar name) | ||||
|  | ||||
| parseLambda :: Parser TricuAST | ||||
| parseLambda = between (satisfy (== LOpenParen)) (satisfy (== LCloseParen)) $ do | ||||
|  | ||||
| @ -66,4 +66,6 @@ decodeResult tc = case toNumber tc of | ||||
|   Right num -> show num | ||||
|   Left _ -> case toString tc of | ||||
|     Right str -> "\"" ++ str ++ "\"" | ||||
|     Left _ -> formatResult TreeCalculus tc | ||||
|     Left _ -> case toList tc of | ||||
|       Right list -> "[" ++ intercalate ", " (map decodeResult list) ++ "]" | ||||
|       Left _ -> formatResult TreeCalculus tc | ||||
|  | ||||
| @ -53,7 +53,7 @@ lexerTests = testGroup "Lexer Tests" | ||||
|           expect = Right [LKeywordT, LStringLiteral "string", LIntegerLiteral 42] | ||||
|       runParser tricuLexer "" input @?= expect | ||||
|   , testCase "Lex invalid token" $ do | ||||
|       let input = "$invalid" | ||||
|       let input = "&invalid" | ||||
|       case runParser tricuLexer "" input of | ||||
|         Left _ -> return () | ||||
|         Right _ -> assertFailure "Expected lexer to fail on invalid token" | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 James Eversole
					James Eversole