Class EmptySchemaPartSyntax

java.lang.Object
dev.frostlake.parser.EmptySchemaPartSyntax

public final class EmptySchemaPartSyntax extends Object
The shapes a name with an empty middle part, db..t, cannot take where it is written — live's syntax errors, judged once the statement has parsed. The grammar reads every name position with the one name rule, which takes any number of parts after the empty one, so the shapes are refused here instead, over the parse tree and the token stream, once per parse:
   SELECT T..x FROM db..t            unexpected 'FROM'   a column reference needs its fourth part
   SELECT db..t.x.y FROM db..t       unexpected '.'      and takes no fifth, refused at its dot
   CREATE TABLE db..t.c (x INT)      unexpected '.'      an object name ends with its third part
   SHOW COLUMNS IN db..t             unexpected '<EOF>' a bare scope, at the token after db..t
   SHOW COLUMNS IN TABLE db..t       unexpected '.'      a scope named with its kind, at the second dot
 

★ A COLUMN REFERENCE over the empty part is db..t.c. With three parts, t..c, the token after it is refused whatever it is — the FROM, a comma, an alias, a cast's ::, a bracket, the end of the input. A fifth part is refused at its dot, and a sixth adds a second line at the dot after that; live stops at two.

★ AN OBJECT NAME — a table, a view, a sequence, a FROM reference, the column of COMMENT ON COLUMN — ends with the part after the empty one: a fourth part is refused at its dot, in one line however many parts follow.

★ A BARE SHOW SCOPE, IN db..t, is refused at the token after db..t, where a scope naming its kind (IN TABLE, IN SCHEMA, …) is refused at its second dot. Live reads a WORD after the bare name as the instance name of a class scope, IN <class> <instance>, which is not modelled: that spelling is refused at the word.

  • Method Details

    • requireWellFormed

      public static void requireWellFormed(FrostlakeParser.SqlScriptContext script, org.antlr.v4.runtime.TokenStream tokens, String sql)
      Refuse the first name, in the order written, whose empty middle part its position does not take.
      Parameters:
      script - the parsed script
      tokens - the token stream it was parsed from
      sql - the script's source text