nitc: add ANode::is_structural
authorJean Privat <jean@pryen.org>
Thu, 9 Feb 2017 17:05:13 +0000 (12:05 -0500)
committerJean Privat <jean@pryen.org>
Thu, 9 Feb 2017 17:05:13 +0000 (12:05 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser/parser_nodes.nit

index 261694a..b8d715d 100644 (file)
@@ -34,6 +34,9 @@ abstract class ANode
                sys.stderr.write "{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
        end
 
+       # Is `self` a token or a pure-structural production like `AQId`?
+       fun is_structural: Bool do return false
+
        # Write the subtree on stdout.
        # See `ASTDump`
        fun dump_tree
@@ -331,6 +334,8 @@ abstract class Token
        # See `blank_before` to get the whitespace that separate tokens.
        var is_loose = false
 
+       redef fun is_structural do return true
+
        # Loose tokens that precede `self`.
        #
        # These tokens start the line or belong to a line with only loose tokens.
@@ -1667,6 +1672,8 @@ class AQid
 
        # The final identifier
        var n_id: TId is writable, noinit
+
+       redef fun is_structural do return true
 end
 
 # A potentially qualified class identifier `foo::bar::Baz`
@@ -1677,6 +1684,8 @@ class AQclassid
 
        # The final identifier
        var n_id: TClassid is writable, noinit
+
+       redef fun is_structural do return true
 end
 
 # A signature in a method definition. eg `(x,y:X,z:Z):T`