Split apart grammar.py and segments_*.py. Introduce Parser class. #510
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another meaty re-org. Reason for this change is twofold:
grammar.py
, which were very difficult to navigate. This PR splits up some of those larger source files into their own modules, namelysqlfluff.core.parser.segments
andsqlfluff.core.parser.grammar
.FileSegment
was a bit of an anomaly in that it depended on grammars, and also that it was instantiated directly to initiate parsing.This PR does four things:
grammar.py
into a module of seperate source files insqlfluff.core.parser.grammar
.segments_base.py
,segments_common.py
&segment_generator.py
into a module of smaller seperate source files insqlfluff.core.parser.segments
.segments_file.py
intodialect_ansi.py
, with the logic in the.from_raw()
method (which used to be called as the standard way of parsing a lexed file) moved into aParser
class which can be called directly, much like the way thatLexer
already exists. This also has the upshot of removing the need for modules outside the parser to deal withRootParseContext
and so this has been removed from the public interface of this module.