tokenizer: Fix multiline comment regex

This commit is contained in:
James Westman 2021-11-24 19:12:59 -06:00
parent 7cab7da4bb
commit 3804d91118
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 26 additions and 1 deletions

View file

@ -57,7 +57,7 @@ _tokens = [
(TokenType.CLOSE_BLOCK, r"\}"),
(TokenType.STMT_END, r";"),
(TokenType.WHITESPACE, r"\s+"),
(TokenType.COMMENT, r"/\*[\s\S]*\*/"),
(TokenType.COMMENT, r"\/\*[\s\S]*?\*\/"),
(TokenType.COMMENT, r"\/\/[^\n]*"),
(TokenType.OPEN_BRACKET, r"\["),
(TokenType.CLOSE_BRACKET, r"\]"),

View file

@ -0,0 +1,15 @@
using Gtk 4.0;
using GObject 2.0;
GObject.Object {
/* multiline-style comment 1 */
}
Gtk.Label {
/* Translators: multiline-style comment 2 */
label: _("Test"); // single-line comment
/**/ visible: false; /**/
}
/* Note: The output XML does not need to contain translator comments. The
translation tooling reads blueprint files, not the generated files. */

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GObject"></object>
<object class="GtkLabel">
<property name="label" translatable="true">Test</property>
<property name="visible">false</property>
</object>
</interface>

View file

@ -96,6 +96,7 @@ class TestSamples(unittest.TestCase):
self.assert_sample("binding")
self.assert_sample("child_type")
self.assert_sample("combo_box_text")
self.assert_sample("comments")
self.assert_sample("enum")
self.assert_sample("file_filter")
self.assert_sample("flags")