[vala/wip/genie: 2/4] genie: More robust comment recognition
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/genie: 2/4] genie: More robust comment recognition
- Date: Sat, 6 May 2017 21:20:25 +0000 (UTC)
commit a4290f47bbe274bc9c623e894bd270ebdd52bbcf
Author: vlad1777d <naumovvladislav mail ru>
Date: Mon May 1 00:06:45 2017 +0300
genie: More robust comment recognition
tests/genie/comments/test_bug_592369.gs | 35 +
tests/genie/comments/test_comments_general.gs | 2113 ++++++++++++++++++++
.../comments/test_comments_inner_structure.gs | 214 ++
vala/valageniescanner.vala | 8 -
4 files changed, 2362 insertions(+), 8 deletions(-)
---
diff --git a/tests/genie/comments/test_bug_592369.gs b/tests/genie/comments/test_bug_592369.gs
new file mode 100644
index 0000000..531ef62
--- /dev/null
+++ b/tests/genie/comments/test_bug_592369.gs
@@ -0,0 +1,35 @@
+init // comment
+/* comment */
+ d: int = 0
+ var j = 0
+// i = 0
+
+ // i = 0
+// i = 0
+ // i = 0
+ // i = 0
+ if j != 0 //this is possible, earlier was "i != 0", which was, of course, impossible
+ d = 4 /* comment
+ comment */
+ else
+ /* comment */
+ d = 5
+ /* comment */
+
+ assert j == 0
+ assert d == 5
+
+ if_if_slc_indent()
+
+
+def if_if_slc_indent()
+ var hit = false
+ if false
+ pass
+ if false
+ pass
+ //indented comment
+ if true
+ hit = true
+
+ assert hit == true
diff --git a/tests/genie/comments/test_comments_general.gs b/tests/genie/comments/test_comments_general.gs
new file mode 100644
index 0000000..ee6f5e6
--- /dev/null
+++ b/tests/genie/comments/test_comments_general.gs
@@ -0,0 +1,2113 @@
+
+init
+
+ if_if_slc_normal ()
+ if_if_slc_indent ()
+ if_if_slc_dedent ()
+ if_if_slc_nodent ()
+ if_if_expr_slc_normal ()
+ if_if_mlc_normal_1 ()
+ if_if_mlc_indent_1 ()
+ if_if_mlc_dedent_1 ()
+ if_if_mlc_nodent_1 ()
+ if_if_expr_mlc_normal_1 ()
+ if_if_mlc_normal_n ()
+ if_if_mlc_indent_n ()
+ if_if_mlc_dedent_n ()
+ if_if_mlc_nodent_n ()
+ if_if_expr_mlc_normal_n ()
+ if_if_docc_normal_1 ()
+ if_if_docc_indent_1 ()
+ if_if_docc_dedent_1 ()
+ if_if_docc_nodent_1 ()
+ if_if_expr_docc_normal_1 ()
+ if_if_docc_normal_n ()
+ if_if_docc_indent_n ()
+ if_if_docc_dedent_n ()
+ if_if_docc_nodent_n ()
+ if_if_expr_docc_normal_n ()
+
+ if_else_slc_normal ()
+ if_else_slc_indent ()
+ if_else_slc_dedent ()
+ if_else_slc_nodent ()
+ if_else_expr_slc_normal ()
+ if_else_mlc_normal_1 ()
+ if_else_mlc_indent_1 ()
+ if_else_mlc_dedent_1 ()
+ if_else_mlc_nodent_1 ()
+ if_else_expr_mlc_normal_1 ()
+ if_else_mlc_normal_n ()
+ if_else_mlc_indent_n ()
+ if_else_mlc_dedent_n ()
+ if_else_mlc_nodent_n ()
+ if_else_expr_mlc_normal_n ()
+ if_else_docc_normal_1 ()
+ if_else_docc_indent_1 ()
+ if_else_docc_dedent_1 ()
+ if_else_docc_nodent_1 ()
+ if_else_expr_docc_normal_1 ()
+ if_else_docc_normal_n ()
+ if_else_docc_indent_n ()
+ if_else_docc_dedent_n ()
+ if_else_docc_nodent_n ()
+ if_else_expr_docc_normal_n ()
+
+ if_assign_slc_normal ()
+ if_assign_slc_indent ()
+ if_assign_slc_dedent ()
+ if_assign_slc_nodent ()
+ if_assign_expr_slc_normal ()
+ if_assign_mlc_normal_1 ()
+ if_assign_mlc_indent_1 ()
+ if_assign_mlc_dedent_1 ()
+ if_assign_mlc_nodent_1 ()
+ if_assign_expr_mlc_normal_1 ()
+ if_assign_mlc_normal_n ()
+ if_assign_mlc_indent_n ()
+ if_assign_mlc_dedent_n ()
+ if_assign_mlc_nodent_n ()
+ if_assign_expr_mlc_normal_n ()
+ if_assign_docc_normal_1 ()
+ if_assign_docc_indent_1 ()
+ if_assign_docc_dedent_1 ()
+ if_assign_docc_nodent_1 ()
+ if_assign_expr_docc_normal_1 ()
+ if_assign_docc_normal_n ()
+ if_assign_docc_indent_n ()
+ if_assign_docc_dedent_n ()
+ if_assign_docc_nodent_n ()
+ if_assign_expr_docc_normal_n ()
+
+ try_except_slc_normal ()
+ try_except_slc_indent ()
+ try_except_slc_dedent ()
+ try_except_slc_nodent ()
+ try_except_expr_slc_normal ()
+ try_except_mlc_normal_1 ()
+ try_except_mlc_indent_1 ()
+ try_except_mlc_dedent_1 ()
+ try_except_mlc_nodent_1 ()
+ try_except_expr_mlc_normal_1 ()
+ try_except_mlc_normal_n ()
+ try_except_mlc_indent_n ()
+ try_except_mlc_dedent_n ()
+ try_except_mlc_nodent_n ()
+ try_except_expr_mlc_normal_n ()
+ try_except_docc_normal_1 ()
+ try_except_docc_indent_1 ()
+ try_except_docc_dedent_1 ()
+ try_except_docc_nodent_1 ()
+ try_except_expr_docc_normal_1 ()
+ try_except_docc_normal_n ()
+ try_except_docc_indent_n ()
+ try_except_docc_dedent_n ()
+ try_except_docc_nodent_n ()
+ try_except_expr_docc_normal_n ()
+
+ do_while_slc_normal ()
+ do_while_slc_indent ()
+ do_while_slc_dedent ()
+ do_while_slc_nodent ()
+ do_while_expr_slc_normal ()
+ do_while_mlc_normal_1 ()
+ do_while_mlc_indent_1 ()
+ do_while_mlc_dedent_1 ()
+ do_while_mlc_nodent_1 ()
+ do_while_expr_mlc_normal_1 ()
+ do_while_mlc_normal_n ()
+ do_while_mlc_indent_n ()
+ do_while_mlc_dedent_n ()
+ do_while_mlc_nodent_n ()
+ do_while_expr_mlc_normal_n ()
+ do_while_docc_normal_1 ()
+ do_while_docc_indent_1 ()
+ do_while_docc_dedent_1 ()
+ do_while_docc_nodent_1 ()
+ do_while_expr_docc_normal_1 ()
+ do_while_docc_normal_n ()
+ do_while_docc_indent_n ()
+ do_while_docc_dedent_n ()
+ do_while_docc_nodent_n ()
+ do_while_expr_docc_normal_n ()
+
+ /*class_class_slc_normal)
+ class_class_slc_indent)
+ class_class_slc_dedent)
+ class_class_slc_nodent)
+ class_class_expr_slc_normal)
+ class_class_mlc_normal_1)
+ class_class_mlc_indent_1)
+ class_class_mlc_dedent_1)
+ class_class_mlc_nodent_1)
+ class_class_expr_mlc_normal_1)
+ class_class_mlc_normal_n)
+ class_class_mlc_indent_n)
+ class_class_mlc_dedent_n)
+ class_class_mlc_nodent_n)
+ class_class_expr_mlc_normal_n)
+ class_class_docc_normal_1)
+ class_class_docc_indent_1)
+ class_class_docc_dedent_1)
+ class_class_docc_nodent_1)
+ class_class_expr_docc_normal_1)
+ class_class_docc_normal_n)
+ class_class_docc_indent_n)
+ class_class_docc_dedent_n)
+ class_class_docc_nodent_n)
+ class_class_expr_docc_normal_n)*/
+
+ def_def_a_slc_normal ()
+ def_def_b_slc_normal ()
+ def_def_a_slc_indent ()
+ def_def_b_slc_indent ()
+ def_def_a_slc_dedent ()
+ def_def_b_slc_dedent ()
+ def_def_a_slc_nodent ()
+ def_def_b_slc_nodent ()
+ def_def_a_expr_slc_normal ()
+ def_def_b_expr_slc_normal ()
+ def_def_a_mlc_normal_1 ()
+ def_def_b_mlc_normal_1 ()
+ def_def_a_mlc_indent_1 ()
+ def_def_b_mlc_indent_1 ()
+ def_def_a_mlc_dedent_1 ()
+ def_def_b_mlc_dedent_1 ()
+ def_def_a_mlc_nodent_1 ()
+ def_def_b_mlc_nodent_1 ()
+ def_def_a_expr_mlc_normal_1 ()
+ def_def_b_expr_mlc_normal_1 ()
+ def_def_a_mlc_normal_n ()
+ def_def_b_mlc_normal_n ()
+ def_def_a_mlc_indent_n ()
+ def_def_b_mlc_indent_n ()
+ def_def_a_mlc_dedent_n ()
+ def_def_b_mlc_dedent_n ()
+ def_def_a_mlc_nodent_n ()
+ def_def_b_mlc_nodent_n ()
+ def_def_a_expr_mlc_normal_n ()
+ def_def_b_expr_mlc_normal_n ()
+ def_def_a_docc_normal_1 ()
+ def_def_b_docc_normal_1 ()
+ def_def_a_docc_indent_1 ()
+ def_def_b_docc_indent_1 ()
+ def_def_a_docc_dedent_1 ()
+ def_def_b_docc_dedent_1 ()
+ def_def_a_docc_nodent_1 ()
+ def_def_b_docc_nodent_1 ()
+ def_def_a_expr_docc_normal_1 ()
+ def_def_b_expr_docc_normal_1 ()
+ def_def_a_docc_normal_n ()
+ def_def_b_docc_normal_n ()
+ def_def_a_docc_indent_n ()
+ def_def_b_docc_indent_n ()
+ def_def_a_docc_dedent_n ()
+ def_def_b_docc_dedent_n ()
+ def_def_a_docc_nodent_n ()
+ def_def_b_docc_nodent_n ()
+ def_def_a_expr_docc_normal_n ()
+ def_def_b_expr_docc_normal_n ()
+
+
+
+def if_if_slc_normal()
+ var hit = false
+ if false
+ pass
+ //normal comment
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_slc_indent()
+ var hit = false
+ if false
+ pass
+ //indented comment
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_slc_dedent()
+ var hit = false
+ if false
+ pass
+ //dedented comment
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_slc_nodent()
+ var hit = false
+ if false
+ pass
+//column zero comment
+ if true
+ hit = true
+
+ assert hit is true
+
+
+def if_if_expr_slc_normal()
+ var hit = false
+ if false
+ pass
+ pass //post-expression comment
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ /*normal comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_indent_1()
+ var hit = false
+ if false
+ pass
+ /*indented comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /*dedented comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_nodent_1()
+ var hit = false
+ if false
+ pass
+/*column zero comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_expr_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /*post-expression comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ /*
+ normal comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_indent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ indented comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ dedented comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_mlc_nodent_n()
+ var hit = false
+ if false
+ pass
+/*
+column zero comment
+*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_expr_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /*
+post-expression comment
+*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ /**normal comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_indent_1()
+ var hit = false
+ if false
+ pass
+ /**indented comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /**dedented comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_nodent_1()
+ var hit = false
+ if false
+ pass
+/**column zero comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_expr_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /**post-expression comment*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ /**
+ normal comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_indent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ indented comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ dedented comment
+ */
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_docc_nodent_n()
+ var hit = false
+ if false
+ pass
+/**
+column zero comment
+*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+def if_if_expr_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /**
+post-expression comment
+*/
+ if true
+ hit = true
+
+ assert(hit is true)
+
+
+
+def if_else_slc_normal()
+ var hit = false
+ if false
+ pass
+ //normal comment
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_slc_indent()
+ var hit = false
+ if false
+ pass
+ //indented comment
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_slc_dedent()
+ var hit = false
+ if false
+ pass
+ //dedented comment
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_slc_nodent()
+ var hit = false
+ if false
+ pass
+//column zero comment
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_expr_slc_normal()
+ var hit = false
+ if false
+ pass
+ pass //post-expression comment
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ /*normal comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_indent_1()
+ var hit = false
+ if false
+ pass
+ /*indented comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /*dedented comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_nodent_1()
+ var hit = false
+ if false
+ pass
+/*column zero comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_expr_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /*post-expression comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ /*
+ normal comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_indent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ indented comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ dedented comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_mlc_nodent_n()
+ var hit = false
+ if false
+ pass
+/*
+column zero comment
+*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_expr_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /*
+post-expression comment
+*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ /**normal comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_indent_1()
+ var hit = false
+ if false
+ pass
+ /**indented comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /**dedented comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_nodent_1()
+ var hit = false
+ if false
+ pass
+/**column zero comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_expr_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /**post-expression comment*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ /**
+ normal comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_indent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ indented comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ dedented comment
+ */
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_docc_nodent_n()
+ var hit = false
+ if false
+ pass
+/**
+column zero comment
+*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+def if_else_expr_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /**
+post-expression comment
+*/
+ else
+ hit = true
+
+ assert(hit is true)
+
+
+
+def if_assign_slc_normal()
+ var hit = false
+ if false
+ pass
+ //normal comment
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_slc_indent()
+ var hit = false
+ if false
+ pass
+ //indented comment
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_slc_dedent()
+ var hit = false
+ if false
+ pass
+ //dedented comment
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_slc_nodent()
+ var hit = false
+ if false
+ pass
+//column zero comment
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_expr_slc_normal()
+ var hit = false
+ if false
+ pass
+ pass //post-expression comment
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ /*normal comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_indent_1()
+ var hit = false
+ if false
+ pass
+ /*indented comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /*dedented comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_nodent_1()
+ var hit = false
+ if false
+ pass
+/*column zero comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_expr_mlc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /*post-expression comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ /*
+ normal comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_indent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ indented comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /*
+ dedented comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_mlc_nodent_n()
+ var hit = false
+ if false
+ pass
+/*
+column zero comment
+*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_expr_mlc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /*
+post-expression comment
+*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ /**normal comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_indent_1()
+ var hit = false
+ if false
+ pass
+ /**indented comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_dedent_1()
+ var hit = false
+ if false
+ pass
+ /**dedented comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_nodent_1()
+ var hit = false
+ if false
+ pass
+/**column zero comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_expr_docc_normal_1()
+ var hit = false
+ if false
+ pass
+ pass /**post-expression comment*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ /**
+ normal comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_indent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ indented comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_dedent_n()
+ var hit = false
+ if false
+ pass
+ /**
+ dedented comment
+ */
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_docc_nodent_n()
+ var hit = false
+ if false
+ pass
+/**
+column zero comment
+*/
+ hit = true
+
+ assert(hit is true)
+
+
+def if_assign_expr_docc_normal_n()
+ var hit = false
+ if false
+ pass
+ pass /**
+post-expression comment
+*/
+ hit = true
+
+ assert(hit is true)
+
+
+
+def never_raise() raises Error
+ pass
+
+
+def try_except_slc_normal()
+ try
+ never_raise()
+ //normal comment
+ except e : Error
+ pass
+
+
+def try_except_slc_indent()
+ try
+ never_raise()
+ //indented comment
+ except e : Error
+ pass
+
+
+def try_except_slc_dedent()
+ try
+ never_raise()
+ //dedented comment
+ except e : Error
+ pass
+
+
+def try_except_slc_nodent()
+ try
+ never_raise()
+//column zero comment
+ except e : Error
+ pass
+
+
+def try_except_expr_slc_normal()
+ try
+ never_raise()
+ pass //post-expression comment
+ except e : Error
+ pass
+
+
+def try_except_mlc_normal_1()
+ try
+ never_raise()
+ /*normal comment*/
+ except e : Error
+ pass
+
+
+def try_except_mlc_indent_1()
+ try
+ never_raise()
+ /*indented comment*/
+ except e : Error
+ pass
+
+
+def try_except_mlc_dedent_1()
+ try
+ never_raise()
+ /*dedented comment*/
+ except e : Error
+ pass
+
+
+def try_except_mlc_nodent_1()
+ try
+ never_raise()
+/*column zero comment*/
+ except e : Error
+ pass
+
+
+def try_except_expr_mlc_normal_1()
+ try
+ never_raise()
+ pass /*post-expression comment*/
+ except e : Error
+ pass
+
+
+def try_except_mlc_normal_n()
+ try
+ never_raise()
+ /*
+ normal comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_mlc_indent_n()
+ try
+ never_raise()
+ /*
+ indented comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_mlc_dedent_n()
+ try
+ never_raise()
+ /*
+ dedented comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_mlc_nodent_n()
+ try
+ never_raise()
+/*
+column zero comment
+*/
+ except e : Error
+ pass
+
+
+def try_except_expr_mlc_normal_n()
+ try
+ never_raise()
+ pass /*
+post-expression comment
+*/
+ except e : Error
+ pass
+
+
+def try_except_docc_normal_1()
+ try
+ never_raise()
+ /**normal comment*/
+ except e : Error
+ pass
+
+
+def try_except_docc_indent_1()
+ try
+ never_raise()
+ /**indented comment*/
+ except e : Error
+ pass
+
+
+def try_except_docc_dedent_1()
+ try
+ never_raise()
+ /**dedented comment*/
+ except e : Error
+ pass
+
+
+def try_except_docc_nodent_1()
+ try
+ never_raise()
+/**column zero comment*/
+ except e : Error
+ pass
+
+
+def try_except_expr_docc_normal_1()
+ try
+ never_raise()
+ pass /**post-expression comment*/
+ except e : Error
+ pass
+
+
+def try_except_docc_normal_n()
+ try
+ never_raise()
+ /**
+ normal comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_docc_indent_n()
+ try
+ never_raise()
+ /**
+ indented comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_docc_dedent_n()
+ try
+ never_raise()
+ /**
+ dedented comment
+ */
+ except e : Error
+ pass
+
+
+def try_except_docc_nodent_n()
+ try
+ never_raise()
+/**
+column zero comment
+*/
+ except e : Error
+ pass
+
+
+def try_except_expr_docc_normal_n()
+ try
+ never_raise()
+ pass /**
+post-expression comment
+*/
+ except e : Error
+ pass
+
+
+
+def do_while_slc_normal()
+ do
+ pass
+ //normal comment
+ while false
+
+
+def do_while_slc_indent()
+ do
+ pass
+ //indented comment
+ while false
+
+
+def do_while_slc_dedent()
+ do
+ pass
+ //dedented comment
+ while false
+
+
+def do_while_slc_nodent()
+ do
+ pass
+//column zero comment
+ while false
+
+
+def do_while_expr_slc_normal()
+ do
+ pass
+ pass //post-expression comment
+ while false
+
+
+def do_while_mlc_normal_1()
+ do
+ pass
+ /*normal comment*/
+ while false
+
+
+def do_while_mlc_indent_1()
+ do
+ pass
+ /*indented comment*/
+ while false
+
+
+def do_while_mlc_dedent_1()
+ do
+ pass
+ /*dedented comment*/
+ while false
+
+
+def do_while_mlc_nodent_1()
+ do
+ pass
+/*column zero comment*/
+ while false
+
+
+def do_while_expr_mlc_normal_1()
+ do
+ pass
+ pass /*post-expression comment*/
+ while false
+
+
+def do_while_mlc_normal_n()
+ do
+ pass
+ /*
+ normal comment
+ */
+ while false
+
+
+def do_while_mlc_indent_n()
+ do
+ pass
+ /*
+ indented comment
+ */
+ while false
+
+
+def do_while_mlc_dedent_n()
+ do
+ pass
+ /*
+ dedented comment
+ */
+ while false
+
+
+def do_while_mlc_nodent_n()
+ do
+ pass
+/*
+column zero comment
+*/
+ while false
+
+
+def do_while_expr_mlc_normal_n()
+ do
+ pass
+ pass /*
+post-expression comment
+*/
+ while false
+
+
+def do_while_docc_normal_1()
+ do
+ pass
+ /**normal comment*/
+ while false
+
+
+def do_while_docc_indent_1()
+ do
+ pass
+ /**indented comment*/
+ while false
+
+
+def do_while_docc_dedent_1()
+ do
+ pass
+ /**dedented comment*/
+ while false
+
+
+def do_while_docc_nodent_1()
+ do
+ pass
+/**column zero comment*/
+ while false
+
+
+def do_while_expr_docc_normal_1()
+ do
+ pass
+ pass /**post-expression comment*/
+ while false
+
+
+def do_while_docc_normal_n()
+ do
+ pass
+ /**
+ normal comment
+ */
+ while false
+
+
+def do_while_docc_indent_n()
+ do
+ pass
+ /**
+ indented comment
+ */
+ while false
+
+
+def do_while_docc_dedent_n()
+ do
+ pass
+ /**
+ dedented comment
+ */
+ while false
+
+
+def do_while_docc_nodent_n()
+ do
+ pass
+/**
+column zero comment
+*/
+ while false
+
+
+def do_while_expr_docc_normal_n()
+ do
+ pass
+ pass /**
+post-expression comment
+*/
+ while false
+
+
+
+
+def class_class_slc_normal()
+ new ClassClassAslc_normal
+ new ClassClassBslc_normal
+
+class ClassClassAslc_normal
+ construct()
+ pass
+ //normal comment
+class ClassClassBslc_normal
+ construct()
+ pass
+
+
+
+def class_class_slc_indent()
+ new ClassClassAslc_indent
+ new ClassClassBslc_indent
+
+class ClassClassAslc_indent
+ construct()
+ pass
+ //indented comment
+class ClassClassBslc_indent
+ construct()
+ pass
+
+
+
+def class_class_slc_dedent()
+ new ClassClassAslc_dedent
+ new ClassClassBslc_dedent
+
+class ClassClassAslc_dedent
+ construct()
+ pass
+ //dedented comment
+class ClassClassBslc_dedent
+ construct()
+ pass
+
+
+
+def class_class_slc_nodent()
+ new ClassClassAslc_nodent
+ new ClassClassBslc_nodent
+
+class ClassClassAslc_nodent
+ construct()
+ pass
+//column zero comment
+class ClassClassBslc_nodent
+ construct()
+ pass
+
+
+
+def class_class_expr_slc_normal()
+ new ClassClassAexpr_slc_normal
+ new ClassClassBexpr_slc_normal
+
+class ClassClassAexpr_slc_normal
+ construct()
+ pass
+ pass //post-expression comment
+class ClassClassBexpr_slc_normal
+ construct()
+ pass
+
+
+
+def class_class_mlc_normal_1()
+ new ClassClassAmlc_normal_1
+ new ClassClassBmlc_normal_1
+
+class ClassClassAmlc_normal_1
+ construct()
+ pass
+ /*normal comment*/
+class ClassClassBmlc_normal_1
+ construct()
+ pass
+
+
+
+def class_class_mlc_indent_1()
+ new ClassClassAmlc_indent_1
+ new ClassClassBmlc_indent_1
+
+class ClassClassAmlc_indent_1
+ construct()
+ pass
+ /*indented comment*/
+class ClassClassBmlc_indent_1
+ construct()
+ pass
+
+
+
+def class_class_mlc_dedent_1()
+ new ClassClassAmlc_dedent_1
+ new ClassClassBmlc_dedent_1
+
+class ClassClassAmlc_dedent_1
+ construct()
+ pass
+ /*dedented comment*/
+class ClassClassBmlc_dedent_1
+ construct()
+ pass
+
+
+
+def class_class_mlc_nodent_1()
+ new ClassClassAmlc_nodent_1
+ new ClassClassBmlc_nodent_1
+
+class ClassClassAmlc_nodent_1
+ construct()
+ pass
+/*column zero comment*/
+class ClassClassBmlc_nodent_1
+ construct()
+ pass
+
+
+
+def class_class_expr_mlc_normal_1()
+ new ClassClassAexpr_mlc_normal_1
+ new ClassClassBexpr_mlc_normal_1
+
+class ClassClassAexpr_mlc_normal_1
+ construct()
+ pass
+ pass /*post-expression comment*/
+class ClassClassBexpr_mlc_normal_1
+ construct()
+ pass
+
+
+
+def class_class_mlc_normal_n()
+ new ClassClassAmlc_normal_n
+ new ClassClassBmlc_normal_n
+
+class ClassClassAmlc_normal_n
+ construct()
+ pass
+ /*
+ normal comment
+ */
+class ClassClassBmlc_normal_n
+ construct()
+ pass
+
+
+
+def class_class_mlc_indent_n()
+ new ClassClassAmlc_indent_n
+ new ClassClassBmlc_indent_n
+
+class ClassClassAmlc_indent_n
+ construct()
+ pass
+ /*
+ indented comment
+ */
+class ClassClassBmlc_indent_n
+ construct()
+ pass
+
+
+
+def class_class_mlc_dedent_n()
+ new ClassClassAmlc_dedent_n
+ new ClassClassBmlc_dedent_n
+
+class ClassClassAmlc_dedent_n
+ construct()
+ pass
+ /*
+ dedented comment
+ */
+class ClassClassBmlc_dedent_n
+ construct()
+ pass
+
+
+
+def class_class_mlc_nodent_n()
+ new ClassClassAmlc_nodent_n
+ new ClassClassBmlc_nodent_n
+
+class ClassClassAmlc_nodent_n
+ construct()
+ pass
+/*
+column zero comment
+*/
+class ClassClassBmlc_nodent_n
+ construct()
+ pass
+
+
+
+def class_class_expr_mlc_normal_n()
+ new ClassClassAexpr_mlc_normal_n
+ new ClassClassBexpr_mlc_normal_n
+
+class ClassClassAexpr_mlc_normal_n
+ construct()
+ pass
+ pass /*
+post-expression comment
+*/
+class ClassClassBexpr_mlc_normal_n
+ construct()
+ pass
+
+
+
+def class_class_docc_normal_1()
+ new ClassClassAdocc_normal_1
+ new ClassClassBdocc_normal_1
+
+class ClassClassAdocc_normal_1
+ construct()
+ pass
+ /**normal comment*/
+class ClassClassBdocc_normal_1
+ construct()
+ pass
+
+
+
+def class_class_docc_indent_1()
+ new ClassClassAdocc_indent_1
+ new ClassClassBdocc_indent_1
+
+class ClassClassAdocc_indent_1
+ construct()
+ pass
+ /**indented comment*/
+class ClassClassBdocc_indent_1
+ construct()
+ pass
+
+
+
+def class_class_docc_dedent_1()
+ new ClassClassAdocc_dedent_1
+ new ClassClassBdocc_dedent_1
+
+class ClassClassAdocc_dedent_1
+ construct()
+ pass
+ /**dedented comment*/
+class ClassClassBdocc_dedent_1
+ construct()
+ pass
+
+
+
+def class_class_docc_nodent_1()
+ new ClassClassAdocc_nodent_1
+ new ClassClassBdocc_nodent_1
+
+class ClassClassAdocc_nodent_1
+ construct()
+ pass
+/**column zero comment*/
+class ClassClassBdocc_nodent_1
+ construct()
+ pass
+
+
+
+def class_class_expr_docc_normal_1()
+ new ClassClassAexpr_docc_normal_1
+ new ClassClassBexpr_docc_normal_1
+
+class ClassClassAexpr_docc_normal_1
+ construct()
+ pass
+ pass /**post-expression comment*/
+class ClassClassBexpr_docc_normal_1
+ construct()
+ pass
+
+
+
+def class_class_docc_normal_n()
+ new ClassClassAdocc_normal_n
+ new ClassClassBdocc_normal_n
+
+class ClassClassAdocc_normal_n
+ construct()
+ pass
+ /**
+ normal comment
+ */
+class ClassClassBdocc_normal_n
+ construct()
+ pass
+
+
+
+def class_class_docc_indent_n()
+ new ClassClassAdocc_indent_n
+ new ClassClassBdocc_indent_n
+
+class ClassClassAdocc_indent_n
+ construct()
+ pass
+ /**
+ indented comment
+ */
+class ClassClassBdocc_indent_n
+ construct()
+ pass
+
+
+
+def class_class_docc_dedent_n()
+ new ClassClassAdocc_dedent_n
+ new ClassClassBdocc_dedent_n
+
+class ClassClassAdocc_dedent_n
+ construct()
+ pass
+ /**
+ dedented comment
+ */
+class ClassClassBdocc_dedent_n
+ construct()
+ pass
+
+
+
+def class_class_docc_nodent_n()
+ new ClassClassAdocc_nodent_n
+ new ClassClassBdocc_nodent_n
+
+class ClassClassAdocc_nodent_n
+ construct()
+ pass
+/**
+column zero comment
+*/
+class ClassClassBdocc_nodent_n
+ construct()
+ pass
+
+
+
+def class_class_expr_docc_normal_n()
+ new ClassClassAexpr_docc_normal_n
+ new ClassClassBexpr_docc_normal_n
+
+class ClassClassAexpr_docc_normal_n
+ construct()
+ pass
+ pass /**
+post-expression comment
+*/
+class ClassClassBexpr_docc_normal_n
+ construct()
+ pass
+
+
+
+def def_def_a_slc_normal()
+ if true
+ pass
+ //normal comment
+
+def def_def_b_slc_normal()
+ pass
+
+
+def def_def_a_slc_indent()
+ if true
+ pass
+ //indented comment
+
+def def_def_b_slc_indent()
+ pass
+
+
+def def_def_a_slc_dedent()
+ if true
+ pass
+ //dedented comment
+
+def def_def_b_slc_dedent()
+ pass
+
+
+def def_def_a_slc_nodent()
+ if true
+ pass
+//column zero comment
+
+def def_def_b_slc_nodent()
+ pass
+
+
+def def_def_a_expr_slc_normal()
+ if true
+ pass
+ pass //post-expression comment
+
+def def_def_b_expr_slc_normal()
+ pass
+
+
+def def_def_a_mlc_normal_1()
+ if true
+ pass
+ /*normal comment*/
+
+def def_def_b_mlc_normal_1()
+ pass
+
+
+def def_def_a_mlc_indent_1()
+ if true
+ pass
+ /*indented comment*/
+
+def def_def_b_mlc_indent_1()
+ pass
+
+
+def def_def_a_mlc_dedent_1()
+ if true
+ pass
+ /*dedented comment*/
+
+def def_def_b_mlc_dedent_1()
+ pass
+
+
+def def_def_a_mlc_nodent_1()
+ if true
+ pass
+/*column zero comment*/
+
+def def_def_b_mlc_nodent_1()
+ pass
+
+
+def def_def_a_expr_mlc_normal_1()
+ if true
+ pass
+ pass /*post-expression comment*/
+
+def def_def_b_expr_mlc_normal_1()
+ pass
+
+
+def def_def_a_mlc_normal_n()
+ if true
+ pass
+ /*
+ normal comment
+ */
+
+def def_def_b_mlc_normal_n()
+ pass
+
+
+def def_def_a_mlc_indent_n()
+ if true
+ pass
+ /*
+ indented comment
+ */
+
+def def_def_b_mlc_indent_n()
+ pass
+
+
+def def_def_a_mlc_dedent_n()
+ if true
+ pass
+ /*
+ dedented comment
+ */
+
+def def_def_b_mlc_dedent_n()
+ pass
+
+
+def def_def_a_mlc_nodent_n()
+ if true
+ pass
+/*
+column zero comment
+*/
+
+def def_def_b_mlc_nodent_n()
+ pass
+
+
+def def_def_a_expr_mlc_normal_n()
+ if true
+ pass
+ pass /*
+post-expression comment
+*/
+
+def def_def_b_expr_mlc_normal_n()
+ pass
+
+
+def def_def_a_docc_normal_1()
+ if true
+ pass
+ /**normal comment*/
+
+def def_def_b_docc_normal_1()
+ pass
+
+
+def def_def_a_docc_indent_1()
+ if true
+ pass
+ /**indented comment*/
+
+def def_def_b_docc_indent_1()
+ pass
+
+
+def def_def_a_docc_dedent_1()
+ if true
+ pass
+ /**dedented comment*/
+
+def def_def_b_docc_dedent_1()
+ pass
+
+
+def def_def_a_docc_nodent_1()
+ if true
+ pass
+/**column zero comment*/
+
+def def_def_b_docc_nodent_1()
+ pass
+
+
+def def_def_a_expr_docc_normal_1()
+ if true
+ pass
+ pass /**post-expression comment*/
+
+def def_def_b_expr_docc_normal_1()
+ pass
+
+
+def def_def_a_docc_normal_n()
+ if true
+ pass
+ /**
+ normal comment
+ */
+
+def def_def_b_docc_normal_n()
+ pass
+
+
+def def_def_a_docc_indent_n()
+ if true
+ pass
+ /**
+ indented comment
+ */
+
+def def_def_b_docc_indent_n()
+ pass
+
+
+def def_def_a_docc_dedent_n()
+ if true
+ pass
+ /**
+ dedented comment
+ */
+
+def def_def_b_docc_dedent_n()
+ pass
+
+
+def def_def_a_docc_nodent_n()
+ if true
+ pass
+/**
+column zero comment
+*/
+
+def def_def_b_docc_nodent_n()
+ pass
+
+
+def def_def_a_expr_docc_normal_n()
+ if true
+ pass
+ pass /**
+post-expression comment
+*/
+
+def def_def_b_expr_docc_normal_n()
+ pass
+
+
+
diff --git a/tests/genie/comments/test_comments_inner_structure.gs
b/tests/genie/comments/test_comments_inner_structure.gs
new file mode 100644
index 0000000..4745026
--- /dev/null
+++ b/tests/genie/comments/test_comments_inner_structure.gs
@@ -0,0 +1,214 @@
+/* It's failing on newly compiled vala builds (with --pkg=libvala-0.38), but
+ * it was passed if I used:"--pkg=libvala-0.34" (installed to system),
+ * configured environment variable:
+ * XDG_DATA_DIRS="${XDG_DATA_DIRS}:/path_to_root_of_sources/share" valac 'path to this file'
+ */
+
+init
+
+ test_fc_slc_1 ()
+ test_fc_slc_2 ()
+ test_fc_slc_3 ()
+ test_fc_slc_4 ()
+
+ test_fc_mlc_1 ()
+ test_fc_mlc_2 ()
+ test_fc_mlc_3 ()
+ test_fc_mlc_4 ()
+
+ test_fc_docc_1 ()
+ test_fc_docc_2 ()
+ test_fc_docc_3 ()
+ test_fc_docc_4 ()
+
+
+class Comment : Object
+ prop line : int
+ prop column : int
+ prop content : string
+ construct(line : int, column : int, content : string)
+ _line = line
+ _column = column
+ _content = content
+
+class Source
+ prop content : string
+ prop comments : array of Comment
+
+def test_fc_slc_1()
+ do_test(new Source() {
+ content =
+"""[indent=4]
+init
+ pass
+"""
+ })
+
+def test_fc_slc_2()
+ do_test(new Source() {
+ content =
+"""//comment1
+[indent=4]
+init
+ pass
+""",
+ comments = {new Comment(1, 1, "//comment1")}
+ })
+
+def test_fc_slc_3()
+ do_test(new Source() {
+ content =
+"""//comment1
+//comment2
+[indent=4]
+init
+ pass
+""",
+ comments = {new Comment(1, 1, "//comment1")}
+ })
+
+def test_fc_slc_4()
+ do_test(new Source() {
+ content =
+"""//comment1
+//comment2
+//comment3
+[indent=4]
+init
+ pass
+""",
+ comments = {new Comment(1, 1, "//comment1")}
+ })
+
+
+def test_fc_mlc_1()
+ do_test(new Source() {
+ content =
+"""/*comment1*/
+[indent=4]
+init
+ pass
+""",
+ comments = {new Comment(1, 1, "comment1")}
+ })
+
+def test_fc_mlc_2()
+ do_test(new Source() {
+ content =
+"""/*comment1*//*comment2*/
+[indent=4]
+init
+ pass
+""",
+ comments = {
+ new Comment(1, 1, "comment1"),
+ new Comment(1, 11, "comment2")
+ }
+ })
+
+def test_fc_mlc_3()
+ do_test(new Source() {
+ content =
+"""/*comment1*//*comment2*/
+/*comment3*/
+[indent=4]
+init
+ pass
+""",
+ comments = {
+ new Comment(1, 1, "comment1"),
+ new Comment(1, 11, "comment2")
+ }
+ })
+
+def test_fc_mlc_4()
+ do_test(new Source() {
+ content =
+"""/*comment1*/
+/*comment2*/
+/*comment3*/
+[indent=4]
+init
+ pass
+""",
+ comments = {
+ new Comment(1, 1, "comment1")
+ }
+ })
+
+def test_fc_docc_1()
+ do_test(new Source() {
+ content =
+"""/**comment1*/
+[indent=4]
+init
+ pass
+"""
+ })
+
+def test_fc_docc_2()
+ do_test(new Source() {
+ content =
+"""/**comment1*//**comment2*/
+[indent=4]
+init
+ pass
+"""
+ })
+
+def test_fc_docc_3()
+ do_test(new Source() {
+ content =
+"""/**comment1*//**comment2*/
+/**comment3*/
+[indent=4]
+init
+ pass
+"""
+ })
+
+def test_fc_docc_4()
+ do_test(new Source() {
+ content =
+"""/**comment1*/
+/**comment2*/
+/**comment3*/
+[indent=4]
+init
+ pass
+"""
+ })
+
+def do_test(source : Source)
+ var ctxt = new Vala.CodeContext()
+ Vala.CodeContext.push(ctxt)
+
+ var source_file = new Vala.SourceFile(ctxt,
+ Vala.SourceFileType.SOURCE,
+ "file_comment_test",
+ source.content)
+ var scanner = new Vala.Genie.Scanner(source_file)
+ scanner.indent_spaces = 4
+ scanner.parse_file_comments()
+
+ var actual_comments = source_file.get_comments()
+ var expected_comments = source.comments
+
+ assert(actual_comments.size is expected_comments.length)
+
+ for var i = 0 to (actual_comments.size - 1)
+ var actual_comment = actual_comments[i]
+ var expected_comment = expected_comments[i]
+ var actual_location = actual_comment.source_reference.begin
+ var actual_content = actual_comment.content
+
+ //print("line %02i, col %02i, len %02i: %s",
+ // actual_location.line,
+ // actual_location.column,
+ // actual_content.length,
+ // actual_content)
+
+ assert(actual_content is expected_comment.content)
+ assert(actual_location.line is expected_comment.line)
+ assert(actual_location.column is expected_comment.column)
+
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index e232a77..517e46d 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -1454,14 +1454,6 @@ public class Vala.Genie.Scanner {
current++;
}
- /* do not ignore EOL if comment does not exclusively occupy the line */
- if (current[0] == '\n' && last_token == TokenType.EOL) {
- current++;
- line++;
- column = 1;
- current_indent_level = 0;
- }
-
if (source_reference != null) {
push_comment (((string) begin).substring (0, (long) (current - begin)),
source_reference, file_comment);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]