bikossor / rudus Goto Github PK
View Code? Open in Web Editor NEWParser combinator library for TypeScript.
Home Page: https://rudus.pages.dev/
License: MIT License
Parser combinator library for TypeScript.
Home Page: https://rudus.pages.dev/
License: MIT License
Introduce a ParserStateResult
type so the result
property of a ParserState
has no unknown
type.
This happens with the regex
, word
and whitespace
parser when they can't match.
D:\Git\Railgun\dist\parser\regex.js:6
const [fullMatch] = searchString.exec(state.input.slice(state.offset));
^
TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Parser.transformState (D:\Git\Railgun\dist\parser\regex.js:6:25)
at Parser.transformState (D:\Git\Railgun\dist\combinators\sequenceOf.js:10:32)
at Parser.run (D:\Git\Railgun\dist\Parser.js:9:21)
at Object.<anonymous> (D:\Git\Railgun\main.js:9:29)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
This parser checks if the state.input.slice(state.offset)
still contains something, if so it fails.
To make the code a bit more appealing :D
A index.ts
file in the src/
folder to export all important parts of Railgun.
This would be equivalent of the regex (\r\n|\r|\n)
but the match won't get captured.
The branch does not exist anymore so this will not be executed at all ๐
separatedBy (value, separator)
value
parser fails, sepBy
will fail toovalue
parses an empty string, sepBy
won't failvalue
parses just a separator, sepBy
will failThe many
combinator tries as many times as possible to parse a given parser.
The many1
combinator tries as many times as possible but at least once to parse a given parser otherwise it fails.
outerLeft
, outerRight
and inner
parserouterRight
defaults to outerLeft
inner
parser will be capturedUsing jest
with ts-jest
.
node.js.yml
codeql-analysis.yml
From
const { whitespace, endOfInput, string } = require("../dist/cjs/parser/index");
const { sequenceOf } = require("../dist/cjs/combinators/index");
to
const { whitespace, endOfInput, string } = require("rudus");
const { sequenceOf } = require("rudus");
Node.js 16
(current active LTS)Node.js 17
(current latest)The errorMessages
should contain the name of the parser that failed.
So when you search in VS Code via Ctrl + E
it just shows up the relevant files.
Parsers should get a ParserState to unify the API.
The tsconfig.json
only excludes the tests
folder. It should also exclude the dist
folder.
With TypeScript version 3.4.5
.
Relates to #73
With descriptions of the parsers
and combinators
.
Create a base tsconfig.json
and one for CommonJS- and ES-Modules.
From railgun
to @bikossor/railgun
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.