Skip to content

Commit 5907f8b

Browse files
Breck YunitsBreck Yunits
authored andcommitted
Rename Grammar to Parsers
1 parent 7821914 commit 5907f8b

File tree

119 files changed

+4564
-2091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4564
-2091
lines changed

builder.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ const { TreeNode } = require("./products/TreeNode.js")
44
const { TypeScriptRewriter } = require("./products/TypeScriptRewriter.js")
55
const { Disk } = require("./products/Disk.node.js")
66
const { Utils } = require("./products/Utils.js")
7-
const { HandGrammarProgram } = require("./products/GrammarLanguage.js")
7+
const { HandParsersProgram } = require("./products/Parsers.js")
88
const { TestRacer } = require("./products/TestRacer.js")
9-
const { GrammarCompiler } = require("./products/GrammarCompiler.js")
9+
const { ParsersCompiler } = require("./products/ParsersCompiler.js")
1010
const path = require("path")
1111
const fs = require("fs")
1212
const { execSync } = require("child_process")
@@ -16,7 +16,7 @@ const prettierConfig = require("./package.json").prettier
1616
import { scrollNotationTypes } from "./products/scrollNotationTypes"
1717

1818
// todo: remove?
19-
const registeredExtensions: scrollNotationTypes.stringMap = { js: "//", maia: "doc.tooling ", ts: "//", grammar: "tooling ", gram: "tooling " }
19+
const registeredExtensions: scrollNotationTypes.stringMap = { js: "//", maia: "doc.tooling ", ts: "//", parsers: "tooling ", gram: "tooling " }
2020

2121
class Builder extends TreeNode {
2222
private _typeScriptToJavascript(sourceCode: string, forBrowser = false) {
@@ -187,23 +187,23 @@ class Builder extends TreeNode {
187187
this._buildTsc(Disk.read(__filename), path.join(__dirname, "builder.js"))
188188
}
189189

190-
makeGrammarFileTestTree(grammarPath: scrollNotationTypes.grammarFilePath) {
191-
// todo: can we ditch these dual tests at some point? ideally Grammar should be bootstrapped correct?
190+
makeParsersFileTestTree(parsersPath: scrollNotationTypes.parsersFilePath) {
191+
// todo: can we ditch these dual tests at some point? ideally Parsers should be bootstrapped correct?
192192
const testTree: any = {}
193-
const checkGrammarFile = (equal: Function, program: any) => {
193+
const checkParsersFile = (equal: Function, program: any) => {
194194
// Act
195195
const errs = program.getAllErrors()
196196
if (errs.length) console.log(errs.join("\n"))
197197
//Assert
198198
equal(errs.length, 0, "should be no errors")
199199
}
200200

201-
const handGrammarProgram = new HandGrammarProgram(Disk.read(grammarPath))
201+
const handParsersProgram = new HandParsersProgram(Disk.read(parsersPath))
202202

203-
testTree[`grammarCheckOf${grammarPath}`] = (equal: Function) => checkGrammarFile(equal, GrammarCompiler.compileGrammarAndCreateProgram(grammarPath, path.join(__dirname, "langs", "grammar", "grammar.grammar")))
204-
testTree[`handGrammarCheckOf${grammarPath}`] = (equal: Function) => checkGrammarFile(equal, handGrammarProgram)
203+
testTree[`parsersCheckOf${parsersPath}`] = (equal: Function) => checkParsersFile(equal, ParsersCompiler.compileParsersAndCreateProgram(parsersPath, path.join(__dirname, "langs", "parsers", "parsers.parsers")))
204+
testTree[`handParsersCheckOf${parsersPath}`] = (equal: Function) => checkParsersFile(equal, handParsersProgram)
205205

206-
Object.assign(testTree, handGrammarProgram.examplesToTestBlocks())
206+
Object.assign(testTree, handParsersProgram.examplesToTestBlocks())
207207

208208
return testTree
209209
}
@@ -251,25 +251,25 @@ class Builder extends TreeNode {
251251
}
252252

253253
produceAllLangs() {
254-
const langs = `arrow chuck dug dumbdown fire fruit grammar hakon jibberish jibjab numbers poop project stamp stump swarm`.split(" ")
254+
const langs = `arrow chuck dug dumbdown fire fruit parsers hakon jibberish jibjab numbers poop project stamp stump swarm`.split(" ")
255255
langs.forEach(lang => this.produceLang(lang))
256256
}
257257

258258
produceLang(langName: string) {
259-
const newFilePath = path.join(__dirname, "langs", langName, `${langName}.grammar`)
260-
GrammarCompiler.compileGrammarForBrowser(newFilePath, this._getProductFolder(), true)
261-
GrammarCompiler.compileGrammarForNodeJs(newFilePath, this._getProductFolder(), true, ".")
259+
const newFilePath = path.join(__dirname, "langs", langName, `${langName}.parsers`)
260+
ParsersCompiler.compileParsersForBrowser(newFilePath, this._getProductFolder(), true)
261+
ParsersCompiler.compileParsersForNodeJs(newFilePath, this._getProductFolder(), true, ".")
262262
}
263263

264264
private _getProductsTree() {
265265
return TreeNode.fromDisk(__dirname + "/products.tree")
266266
}
267267

268268
buildJibJab() {
269-
const combined = GrammarCompiler.combineFiles([__dirname + "/langs/jibberish/jibberish.grammar", __dirname + "/langs/jibjab/jibjab.gram"])
270-
const path = __dirname + "/langs/jibjab/jibjab.grammar"
269+
const combined = ParsersCompiler.combineFiles([__dirname + "/langs/jibberish/jibberish.parsers", __dirname + "/langs/jibjab/jibjab.gram"])
270+
const path = __dirname + "/langs/jibjab/jibjab.parsers"
271271
combined.toDisk(path)
272-
GrammarCompiler.formatFileInPlace(path, __dirname + "/langs/grammar/grammar.grammar")
272+
ParsersCompiler.formatFileInPlace(path, __dirname + "/langs/parsers/parsers.parsers")
273273
}
274274

275275
_getProductFolder() {
@@ -297,7 +297,7 @@ class Builder extends TreeNode {
297297

298298
const fileTestTree: any = {}
299299

300-
allTestFiles.filter(file => file.endsWith(".grammar")).forEach(file => (fileTestTree[file] = this.makeGrammarFileTestTree(file)))
300+
allTestFiles.filter(file => file.endsWith(".parsers")).forEach(file => (fileTestTree[file] = this.makeParsersFileTestTree(file)))
301301

302302
allTestFiles.filter(file => file.endsWith(".test.js") || file.endsWith(".test.ts")).forEach(file => (fileTestTree[file] = require(file).testTree))
303303

@@ -314,7 +314,7 @@ treeNode
314314
swim
315315
testRacer
316316
treeFileSystem
317-
grammar
317+
parsers
318318
utils
319319
treeComponentFramework`.split("\n")
320320
const fileTree = {}

0 commit comments

Comments
 (0)