From 856a1faa9c323a0a56b28f151f690ce8039bf647 Mon Sep 17 00:00:00 2001 From: Ed94 Date: Sun, 17 Jul 2022 11:27:10 -0400 Subject: [PATCH] Added support for comments. --- App/RegM/RegM_Viewer.tscn | 2 ++ App/RegM/Scripts/SRegex.Notes.md | 24 ++++++++++++++++++++++++ App/RegM/Scripts/SRegex.gd | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/App/RegM/RegM_Viewer.tscn b/App/RegM/RegM_Viewer.tscn index c1d1030..615f15f 100644 --- a/App/RegM/RegM_Viewer.tscn +++ b/App/RegM/RegM_Viewer.tscn @@ -26,8 +26,10 @@ margin_left = 1.2 margin_right = 0.375977 grow_horizontal = 0 theme = ExtResource( 2 ) +readonly = true highlight_current_line = true show_line_numbers = true +wrap_enabled = true [node name="SRegEx_TEdit" type="TextEdit" parent="."] anchor_left = 0.525 diff --git a/App/RegM/Scripts/SRegex.Notes.md b/App/RegM/Scripts/SRegex.Notes.md index c44f679..51705e7 100644 --- a/App/RegM/Scripts/SRegex.Notes.md +++ b/App/RegM/Scripts/SRegex.Notes.md @@ -146,3 +146,27 @@ start \" !set( \" ).repeat(0-) \" start "null" start "this" 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 \ No newline at end of file diff --git a/App/RegM/Scripts/SRegex.gd b/App/RegM/Scripts/SRegex.gd index a1fd574..a47141c 100644 --- a/App/RegM/Scripts/SRegex.gd +++ b/App/RegM/Scripts/SRegex.gd @@ -15,6 +15,7 @@ extends Object const TokenType : Dictionary = \ { fmt_S = "Formatting", + cmt_SL = "Comment Single Line", str_start = "String Start", str_end = "String End", @@ -55,6 +56,7 @@ const TokenType : Dictionary = \ const Spec : Dictionary = \ { TokenType.fmt_S : "^\\s", + TokenType.cmt_SL: "^^\\(\\?\\#.*?\\)", TokenType.str_start : "^\\bstart\\b", TokenType.str_end : "^\\bend\\b", @@ -151,6 +153,12 @@ func tokenize(): if result == null || result.get_start() != 0 : continue + # Skip Comments + if type == TokenType.cmt_SL : + Cursor += result.get_string().length() + error = false + break + # Skip Whitespace if type == TokenType.fmt_S : var addVal = result.get_string().length()