Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mysql/oracle] Add remaining ports to support all targets. #4345

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

kaby76
Copy link
Contributor

@kaby76 kaby76 commented Nov 29, 2024

This PR implements the rest of the ports of the mysql/oracle grammar. This is a necessary first step in generating each of the ports automatically from the official source (here). It also refactors the code to be more in line with standard OO development practices. These ports are necessary mainly because people want to pick a grammar and run with it. Asking them to write a port of the grammar is time-consuming and difficult.

Previously, from the original Antlr4ng port, initialization was done in the driver:

lexer.serverVersion = 80200;
lexer.sqlModeFromString("ANSI_QUOTES");
lexer.charSets = charSets;
parser.serverVersion = lexer.serverVersion;
parser.sqlModes = lexer.sqlModes;

This is actually a bad place to put initialization because it requires the user to read the driver code or readme. No one does either, and they just want it to "work." Also, driver code are not part of the grammar. Initialization should be done in a constructor, in line with OO practices.

In addition, the class SqlMode should be in its own file, not embedded in the lexer base class.

export enum SqlMode {
NoMode,
AnsiQuotes,
HighNotPrecedence,
PipesAsConcat,
IgnoreSpace,
NoBackslashEscapes,
}

It is used in the parser.

import { SqlMode } from "./MySQLBaseLexer.js";

The method that creates a Set<SqlMode> is in the lexer. It should be in the class SqlModes.

What was done?

  • The existing ports (Antlr4ng CSharp Java Python3 TypeScript) were fixed to set defaults in constructors.
  • The custom Test.* files were removed.
  • StackQueue<> was removed and all ports now use a standard queue data structure.
  • The Cpp, Dart, Go, and JavaScript ports were added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant