keyword has both *single-line* and *multi-line-block* variants.
:
===========================
_____ !!! SOLVED !!! _____
===========================
I had to make use of the regex (?-m) option to turn off multi-line search for the single-line "Type" variations.
Code: Select all
;These rules go in the "Folds:" section of the freebasic.coder file.
;
;Type (Alias): *Single-Line*
;With "Deny Fold" - (Used in Production):
;The folds will *not* display... (but neither will "Color text", so you cannot see which rules were used to capture the text).
;3409920=2048+262144+1048576+2097152
3409920 0 ${REG} 0 "^(?-m)(?i)\s*(type)\b([^\n]*?)(as)\b" "$" " " 0 0
;
;With-out "Deny Fold" - (Used when Troubleshooting):
;The folds *will* display... (and you can use different "Color text" per rule to see which rules were used to capture the text).
;3407872=262144+1048576+2097152
;3407872 0 ${REG} 0 "^(?-m)(?i)\s*(type)\b([^\n]*?)(as)\b" "$" " " 0 0
;
;Type (Block): *Multi-Line*
;40=8+32
40 0 0 0 "type" "end type" " " 0 0
===========================
:
FreeBASIC has two (2) "Type" keywords:
Code: Select all
A. *multi-line* "Type ... End Type" block.
Type some__TYPE
' comment #1
' comment #2 ... something with the word AS in it
m As ulongint = 2762781
s As ulongint = 0
i As ulongint = 0
r As ubyte = 13
End Type
B. *single-line* "Type Alias" with three (3) variations.
1. Type some_alias_name As Function (As Integer, As Integer) As Integer
2. Type As Function (As Integer, As Integer) As Integer some_ALIAS_name
3. Type some__TYPE As some_ALIAS_name
Code: Select all
;Type (Alias): *Single-Line*
;262152=8+262144
262152 0 0 0 "type" "as function" " " 0 0
And I can handle the standard "Type ... End Type" block with this basic "Folds:" rule:
Code: Select all
;Type (Block): *Multi-Line*
;40=8+32
40 0 0 0 "type" "end type" " " 0 0
the #3 "Type mytype As mytype_alias" at the same time.
I'm sure it is going to need regex(s) to work, but so far... just failures.
The #3 "Type mytype As mytype_alias" only has two (2) keywords to work with...
"TYPE" and "AS". So I think a regex is going to have to function something like this
pseudo-regex.
Code: Select all
^(type)(any characters except a \n)(\s)(as)(\s)(any characters)$
but that rule does not seem to work correctly as a "Folds:" regex.
Code: Select all
"^\s*(type)\s+[^\n]+? (as) "
Note:
(While testing, I usually set the fold captures to different colors so that it
is easy to see what is getting captured).
Code: Select all
;
;Type (Alias): *Single-Line*
;262152=8+262144
262152 0 ${ERR} 0 "type" "as function" " " 0 0
262152 0 ${REG} 0 "type" "as" " \n" 0 0
;2099208=8+2048+2097152
;2097160=8+2097152
;2097160 0 ${ERR} 0 "type" "^[ \t]*[a-z0-9_]*? as " " " 0 0
;2099208 0 ${ERR} 0 "type" "(^[ \t]*?type [a-z0-9_]*?)? as " " " 0 0
;2099208 0 ${ERR} 0 "type" "(^[ \t]*type [a-z0-9_]*)? as " " " 0 0
;1050632=8+2048+1048576
;3147784=8+2048+1048576+2097152
;3409928=8+2048+262144+1048576+2097152
;1310720=262144+1048576
;2359304=8+262144+2097152
;3407872=262144+1048576+2097152
;3409920=2048+262144+1048576+2097152
;
;2359304 0 ${REG} 0 "type" "[^\n]*?\b(as)\b" " " 0 0
;262152 0 ${REG} 0 "type" " as " " " 0 0
;1310720 0 ${REG} 0 "^\s*(type)\s+[^\n]++" "as" " " 0 0
;3407872 0 ${REG} 0 "^\s*(type)\s+[^\n]+?\b(as)\b" "\n" " " 0 0
;;;3407872 0 ${REG} 0 "^[ \t]*(type)[ \t]*\b([a-z0-9_]+)\b[ \t]*(as)\b" "$" " " 0 0
;3409920 0 ${REG} 0 "^[ \t]*(type)[ \t]*\b([a-z0-9_]+)\b[ \t]*(as)\b" "\n" " " 0 0
;3407872 0 ${REG} 0 "^([ \t]*)(type)([ \t]*)([a-z0-9_]+)([ \t]*)(as\s)" "\n" " " 0 0
;2359304 0 ${REG} 0 "type" "([ \t]*)([a-z0-9_\s]+)(as)([ \t]*)\n" " " 0 0
;
;3409920 0 ${ERR} 0 "^[ \t]*(type)[ \t]*(([a-z0-9_]?)[ \t]*)?(as)\b" "$" " " 0 0
;2359304=8+262144+2097152
;392=8+128+256
;2359304 0 ${ERR} 0 "type" " as .+?$" " " 0 0
;
;Type (Block): *Multi-Line*
;40=8+32
40 0 ${NUM} 0 "type" "end type" " " 0 0
;
Code: Select all
Type some_alias_name As Function (As Integer, As Integer) As Integer
Type As Function (As Integer, As Integer) As Integer some_ALIAS_name
Type some__TYPE As some_ALIAS_name
Type some__TYPE
' comment #1
' comment #2 ... something with the word AS in it
m As ulongint = 2762781
s As ulongint = 0
i As ulongint = 0
r As ubyte = 13
End Type
if x then
end if
if x then 'lkjldjkf
end if
if x then y else z end if
if x then y
CBruce