Skip to content

Commit

Permalink
Rename regexp to reg for uniformity
Browse files Browse the repository at this point in the history
  • Loading branch information
barsdeveloper committed Jan 3, 2024
1 parent 1d86ef7 commit a678964
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 109 deletions.
24 changes: 12 additions & 12 deletions dist/parsernostrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,41 +747,41 @@ class Parsernostrum {
// Prefedined parsers

/** Parser accepting any valid decimal, possibly signed number */
static number = this.regexp(new RegExp(this.#numberRegex.source + String.raw`(?!\.)`))
static number = this.reg(new RegExp(this.#numberRegex.source + String.raw`(?!\.)`))
.map(Number)

/** Parser accepting any digits only number */
static numberInteger = this.regexp(/[\-\+]?\d+(?!\.\d)/).map(Number)
static numberInteger = this.reg(/[\-\+]?\d+(?!\.\d)/).map(Number)

/** Parser accepting any digits only number */
static numberNatural = this.regexp(/\d+/).map(Number)
static numberNatural = this.reg(/\d+/).map(Number)

/** Parser accepting any valid decimal, possibly signed, possibly in the exponential form number */
static numberExponential = this.regexp(new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`))
static numberExponential = this.reg(new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`))
.map(Number)

/** Parser accepting any valid decimal number between 0 and 1 */
static numberUnit = this.regexp(/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/)
static numberUnit = this.reg(/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/)
.map(Number)

/** Parser accepting any integer between 0 and 255 */
static numberByte = this.regexp(/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/)
static numberByte = this.reg(/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/)
.map(Number)

/** Parser accepting whitespace */
static whitespace = this.regexp(/\s+/)
static whitespace = this.reg(/\s+/)

/** Parser accepting whitespace */
static whitespaceOpt = this.regexp(/\s*/)
static whitespaceOpt = this.reg(/\s*/)

/** Parser accepting whitespace that spans on a single line */
static whitespaceInline = this.regexp(/[^\S\n]+/)
static whitespaceInline = this.reg(/[^\S\n]+/)

/** Parser accepting whitespace that spans on a single line */
static whitespaceInlineOpt = this.regexp(/[^\S\n]+/)
static whitespaceInlineOpt = this.reg(/[^\S\n]+/)

/** Parser accepting whitespace that contains a list a newline */
static whitespaceMultiline = this.regexp(/\s*?\n\s*/)
static whitespaceMultiline = this.reg(/\s*?\n\s*/)

/** Parser accepting a double quoted string and returns the content */
static doubleQuotedString = this.regexpGroups(new RegExp(`"(${this.#createEscapeable('"')})"`))
Expand Down Expand Up @@ -838,7 +838,7 @@ class Parsernostrum {
}

/** @param {RegExp} value */
static regexp(value, group = 0) {
static reg(value, group = 0) {
return new this(new RegExpParser(value, group))
}

Expand Down
2 changes: 1 addition & 1 deletion dist/parsernostrum.min.js

Large diffs are not rendered by default.

126 changes: 63 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parsernostrum",
"type": "module",
"version": "1.0.8",
"version": "1.0.9",
"description": "A tiny LL parser combinator library for javascript",
"main": "src/Parsernostrum.js",
"types": "src/types.js",
Expand Down
24 changes: 12 additions & 12 deletions src/Parsernostrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,41 @@ export default class Parsernostrum {
// Prefedined parsers

/** Parser accepting any valid decimal, possibly signed number */
static number = this.regexp(new RegExp(this.#numberRegex.source + String.raw`(?!\.)`))
static number = this.reg(new RegExp(this.#numberRegex.source + String.raw`(?!\.)`))
.map(Number)

/** Parser accepting any digits only number */
static numberInteger = this.regexp(/[\-\+]?\d+(?!\.\d)/).map(Number)
static numberInteger = this.reg(/[\-\+]?\d+(?!\.\d)/).map(Number)

/** Parser accepting any digits only number */
static numberNatural = this.regexp(/\d+/).map(Number)
static numberNatural = this.reg(/\d+/).map(Number)

/** Parser accepting any valid decimal, possibly signed, possibly in the exponential form number */
static numberExponential = this.regexp(new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`))
static numberExponential = this.reg(new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`))
.map(Number)

/** Parser accepting any valid decimal number between 0 and 1 */
static numberUnit = this.regexp(/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/)
static numberUnit = this.reg(/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/)
.map(Number)

/** Parser accepting any integer between 0 and 255 */
static numberByte = this.regexp(/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/)
static numberByte = this.reg(/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/)
.map(Number)

/** Parser accepting whitespace */
static whitespace = this.regexp(/\s+/)
static whitespace = this.reg(/\s+/)

/** Parser accepting whitespace */
static whitespaceOpt = this.regexp(/\s*/)
static whitespaceOpt = this.reg(/\s*/)

/** Parser accepting whitespace that spans on a single line */
static whitespaceInline = this.regexp(/[^\S\n]+/)
static whitespaceInline = this.reg(/[^\S\n]+/)

/** Parser accepting whitespace that spans on a single line */
static whitespaceInlineOpt = this.regexp(/[^\S\n]+/)
static whitespaceInlineOpt = this.reg(/[^\S\n]+/)

/** Parser accepting whitespace that contains a list a newline */
static whitespaceMultiline = this.regexp(/\s*?\n\s*/)
static whitespaceMultiline = this.reg(/\s*?\n\s*/)

/** Parser accepting a double quoted string and returns the content */
static doubleQuotedString = this.regexpGroups(new RegExp(`"(${this.#createEscapeable('"')})"`))
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class Parsernostrum {
}

/** @param {RegExp} value */
static regexp(value, group = 0) {
static reg(value, group = 0) {
return new this(new RegExpParser(value, group))
}

Expand Down
Loading

0 comments on commit a678964

Please sign in to comment.