Commit 40eb6617 authored by Diederik van Arkel's avatar Diederik van Arkel
Browse files

typedecl colouring

parent a849a1f8
...@@ -8,6 +8,9 @@ from EdPosition import :: LineNr ...@@ -8,6 +8,9 @@ from EdPosition import :: LineNr
import syncol import syncol
import Platform import Platform
//import dodebug
trace_n` _ f :== f
//-- stuff we want to parametrise... //-- stuff we want to parametrise...
/* /*
class TextAnnot a // b class TextAnnot a // b
...@@ -22,7 +25,7 @@ export TextAnnot Void, SyncInf, ConsInf ...@@ -22,7 +25,7 @@ export TextAnnot Void, SyncInf, ConsInf
*/ */
:: LineAnnot :== Info :: LineAnnot :== Info
dummyLineAnnot :== (0,False,False) dummyLineAnnot :== (0,False,False,0)
annotLine :== slMap (\s->(dummyLineAnnot,s)) annotLine :== slMap (\s->(dummyLineAnnot,s))
annotWhole :== firstParse annotWhole :== firstParse
annotPart :== quickParse annotPart :== quickParse
...@@ -283,5 +286,4 @@ updateLine lineNr string text=:{ nrLines, blocks } ...@@ -283,5 +286,4 @@ updateLine lineNr string text=:{ nrLines, blocks }
# after = SCons (pl,string) (slTail after) # after = SCons (pl,string) (slTail after)
#! lines = slAppend before after #! lines = slAppend before after
# (st,fin,lines) = annotPart lineNr lineNr lines # (st,fin,lines) = annotPart lineNr lineNr lines
= (st,fin,{blocks = group BlockSize lines, nrLines = nrLines}) = trace_n` ("updateLine",st,fin) (st,fin,{blocks = group BlockSize lines, nrLines = nrLines})
...@@ -44,7 +44,7 @@ where ...@@ -44,7 +44,7 @@ where
scanFirst :: !Int !Int !Int !.String -> (!Int,!Int,!Int) scanFirst :: !Int !Int !Int !.String -> (!Int,!Int,!Int)
scanFirst level index indent line scanFirst level index indent line
| index >= line_size = (index,indent,level) | index >= line_size = (index,-1,level)
# char = line.[index] # char = line.[index]
| char == ' ' = scanFirst level (inc index) (inc indent) line | char == ' ' = scanFirst level (inc index) (inc indent) line
| char == '\t' = scanFirst level (inc index) ((inc (indent >> 2)) << 2) line | char == '\t' = scanFirst level (inc index) ((inc (indent >> 2)) << 2) line
...@@ -104,17 +104,20 @@ scanfunny i line_size line ...@@ -104,17 +104,20 @@ scanfunny i line_size line
//:: String State -> ((Info,String),State) //:: String State -> ((Info,String),State)
parseLine :: !.State !.String -> (!Bool,!State) parseLine :: !.State !.String -> (!Bool,!State)
parseLine state=:(level,typedef,typedecl,offside) line parseLine state=:(level,typedef,typedecl,offside) line
# (index,indent,level) = scanFirst level 0 0 line #! (index,indent,level) = scanFirst level 0 0 line
# (typedecl,offside) = if typedecl #! (typedecl,offside) = if typedecl
(if (index < line_size && indent <= offside) (if (index < line_size && indent >= 0 && indent <= offside)
(False,indent) (False,indent)
(True,offside) (True,offside)
) )
(False,indent) (False,if (indent >= 0) indent offside)
# state = (level,typedef,typedecl,offside) #! state = (level,typedef,typedecl,offside)
# has_content = index < line_size #! has_content = indent >= 0 && index < line_size
# not_double_colon = line%(index,dec (scanfunny index line_size line)) <> "::" | index > 0
= (has_content && if (index > 0) not_double_colon True , pL state index) #! not_double_colon = line%(index,dec (scanfunny index line_size line)) <> "::"
= (has_content && not_double_colon, pL state index)
= (has_content, pL state index)
// = (has_content && if (index > 0) not_double_colon True , pL state index)
where where
line_size = size line line_size = size line
...@@ -171,7 +174,10 @@ where ...@@ -171,7 +174,10 @@ where
no_c` = line_size < 2 no_c` = line_size < 2
c` = line.[1] c` = line.[1]
scanFunny (level,typedef,typedecl,offside) s i scanFunny (level,typedef,typedecl,offside) s i
| i >= line_size = pL (level,typedef,typedecl,offside) line_size | i >= line_size
| level == 0 && line%(s,dec i) == "::"
= pL (0,typedef,True,offside) i
= pL (level,typedef,typedecl,offside) i
#! c = line.[i] #! c = line.[i]
| funnyChar c = scanFunny (level,typedef,typedecl,offside) s (inc i) | funnyChar c = scanFunny (level,typedef,typedecl,offside) s (inc i)
| level == 0 && line%(s,dec i) == "::" | level == 0 && line%(s,dec i) == "::"
...@@ -203,27 +209,29 @@ WhiteSpace c ...@@ -203,27 +209,29 @@ WhiteSpace c
*/ */
firstParse :: !(StrictList String) -> StrictList (!Info,!String) firstParse :: !(StrictList String) -> StrictList (!Info,!String)
firstParse lines firstParse lines
= slFromList (fP (0,False,False,0) [] lines) // = slFromList (fP (0,False,False,0) [] lines)
= fP (0,False,False,0) id [] lines
where where
fP i acc SNil fP :: !(!Int,!Bool,!Bool,!Int) ((StrictList (!Info,!String)) -> StrictList (!Info,!String)) ![(!(!Int,!Bool,!Bool,!Int),!String)] !(StrictList String) -> StrictList (!Info,!String)
= acc fP i res acc SNil
fP i=:(level,typedef,typedecl,offside) acc (SCons h t) = res (slFromList acc)
fP i=:(level,typedef,typedecl,offside) res acc (SCons h t)
#! (has_contents,j=:(level`,typedef`,typedecl`,offside`)) = parseLine i h #! (has_contents,j=:(level`,typedef`,typedecl`,offside`)) = parseLine i h
i` = (level,typedef`,typedecl`) i` = (level,typedef`,typedecl`,offside`)
| typedecl == False && typedecl` && offside < offside` | typedecl == False && typedecl` && offside < offside`
| has_contents | has_contents
= acc ++ (fP j [(i`,h)] t) = fP j (\r -> res (slFromList` acc r)) [(i`,h)] t
// should be identifier in acc... // should be identifier in acc...
# j` = (level,typedef,typedecl`,offside) # j` = (level,typedef,typedecl`,offside)
= [fun s \\ s<- acc] ++ (fP j` [] (SCons h t)) = fP j` (\r -> res (slFromList` [fun s \\ s <- acc] r)) [] (SCons h t)
with with
fun :: (!Info,!String) -> (!Info,!String) fun :: (!Info,!String) -> (!Info,!String)
fun ((c,t,d),l) = ((c,False,True),l) fun ((c,t,d,o),l) = ((c,False,True,o),l)
| has_contents | has_contents
| isEmpty acc | isEmpty acc
= fP j [(i`,h)] t = fP j res [(i`,h)] t
= acc ++ (fP j [(i`,h)] t) = fP j (\r -> res (slFromList` acc r)) [(i`,h)] t
= fP j (acc ++[(i`,h)]) t = fP j res (acc ++[(i`,h)]) t
/* /*
quickParse: (first modified line) (last modified line) textlines quickParse: (first modified line) (last modified line) textlines
......
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