Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/lexer-next
lexer for recursive descent parsers
https://github.com/stagas/lexer-next
iterable iterator lexer parser parsing recursive-descent-parser regexp regexp-match tokenizer
Last synced: 14 days ago
JSON representation
lexer for recursive descent parsers
- Host: GitHub
- URL: https://github.com/stagas/lexer-next
- Owner: stagas
- License: mit
- Created: 2021-11-03T00:04:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T17:28:41.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T14:23:34.964Z (about 1 month ago)
- Topics: iterable, iterator, lexer, parser, parsing, recursive-descent-parser, regexp, regexp-match, tokenizer
- Language: TypeScript
- Homepage:
- Size: 1.08 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
lexer-nextlexer for recursive descent parsers
npm i lexer-next
pnpm add lexer-next
yarn add lexer-next
## API
#
createLexer
(tokenize) src/index.ts#L106
LexerErrorCauses
src/causes.ts#L1 # LexerErrorCause
src/causes.ts#L3
# constructor
(message) src/causes.ts#L5
message
src/causes.ts#L5 string
name
= 'LexerErrorUnknown'
src/causes.ts#L4 string
UnexpectedToken
src/causes.ts#L8 # constructor
(currentToken, expectedGroup, expectedValue) src/causes.ts#L10
currentToken
src/causes.ts#L10 # expectedGroup
src/causes.ts#L10 string
expectedValue
src/causes.ts#L10 string
message
src/causes.ts#L5 string
name
= 'LexerErrorUnexpectedToken'
src/causes.ts#L9 string
LexerError
src/index.ts#L15 # constructor
(cause) src/index.ts#L21
cause
src/index.ts#L16 # name
= 'LexerError'
src/index.ts#L20 string
prepareStackTrace
stackTraceLimit
number
captureStackTrace
(targetObject, constructorOpt) # targetObject
object
constructorOpt
Function
captureStackTrace(targetObject, constructorOpt) =>
- void
RegExpToken
# constructor
(pattern)
# new RegExpToken
()
# pattern
string | RegExp
new RegExpToken
() # new RegExpToken
() Token
# constructor
(value)
group
string
source
# index
value
as
(value, group) is
(group, value) # toJSON
()
toJSON() =>
create
(value, group, source) # Lexer
src/index.ts#L46 # unknown
src/index.ts#L89
accept
(group, value) src/index.ts#L69 advance
() src/index.ts#L50
advance() =>
expect
(group, value) src/index.ts#L77 # filter
(fn) src/index.ts#L87 # fn
filter(fn) =>
- void
onerror
(fn) src/index.ts#L82 # fn
onerror(fn) =>
- void
peek
() src/index.ts#L59 # RegExpMatchArrayLike
# TokenJson
# value
string
ErrorHandler
src/index.ts#L31 # FilterFunction
src/index.ts#L39 # LexerFactory
src/index.ts#L95 # Tokenizer
src/index.ts#L41 # createLexer
(tokenize) src/index.ts#L106
## Credits
- [match-to-token](https://npmjs.org/package/match-to-token) by [stagas](https://github.com/stagas) – transform a RegExp named group match to a more useful object
## Contributing
[Fork](https://github.com/stagas/lexer-next/fork) or [edit](https://github.dev/stagas/lexer-next) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)