Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Dec 7, 2024
1 parent 97e29b3 commit 1c507e8
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrollsdk",
"version": "100.0.0",
"version": "100.0.1",
"description": "This npm package includes the Particles class, the Parsers compiler-compiler, a Parsers IDE, and more, all implemented in Particles, Parsers, and TypeScript.",
"types": "./built/scrollsdk.node.d.ts",
"main": "./products/Particle.js",
Expand Down
31 changes: 31 additions & 0 deletions parsers/Parsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,37 @@ type bar`)
equal(anyProgram.getAllErrors().length, 2)
}

testParticles.extendsScope = equal => {
// Arange
const rootParser = new HandParsersProgram(`cueAtom
newlangParser
root
catchAllParser catchAllErrorParser
inScope rootParser
rootParser
videoParser
extends rootParser
atoms cueAtom
cueFromId
widthParser
cueFromId
atoms cueAtom
quickVideoParser
cue qv
extends videoParser
catchAllErrorParser
baseParser errorParser`).compileAndReturnRootParser()
const program = `video
width
qv
width`

// console.log(new rootParser(program).definition.toBrowserJavascript())

// Act
equal(new rootParser(program).getAllErrors().length, 0)
}

testParticles.abstractParsers = equal => {
// Arrange/Act
const anyProgram = makeJibberishProgram(`someAbstractClass
Expand Down
11 changes: 10 additions & 1 deletion parsers/Parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2241,9 +2241,18 @@ ${captures}
return this._cache_ancestorParserIdsArray
}

_isLooping = false
protected _cache_parserDefinitionParsers: { [parserId: string]: parserDefinitionParser }
get programParserDefinitionCache() {
if (!this._cache_parserDefinitionParsers) this._cache_parserDefinitionParsers = this.isRoot || this.hasParserDefinitions ? this.makeProgramParserDefinitionCache() : this.parent.programParserDefinitionCache
if (!this._cache_parserDefinitionParsers) {
if (this._isLooping) throw new Error(`Loop detected in ${this.id}`)
this._isLooping = true
this._cache_parserDefinitionParsers =
this.isRoot() || this.hasParserDefinitions
? this.makeProgramParserDefinitionCache()
: this.parent.programParserDefinitionCache[this.get(ParsersConstants.extends)]?.programParserDefinitionCache || this.parent.programParserDefinitionCache
this._isLooping = false
}
return this._cache_parserDefinitionParsers
}

Expand Down
2 changes: 1 addition & 1 deletion particle/Particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ class Particle extends AbstractParticle {
return str ? indent + str.replace(/\n/g, indent) : ""
}

static getVersion = () => "100.0.0"
static getVersion = () => "100.0.1"

static fromDisk(path: string): Particle {
const format = this._getFileFormat(path)
Expand Down
16 changes: 15 additions & 1 deletion products/Parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,10 @@ class ParsersParserConstantString extends AbstractParserConstantParser {
class ParsersParserConstantFloat extends AbstractParserConstantParser {}
class ParsersParserConstantBoolean extends AbstractParserConstantParser {}
class AbstractParserDefinitionParser extends AbstractExtendibleParticle {
constructor() {
super(...arguments)
this._isLooping = false
}
createParserCombinator() {
// todo: some of these should just be on nonRootParticles
const types = [
Expand Down Expand Up @@ -1803,9 +1807,19 @@ ${captures}
return this._cache_ancestorParserIdsArray
}
get programParserDefinitionCache() {
if (!this._cache_parserDefinitionParsers) this._cache_parserDefinitionParsers = this.isRoot || this.hasParserDefinitions ? this.makeProgramParserDefinitionCache() : this.parent.programParserDefinitionCache
var _a
if (!this._cache_parserDefinitionParsers) {
if (this._isLooping) throw new Error(`Loop detected in ${this.id}`)
this._isLooping = true
this._cache_parserDefinitionParsers =
this.isRoot() || this.hasParserDefinitions
? this.makeProgramParserDefinitionCache()
: ((_a = this.parent.programParserDefinitionCache[this.get(ParsersConstants.extends)]) === null || _a === void 0 ? void 0 : _a.programParserDefinitionCache) || this.parent.programParserDefinitionCache
this._isLooping = false
}
return this._cache_parserDefinitionParsers
}
get extendedDef() {}
get hasParserDefinitions() {
return !!this.getSubparticlesByParser(parserDefinitionParser).length
}
Expand Down
16 changes: 15 additions & 1 deletion products/Parsers.ts.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,10 @@ class ParsersParserConstantString extends AbstractParserConstantParser {
class ParsersParserConstantFloat extends AbstractParserConstantParser {}
class ParsersParserConstantBoolean extends AbstractParserConstantParser {}
class AbstractParserDefinitionParser extends AbstractExtendibleParticle {
constructor() {
super(...arguments)
this._isLooping = false
}
createParserCombinator() {
// todo: some of these should just be on nonRootParticles
const types = [
Expand Down Expand Up @@ -1801,9 +1805,19 @@ ${captures}
return this._cache_ancestorParserIdsArray
}
get programParserDefinitionCache() {
if (!this._cache_parserDefinitionParsers) this._cache_parserDefinitionParsers = this.isRoot || this.hasParserDefinitions ? this.makeProgramParserDefinitionCache() : this.parent.programParserDefinitionCache
var _a
if (!this._cache_parserDefinitionParsers) {
if (this._isLooping) throw new Error(`Loop detected in ${this.id}`)
this._isLooping = true
this._cache_parserDefinitionParsers =
this.isRoot() || this.hasParserDefinitions
? this.makeProgramParserDefinitionCache()
: ((_a = this.parent.programParserDefinitionCache[this.get(ParsersConstants.extends)]) === null || _a === void 0 ? void 0 : _a.programParserDefinitionCache) || this.parent.programParserDefinitionCache
this._isLooping = false
}
return this._cache_parserDefinitionParsers
}
get extendedDef() {}
get hasParserDefinitions() {
return !!this.getSubparticlesByParser(parserDefinitionParser).length
}
Expand Down
2 changes: 1 addition & 1 deletion products/Particle.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
Particle.getVersion = () => "100.0.0"
Particle.getVersion = () => "100.0.1"
class AbstractExtendibleParticle extends Particle {
_getFromExtended(cuePath) {
const hit = this._getParticleFromExtended(cuePath)
Expand Down
2 changes: 1 addition & 1 deletion products/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
Particle.getVersion = () => "100.0.0"
Particle.getVersion = () => "100.0.1"
class AbstractExtendibleParticle extends Particle {
_getFromExtended(cuePath) {
const hit = this._getParticleFromExtended(cuePath)
Expand Down
3 changes: 3 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ node_modules/scroll-cli/microlangs/changes.parsers

thinColumns 4

📦 100.0.1 2024-12-07
🏥 fixed bug in Parsers where inline Parsers were not in scope in child Parsers

📦 100.0.0 2024-12-07
🎉 Finished migrating "keywordAtom" to "cueAtom"
⚠️ BREAKING: every `keywordAtom` is now `cueAtom`
Expand Down

0 comments on commit 1c507e8

Please sign in to comment.