Commit ec5046c9 authored by Camil Staps's avatar Camil Staps 🚀

Improve parsing of string literals in ABC optimiser & increase heap size to...

Improve parsing of string literals in ABC optimiser & increase heap size to deal with (ridiculously) large strings
parent dac788ea
Pipeline #30457 passed with stages
in 18 minutes and 47 seconds
......@@ -2,6 +2,7 @@ implementation module ABC.Parse
import StdEnv
import StdGeneric
import StdOverloadedList
import ABC.Instructions
......@@ -83,17 +84,20 @@ where
| isSpace line.[start] = ParseResult (toString (reverse cs)) start
| otherwise = id [line.[start]:cs] (start + 1)
parseLine`{|StringLiteral|} start line = case line.[start] of
'"' -> let (sl,j) = stringlit [] (start+1) in case line.[j] of
'"' -> let (sl,j) = stringlit [|] (start+1) in case line.[j] of
'"' -> ParseResult sl (start+1)
_ -> NoParseResult
_ -> NoParseResult
where
stringlit :: [Char] !Int -> (!StringLiteral, !Int)
// TODO: for really large strings it would be better to scan ahead until
// the end, allocate the result string, and fill it, without using a list
// for the intermediate result.
stringlit :: ![#Char!] !Int -> (!StringLiteral, !Int)
stringlit cs start
| start >= size line = (StringLit (toString (reverse cs)), start)
| line.[start] == '\\' = stringlit [line.[start+1],line.[start]:cs] (start+2)
| line.[start] == '"' = (StringLit (toString (reverse cs)), start)
| otherwise = stringlit [line.[start]:cs] (start + 1)
| start >= size line = (StringLit {c \\ c <|- Reverse cs}, start)
| line.[start] == '\\' = stringlit [|line.[start+1],line.[start]:cs] (start+2)
| line.[start] == '"' = (StringLit {c \\ c <|- Reverse cs}, start)
| otherwise = stringlit [|line.[start]:cs] (start + 1)
parseLine`{|StringWithSpaces|} start line = ParseResult (StringWithSpaces (line % (start,size line-1))) (size line-1)
parseLine`{|CONS of {gcd_name,gcd_arity}|} fx 0 line
......
......@@ -8,7 +8,7 @@ Global
CheckIndexes: True
GenerateByteCode: False
Application
HeapSize: 20971520
HeapSize: 1073742000
StackSize: 2048000
ExtraMemory: 8192
IntialHeapSize: 20971520
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment