Added support for comments.

This commit is contained in:
Edward R. Gonzalez 2022-07-17 11:27:10 -04:00
parent 31f1ae9b8f
commit 856a1faa9c
3 changed files with 34 additions and 0 deletions

View File

@ -26,8 +26,10 @@ margin_left = 1.2
margin_right = 0.375977 margin_right = 0.375977
grow_horizontal = 0 grow_horizontal = 0
theme = ExtResource( 2 ) theme = ExtResource( 2 )
readonly = true
highlight_current_line = true highlight_current_line = true
show_line_numbers = true show_line_numbers = true
wrap_enabled = true
[node name="SRegEx_TEdit" type="TextEdit" parent="."] [node name="SRegEx_TEdit" type="TextEdit" parent="."]
anchor_left = 0.525 anchor_left = 0.525

View File

@ -146,3 +146,27 @@ start \" !set( \" ).repeat(0-) \"
start "null" start "null"
start "this" start "this"
start word.repeat(1-) start word.repeat(1-)
start(
http://www\.
| https://www\.
| http://
| https://
).repeat(0-1)
set(a-z 0-9).repeat(1-)
(
set(\- \. ).repeat(1)
set(a-z 0-9).repeat(1-)
)
.repeat(0-)
\.
set(a-z).repeat(2,5)
( : set(0-9).repeat(1-5) ).repeat(0-1)
( / \. \*).repeat(0-1)
end

View File

@ -15,6 +15,7 @@ extends Object
const TokenType : Dictionary = \ const TokenType : Dictionary = \
{ {
fmt_S = "Formatting", fmt_S = "Formatting",
cmt_SL = "Comment Single Line",
str_start = "String Start", str_start = "String Start",
str_end = "String End", str_end = "String End",
@ -55,6 +56,7 @@ const TokenType : Dictionary = \
const Spec : Dictionary = \ const Spec : Dictionary = \
{ {
TokenType.fmt_S : "^\\s", TokenType.fmt_S : "^\\s",
TokenType.cmt_SL: "^^\\(\\?\\#.*?\\)",
TokenType.str_start : "^\\bstart\\b", TokenType.str_start : "^\\bstart\\b",
TokenType.str_end : "^\\bend\\b", TokenType.str_end : "^\\bend\\b",
@ -151,6 +153,12 @@ func tokenize():
if result == null || result.get_start() != 0 : if result == null || result.get_start() != 0 :
continue continue
# Skip Comments
if type == TokenType.cmt_SL :
Cursor += result.get_string().length()
error = false
break
# Skip Whitespace # Skip Whitespace
if type == TokenType.fmt_S : if type == TokenType.fmt_S :
var addVal = result.get_string().length() var addVal = result.get_string().length()