Commit 5924712b authored by Laszlo Domoszlai's avatar Laszlo Domoszlai

Merge branch 'hierarchical' of...

Merge branch 'hierarchical' of https://gitlab.science.ru.nl/clean-and-itasks/clean-sapl into hierarchical
parents 5de1bf18 86de990b
......@@ -18,11 +18,16 @@ not_eol c = not (c == '\n')
find_first_string :: !String !Int (Char String Int -> Bool) -> Int
find_first_string line start f
| start == size line
= size line
| f line.[start-1] line start
= find_first_string line (start + 1) f
= start
# lineSz = size line
| start == lineSz
= lineSz
# newPos = start - 1
| newPos >= lineSz
= abort "find_first_string newPos >= lineSz"
| f line.[newPos] line start
= find_first_string line (start + 1) f
| otherwise
= start
read_string_lit :: !Char !Int !String -> (!Int, !UString)
read_string_lit qc start str
......@@ -30,27 +35,29 @@ read_string_lit qc start str
= (nextbase, reverse l)
where
decode p cs
| eof p = (p, cs)
| str.[p] == qc = (p+1, cs)
| str.[p] == '\\' = let (n,c) = decodeBSChar (p+1) in decode n [c:cs]
= decode (p+1) [fromChar str.[p]:cs]
| eof p = (p, cs)
# strP = str.[p]
| strP == qc = (p+1, cs)
| strP == '\\' = let (n,c) = decodeBSChar (p+1) in decode n [c:cs]
| otherwise = decode (p+1) [fromChar strP : cs]
decodeBSChar p
| eof p = (p ,fromChar '\\')
| str.[p] == '0' = (p+1,fromInt 0)
| str.[p] == 'a' = (p+1,fromInt 7)
| str.[p] == 'b' = (p+1,fromChar '\b')
| str.[p] == 'f' = (p+1,fromChar '\f')
| str.[p] == 'n' = (p+1,fromChar '\n')
| str.[p] == 'r' = (p+1,fromChar '\r')
| str.[p] == 't' = (p+1,fromChar '\t')
| str.[p] == 'v' = (p+1,fromChar '\v')
| str.[p] == '\'' = (p+1,fromChar '\'')
| str.[p] == '"' = (p+1,fromChar '"')
| str.[p] == 'x' = decodeHex 2 2 0
| str.[p] == 'u' = decodeHex 4 4 0
| str.[p] == 'U' = decodeHex 8 8 0
= (p+1,fromChar str.[p]) // skip the backslash otherwise
| eof p = (p ,fromChar '\\')
# strP = str.[p]
| strP == '0' = (p+1,fromInt 0)
| strP == 'a' = (p+1,fromInt 7)
| strP == 'b' = (p+1,fromChar '\b')
| strP == 'f' = (p+1,fromChar '\f')
| strP == 'n' = (p+1,fromChar '\n')
| strP == 'r' = (p+1,fromChar '\r')
| strP == 't' = (p+1,fromChar '\t')
| strP == 'v' = (p+1,fromChar '\v')
| strP == '\'' = (p+1,fromChar '\'')
| strP == '"' = (p+1,fromChar '"')
| strP == 'x' = decodeHex 2 2 0
| strP == 'u' = decodeHex 4 4 0
| strP == 'U' = decodeHex 8 8 0
| otherwise = (p+1,fromChar strP) // skip the backslash otherwise
where
decodeHex :: !Int !Int !Int -> (!Int, !UChar)
decodeHex len s acc
......@@ -145,12 +152,13 @@ read_token base line
"update" = return (TUpdateKeyword, stop)
"let" = return (TLetKeyword, stop)
"in" = return (TInKeyword, stop)
str = if (str.[0] == '!')
(return (TStrictIdentifier (str % (1, size str)), stop))
(return (TIdentifier str, stop))
str
# strSz = size str
| strSz > 0 && str.[0] == '!' = return (TStrictIdentifier (str % (1, strSz)), stop)
| otherwise = return (TIdentifier str, stop)
where
tstr stop = line % (start, stop - 1)
start = (skipChars line base is_space)
start = skipChars line base is_space
rnoarg t length = (start, start + length, t)
return (a, newbase) = (start, newbase, a)
......
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