xref: /plugin/combo/vendor/antlr/antlr4-php-runtime/src/Tree/SyntaxTree.php (revision 37748cd8654635afbeca80942126742f0f4cc346)
1*37748cd8SNickeau<?php
2*37748cd8SNickeau
3*37748cd8SNickeaudeclare(strict_types=1);
4*37748cd8SNickeau
5*37748cd8SNickeaunamespace Antlr\Antlr4\Runtime\Tree;
6*37748cd8SNickeau
7*37748cd8SNickeauuse Antlr\Antlr4\Runtime\Interval;
8*37748cd8SNickeau
9*37748cd8SNickeau/**
10*37748cd8SNickeau * A tree that knows about an interval in a token stream
11*37748cd8SNickeau * is some kind of syntax tree. Subinterfaces distinguish
12*37748cd8SNickeau * between parse trees and other kinds of syntax trees we might want to create.
13*37748cd8SNickeau */
14*37748cd8SNickeauinterface SyntaxTree extends Tree
15*37748cd8SNickeau{
16*37748cd8SNickeau    /**
17*37748cd8SNickeau     * Return an {@see Interval} indicating the index in the
18*37748cd8SNickeau     * {@see TokenStream} of the first and last token associated with this
19*37748cd8SNickeau     * subtree. If this node is a leaf, then the interval represents a single
20*37748cd8SNickeau     * token and has interval i..i for token index i.
21*37748cd8SNickeau     *
22*37748cd8SNickeau     * An interval of i..i-1 indicates an empty interval at position
23*37748cd8SNickeau     * i in the input stream, where 0 <= i <= the size of the input
24*37748cd8SNickeau     * token stream. Currently, the code base can only have i=0..n-1 but
25*37748cd8SNickeau     * in concept one could have an empty interval after EOF.
26*37748cd8SNickeau     *
27*37748cd8SNickeau     * If source interval is unknown, this returns {@see Interval::invalid()}.
28*37748cd8SNickeau     *
29*37748cd8SNickeau     * As a weird special case, the source interval for rules matched after
30*37748cd8SNickeau     * EOF is unspecified.
31*37748cd8SNickeau     */
32*37748cd8SNickeau    public function getSourceInterval() : Interval;
33*37748cd8SNickeau}
34