- Parser
- Breaking Change:
IParserBuilder.global
now accept a function as the global factory.- Because we won't clone the parser, we don't need a global cloner, just need a global factory.
- Fix:
$
/$$
will check forTNode
first, instead ofNTNode
.
- Breaking Change:
- Parser
- Fix:
structuredClone
not working in browser. See the details here.
- Fix:
- Lexer
- Feat: add
ExtractToken
.
- Feat: add
- Parser
- Feat:
ASTNode
,$
and$$
are kind-sensitive. - Breaking Change: rewrite
ASTNode
, addNTNode
andTNode
.- Rewrite selectors and traversers.
- Breaking Change: remove
IParserBuilder.lexer
. Set the lexer in parser builders' constructor instead. - Breaking Change: remove
ASTNode.token
, addIParserBuilder.mapper
to transform token intoASTData
. #38 - Breaking Change:
IParserBuilder.build
will consume the builder. Don't re-use the builder after callingbuild
. - Feat: add
ExtractSerializableParserData
. #41 - Feat: add
ASTNode.global
to share data across all nodes.- Add
IParserBuilder.global
to set the global data and cloner.
- Add
- Feat: allow multiple calls for
IParserBuilder.data
.
- Feat:
- Perf: prevent unnecessary calculation.
- Reduce package size. #31
- Optimize the format of serialized parser data, remove unused strings.
- Lexer
- Breaking Change: remove
IReadonlyLexerCore.actions
, addIReadonlyLexerCore.getTokenKinds
. - Breaking Change: remove
Builder.getTokenKinds
. - Breaking Change: remove
Lexer.fromTo
. - Breaking Change: rewrite
stringLiteral/numericLiteral/comment
.- Add
StringLiteralOptions/StringLiteralData/EscapeHandler
.
- Add
- Breaking Change: rewrite
javascript.regexLiteral
. - Breaking Change:
Lexer.take/takeUntil
will reset lexer's action state by default. #42 - Feat: allow multiple calls for
Builder.state
andBuilder.error
. - Feat: add
ITrimmedLexer/IReadonlyTrimmedLexer
. #37 - Feat:
Builder.append
can accept actions with different data bindings in one call. - Feat: add
Lexer.javascript.evalStringContent/simpleStringLiteral/singleQuoteStringLiteral/doubleQuoteStringLiteral/templateStringLiteralLeft/templateStringLiteralRight
. - Feat: add
Lexer.integerLiteral/binaryIntegerLiteral/octalIntegerLiteral/hexIntegerLiteral
andIntegerLiteralOptions/IntegerLiteralData
.- Add
Lexer.javascript.binaryIntegerLiteral/octalIntegerLiteral/hexIntegerLiteral/identifier
.
- Add
- Feat: add
Lexer.json
. - Feat: add
Lexer.SubAction
,Lexer.IntoSubAction
. - Feat: add
Lexer.Action.prevent
. - Feat: add
Lexer.invalidRejecter
. - Fix:
Lexer.trimStart
shouldn't collect non-muted errors.
- Breaking Change: remove
- Parser
- Breaking Change: lexer will be trimmed after every parse. This should improve the performance.
GrammarRuleContext.lexer
will beIReadonlyTrimmedLexer
instead ofIReadonlyLexer
.
- Breaking Change: lexer will be trimmed after every parse. This should improve the performance.
- Lexer
- Breaking Change: remove
Builder.select
, useBuilder.append
instead. - Breaking Change: rename
Action.map
toAction.select
.- Feat: add
Action.map
to map data for multi kinds action. #34
- Feat: add
- Breaking Change: rename
Action.clearData
toAction.purge
. - Feat:
Builder.define
can accept actions with different data types in one call. - Fix: unclosed single line string literal should not include the tail
\n
. #32 - Fix: default
token.data
type should beundefined
instead ofnever
. #33
- Breaking Change: remove
- Fix: include utils.
- Breaking Change: re-order and simplify generic parameters.
- Breaking Change: remove
jsonLogger
, usejsonLoggerFactory
instead. - Lexer
- Breaking Change: apply
LazyString
inActionInput/AcceptedActionOutput.rest
. - Breaking Change: customizable token data. #29
- Add
Action.data
.
- Add
- Breaking Change: make
Action/Builder
's defaultErrorType
tonever
. - Breaking Change:
Builder.define/ignore/anonymous
will accept functions asActionBuilder
instead ofSimpleActionExec
. - Breaking Change: make
Action
's constructor private. UseAction.exec
instead. - Breaking Change: utils will set token data when the value is invalid, instead of setting token error.
- Breaking Change: all actions should have the same data type in one
Builder.define
. - Breaking Change: remove
ILexer.defs
, useILexer.core.defs
instead. - Breaking Change: rename
Builder.useState
toBuilder.state
. - Feat: add
ActionInput.peek
. - Feat: add
ActionBuilder
for chaining action decorators. - Feat: add
Builder.error
to set error type. - Feat: add
Builder.select
to allow an action to map multiple token kinds. #28- Add
Action.kinds
,ActionWithKinds
andSelectedAction
.
- Add
- Feat: add
Lexer.javascript
.- Add
evalString
. #30 - Add
comment
. - Breaking Change: move
regexLiteral/numericLiteral
intoLexer.javascript
.
- Add
- Feat: add option
lineContinuation
forLexer.stringLiteral
. - Feat:
Action.match
will set output data toRegExpExecArray
.- Add
Action.dryMatch
.
- Add
- Feat: add
ILexer/ILexerCore.readonly
.
- Breaking Change: apply
- Parser
- Breaking Change: add
ASTNode.token
. - Breaking Change: rename
IParserBuilder.useLexer/useData
toIParserBuilder.lexer/data
.- Breaking Change:
IParserBuilder.lexer
must be called and only can be called once to set the lexer, instead of setting the lexer inIParserBuilder.build
. - Breaking Change:
IParserBuilder.data
can only be called once. - Breaking Change: rewrite
BuilderDecorator
andIParserBuilder.use
, restrict the modification only to theKinds
.
- Breaking Change:
- Feat: add
IParserBuilder.useData
.
- Breaking Change: add
- Optimize package size.
- Breaking Changes: rename
type
tokind
. - Breaking Change: rewrite
Logger
, adddefaultLogger
andjsonLogger
. #9 - Feat: add dist build. #23
- Lexer
- Breaking Change:
ActionExec
will takeActionInput
as the input. #6- Rename
ActionAcceptedOutput
toAcceptedActionOutput
, and make it a class, rewrite its logics. Action.mute/check/reject/then
will takeAcceptedActionOutput
as the callback's param.- Regex should not starts with
^
and will auto have sticky flag.
- Rename
- Breaking Change:
Lexer.whitespaces
is now a function. - Breaking Change: add
ILexer.lineChars/errors
, removeILexer.getLineChars/getErrors
. - Feat: add
ILexer.defs/buffer
. - Feat:
SimpleActionExec
can acceptstring/SimpleAcceptedActionOutput
as the output. - Feat: add generic parameter for Lexer family as the
Token.error
type. - Feat: add
options.autoSticky/autoGlobal
forfromTo
. - Feat: export
Action.simple/match
. Addoptions.autoSticky/rejectCaret
forAction.match
. - Feat: add typed error.
- Feat: add
ILexer.takeUntil
. #16 - Feat: add
Lexer.utils.regexLiteral
. #15 - Feat: add
ILexer.lex.peek
. - Feat: typed lexer. #17
- Feat: add
IReadonlyLexer
. - Feat: add utils
exactArray/wordArray/exactKind
. - Feat: add
IReadonlyLexer.trimmed
. - Feat: add
IReadonlyLexerCore/ILexerCore/LexerCore
. - Feat: add lexer's action state. #25
- Fix: actions won't be merged into one when calling
Builder.define/anonymous/ignore
. This will fix expectational lexing behaviour.
- Breaking Change:
- Parser
- Feat: add
name
forASTNode
andASTObj
.- Breaking Change:
ASTNode.toTreeString
will also printASTNode.name
. - Breaking Change: refactor
ASTNode.toString
. The output format is changed.
- Breaking Change:
- Breaking Change: rename
ASTNodeQuerySelector
toASTNodeChildrenSelector
. - Breaking Change: refactor typed errors.
- Breaking Change: rename
ParserContext
toGrammarRuleContext
, makeParserContext
a class. - Breaking Change: remove
ReducerContext
, just useGrammarRuleContext
. - Breaking Change: rename
BaseResolverOptions.reduce
toaccept
. - Breaking Change: rename
ASTNode.toObj
totoJSON
. - Breaking Change:
ASTNode/GrammarRuleContext.$
is renamed toASTNode/GrammarRuleContext.$$
to search for an array.- Add
ASTNode/GrammarRuleContext.$
to search for the first match.
- Add
- Breaking Change: remove
IParser.getErrors/getNodes
, useIParser.errors/buffer
instead. - Breaking Change:
IParser.take
will auto commit the parser. - Breaking Change:
IParser.take
will take the first N nodes instead of the first one node. - Breaking Change:
IParserBuilder.build
withcheckAll
will also check if there is any rollback functions if rollback is disabled.- Add
checkRollback
forIParserBuilder.build
.
- Add
- Breaking Change:
IParserBuilder.entry
will check kinds. - Breaking Change:
IParserBuilder.build
will return{ parser, serializable, mermaid }
. - Breaking Change: remove
IParserBuilder.leftSA/rightSA
, enhance theIParserBuilder.priority
to support left-to-right or right-to-left associativity. - Breaking Change: entry NT's follow set will also be checked during parsing.
- Add
BuildOptions/IParser.ignoreEntryFollow
to override the behaviour.
- Add
- Breaking Change: use
builder.build({ lexer, entry })
instead ofbuilder.build(lexer)
andbuilder.entry
. - Breaking Change:
GrammarRuleContext.lexer
isReadonlyILexer
. - Breaking Change:
IParserBuilder.build
withgenerateResolvers
won't print resolvers. The resolver string is stored in the result ofIParserBuilder.build
. - Breaking Change: use array to define resolver's next set. E.g.
{ next: [`'+'`], accept: true }
- Breaking Change: remove
IParser.clone/dryClone
. - Breaking Change:
IParserBuilder.define
now accept optionalDefinitionContextBuilderDecorator
to set the definition context. - Feat: typed parser.
- Add
IParserBuilder.useLexer
to set lexer kinds and error types.
- Add
- Feat: built-in support for conflict resolver. #7
- Feat: in
AdvancedBuilder
you can rename literals. - Feat:
children
in traverser is neverundefined
. - Feat: serialize parser. #2
- Feat: add
BuildOptions.mermaid
for parser to generate mermaid graph. - Feat: add
BuildOptions/IParser.autoCommit
for parser to auto commit when parsing. - Fix: fix follow set calculation. This will also reduce the number of unresolved conflicts.
- Fix: fix
gr+
logic, treat thegr
as a whole. - Fix: first defined resolver will be applied. Ignore others.
- Fix: detect RS conflicts more accurately.
- Note: optimize debug output.
- Feat: add
- Optimize performance.
Published by mistake :)
- Lexer
- Feat: Add
debug/logger
option. #11- Breaking Change: Update
ILexer
model to adopt debug/logger options.
- Breaking Change: Update
- Feat: Add
Action.or
to cascade actions. - Feat: Add
Action.reduce
to reduce actions.- Perf: Apply this in
Lexer.Builder.define
to optimize performance.
- Perf: Apply this in
- Feat:
Lexer.Action.mute
can accept a function,Lexer.Action.reject
can accept a boolean. - Feat: Add
Lexer.Action.error
to set error directly. - Feat: Add utils:
Lexer.whitespaces/comment/numericLiteral
. #5 - Feat: Add utils
Lexer.esc4regex
. - Fix: Reset regex state for regex based actions.
- Breaking Change: Remove
Lexer.from_to
, useLexer.fromTo
instead. - Breaking Change: New
Lexer.stringLiteral
, more options, more powerful.
- Feat: Add
- Parser
- Feat: Literals in grammar rules also have name and can be renamed. #4
- Feat: Add
logger
option. #11- Breaking Change: Update
IParser
model to adopt debug/logger options.
- Breaking Change: Update
- Feat: Optional re-lex and rollback by setting
ParserBuilder.options.reLex/rollback
.- Breaking Change: Disable rollback by default to optimize the performance.
- Breaking Change: Export
IParserBuilder/BuilderDecorator
in theELR
namespace, instead of the top level. - Breaking Change: New
ASTNode.toTreeString
.
- Parser
- Export
IParserBuilder/BuilderDecorator
in the top level. - Breaking Change: Change
LR_RuntimeError
, addParserTraverseError
. - Breaking Change: Remove
DFA.calculateAllStates
since all states will be calculated and cached when build DFA.
- Export
- Optimize performance.
- Prevent unnecessary string copy.
- Cache string manipulation results and other temp results.
- Add
Lexer.Action.maybeMuted
to accelerate expectational lexing &trimStart
.
- Parser
- Breaking Change:
ParserBuilder.checkSymbols
is now private, useoptions
inParserBuilder.build
instead. - Breaking Change: Remove
AdvancedBuilder.expand
, makeAdvancedBuilder
extendParserBuilder
, they both implementIParserBuilder
. - Add
ParserBuilder.use
to apply custom decorators with chain call. - Add
IParserBuilder.priority/leftSA/rightSA
for simplified conflict resolution. AdvancedBuilder.resolveRS/resolveRR
support+*?|()
.- Parser will calculate all DFA states at the start.
- Breaking Change:
- Fix
- Return
null
fromTraverser
will be transformed toundefined
.
- Return
- Optimize performance.
- Remove unnecessary conflict calculation.
- Only handle conflicts that exactly exists in rejecter.
- Versioned documentation.
- Parser
- Add
debug
option toAdvancedBuilder.expand
. - Auto resolve R-S conflicts when
AdvancedBuilder.expand
. - Allow
'*'
as thenext
when resolve RS/RR conflicts. - Breaking Change:
ParserBuilder.generateResolvers/checkConflicts
is now private, andParserBuilder.checkAll
is removed. Useoptions
inParserBuilder.build
instead.
- Add
- Fix
- Parser can detect R-S conflict like:
exp: `a b | a b c`
whereb
is a terminator. - Parser won't print
[user resolved RR]
in debug mode when it's actually an R-S conflict.
- Parser can detect R-S conflict like:
- Optimize code & comments.
- Optimize performance.
- Merge
ParserBuilder.generateResolvers/checkConflicts
toParserBuilder.build
to avoid unnecessary DFA build. - Re-use computed conflicts when generate resolvers and check conflicts.
- Pre-calculate values before the parser is built to avoid repeated calculation.
- Reduce the use of
TempGrammar/TempGrammarRule
, useGrammar/GrammarRule
instead.
- Merge
- More tests.
- Parser
- Breaking Change:
ASTNodeQuerySelector
a.k.a the$
function will return a list ofASTNode
instead ofASTNode | undefined
, and can only query by type name not literals. - Breaking Change: Remove
GrammarRule.queryIndex
. - Add
ParserBuilder.cascadeQueryPrefix
to use cascade query in the$
function. - Support
@
in grammar rules to rename a grammar when query using$
. - Add
ELR.AdvancedBuilder
to build ELR parser, you can use|+*()?
in your grammar rules.
- Breaking Change:
- Optimize package size.
- Parser
- Make
ASTNode.type/start/text/children
readonly. - Add
ASTNode.$
to query children by its type name or literal value. - Add
ASTNode.traverse
to traverse AST after parsing. - ELR Parser
- Export
ELR.commit
andELR.rollback
. - Breaking Change: Reducer will take
ReducerContext
as the parameter instead ofParserContext
. - Breaking Change:
ParserBuilder.checkSymbols/checkAll
will require a lexer to check if literals in grammar rules are valid.
- Export
- Make
- Optimize performance.
- Lexer
- Add optional
stopOnError
parameter toLexer.lexAll
. - Change
Token
andDefinition
from type to interface. - If token has no error, the error field will be
undefined
. - Add interface
ILexer
. - Add
Lexer.clone/dryClone
. Lexer.lex
add optional parameterexpect
to limit the output token type or/and token content.- Add
Lexer.trimStart
. - Add
Lexer.take
. - Add
Lexer.digested
. - Rename
Lexer.hasError
toLexer.hasErrors
.
- Add optional
- Parser
- If
ASTNode
has no error, the error field will beundefined
. - Add
ASTNode.toObj
for serialization. - Add optional
stopOnError
parameter toIParser.parse
. Parser.parse
will accept string as input instead of a list of ASTNode.- So each parser will have a lexer. Parser builders will need lexer when
build
.
- So each parser will have a lexer. Parser builders will need lexer when
- Remove LR parser.
- ELR Parser: Expectational LR Parser
- Use
DefinitionContextBuilder
to define parser actions. - Rename
ReducerContext
toParserContext
. - If
ReducerContext
has no error, the error field will beundefined
. - Add optional
stopOnError
parameter toDFA.parse
andParser.parse
. - Add
ParserBuilder.checkConflicts
to ensure all reduce-shift and reduce-reduce conflicts are resolved.- It will also try to auto resolve conflicts by LR(1) peeking.
- Add
ParserBuilder.resolveRS/resolveRR
to manually resolve conflicts. - Add
ParserBuilder.generateResolvers
to auto generate resolver template.
- Add
ParserBuilder.checkAll
to do all necessary checks. - Replace
dataReducer
withELR.reducer
. GrammarRule/Candidate.toString
will output like user's definition using:
,`
and{}
.- DFA will cache state transition on the fly to optimize runtime performance.
- Add
DFA.calculateAllStates
to calculate all state transitions ahead of time and cache them.
- Add
- Remove
ParserBuilder.use
. - Add
ParserContext.$
to find AST node by its type name or literal value. - Parser will actively use Lexer to lex input string to token according to the grammar rules.
- Re-Lex: If the lexed token can't be accepted, the parser will try to restore & re-lex input.
Parser.commit
will abandon all other possibilities and only keep the current state.DefinitionContext
supportrollback
to rollback state when re-lex.DefinitionContext
supportcommit
to prevent re-lex.
- Use
- If
- Remove
Manager
sinceParser.parse
already accept string as input and keep a state. - Optimize document / comments.
- Generate documentation with typedoc.
- Optimize code / performance.
- Use strict.
- More test code.
- Enable code coverage report.
- Parser
- Replace
ASTData
with generic type. - Remove
valueParser
. - LR Parser
- Add
ParserBuilder.use
to re-use existing parser builder or modularize code. GrammarRule/Candidate.toString
will use<=
as the default arrow instead of=>
.
- Add
- Replace
- Optimize document / comments.
- Better export structure.
- Lexer
- Decouple
Lexer
toLexer
andBuilder
. - Add
Lexer.hasError
. - Fix
stringLiteral
to parse\\
correctly. - More optional parameters for
stringLiteral
to support custom quotes. - Remove
Builder.overload
, butBuilder.define
can acceptActionSource[]
.
- Decouple
- Parser
- Rename
ParserManager
toManager
and put it in the top level. - Treat
Parser
as an interfaceIParser
instead of a type. AddIParser.reset
. ASTNode
will record the start position.ASTNode.error
can be any type instead of string only.ASTNode.toTreeString
has more format options.- Custom error class
ParserError
. - LR Parser
ReducerContext.error
can be any type instead of string only.- Rename
LRParser
toLR.Parser
,LRParserBuilder
toLR.ParserBuilder
.
- Rename
- Manager
Manager
will only manage one parser instead of many.
- Optimize document / comments.
- Optimize code.
- More examples.
- Test using jest.
Initial release.
Provide basic Lexer
, ParserManager
and LRParser
.