public final class StatementBoundaryDetector extends Object
Pp2TokenStream and produces a list of
StatementRanges — one per statement in the source.
Terminators recognized:
; — standard SQL statement separator. Every dialect.GO (keyword) — SQL Server / Sybase batch separator,
recognized only when the vendor is in the T-SQL family.; — string literals tokenize as
a single ttsqstring token; the inner ; never
appears as a ttsemicolon so no special case is needed.; — a BEGIN ... END;
block has internal semicolons at depth ≥ 1; only depth-0
semicolons split statements. The detector tracks BEGIN/END depth
and treats END IF / LOOP / WHILE / REPEAT / FOR as
inner-construct ends that do not pop the block-depth counter
(those keywords don't push depth, so there's nothing to pop).BEGIN block —
CASE pushes its own caseDepth counter so its
unqualified END doesn't accidentally pop the surrounding
block-depth. END CASE pops caseDepth (and the
trailing CASE keyword is consumed as a qualifier, not as
a new CASE push).TokenRole.NO_FORMAT_ZONE (by S9's
ProtectedZoneDetector) are treated as opaque: depth
is not adjusted, terminators are not consumed.StatementRange.Terminator.NONE.DECLARE ... BEGIN ... END; blocks where
the DECLARE clause has its own ; at depth 0 — the
detector will split there. S22's island recognizer can refine.
PL/SQL in practice almost always wraps in BEGIN./ on its own line as a block terminator —
not in the plan §7.3/S11 scope. The / appears as a normal
token; the next statement starts after it.GO N count syntax — the GO is treated
as a terminator regardless of any trailing count.Plan reference: §7.3/S11, §7.4/S11.
| Constructor and Description |
|---|
StatementBoundaryDetector() |
| Modifier and Type | Method and Description |
|---|---|
List<StatementRange> |
detect(Pp2TokenStream stream,
EDbVendor vendor)
Detect statement boundaries.
|
public StatementBoundaryDetector()
public List<StatementRange> detect(Pp2TokenStream stream, EDbVendor vendor)
stream - non-null token stream (typically already annotated by
S9's ProtectedZoneDetector)vendor - non-null vendor identity; used to decide whether
GO is a terminatorStatementRanges in source orderNullPointerException - if either argument is null