@@ -4,9 +4,9 @@ const { TreeNode } = require("./products/TreeNode.js")
4
4
const { TypeScriptRewriter } = require ( "./products/TypeScriptRewriter.js" )
5
5
const { Disk } = require ( "./products/Disk.node.js" )
6
6
const { Utils } = require ( "./products/Utils.js" )
7
- const { HandGrammarProgram } = require ( "./products/GrammarLanguage .js" )
7
+ const { HandParsersProgram } = require ( "./products/Parsers .js" )
8
8
const { TestRacer } = require ( "./products/TestRacer.js" )
9
- const { GrammarCompiler } = require ( "./products/GrammarCompiler .js" )
9
+ const { ParsersCompiler } = require ( "./products/ParsersCompiler .js" )
10
10
const path = require ( "path" )
11
11
const fs = require ( "fs" )
12
12
const { execSync } = require ( "child_process" )
@@ -16,7 +16,7 @@ const prettierConfig = require("./package.json").prettier
16
16
import { scrollNotationTypes } from "./products/scrollNotationTypes"
17
17
18
18
// 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 " }
20
20
21
21
class Builder extends TreeNode {
22
22
private _typeScriptToJavascript ( sourceCode : string , forBrowser = false ) {
@@ -187,23 +187,23 @@ class Builder extends TreeNode {
187
187
this . _buildTsc ( Disk . read ( __filename ) , path . join ( __dirname , "builder.js" ) )
188
188
}
189
189
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?
192
192
const testTree : any = { }
193
- const checkGrammarFile = ( equal : Function , program : any ) => {
193
+ const checkParsersFile = ( equal : Function , program : any ) => {
194
194
// Act
195
195
const errs = program . getAllErrors ( )
196
196
if ( errs . length ) console . log ( errs . join ( "\n" ) )
197
197
//Assert
198
198
equal ( errs . length , 0 , "should be no errors" )
199
199
}
200
200
201
- const handGrammarProgram = new HandGrammarProgram ( Disk . read ( grammarPath ) )
201
+ const handParsersProgram = new HandParsersProgram ( Disk . read ( parsersPath ) )
202
202
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 )
205
205
206
- Object . assign ( testTree , handGrammarProgram . examplesToTestBlocks ( ) )
206
+ Object . assign ( testTree , handParsersProgram . examplesToTestBlocks ( ) )
207
207
208
208
return testTree
209
209
}
@@ -251,25 +251,25 @@ class Builder extends TreeNode {
251
251
}
252
252
253
253
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 ( " " )
255
255
langs . forEach ( lang => this . produceLang ( lang ) )
256
256
}
257
257
258
258
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 , "." )
262
262
}
263
263
264
264
private _getProductsTree ( ) {
265
265
return TreeNode . fromDisk ( __dirname + "/products.tree" )
266
266
}
267
267
268
268
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 "
271
271
combined . toDisk ( path )
272
- GrammarCompiler . formatFileInPlace ( path , __dirname + "/langs/grammar/grammar.grammar " )
272
+ ParsersCompiler . formatFileInPlace ( path , __dirname + "/langs/parsers/parsers.parsers " )
273
273
}
274
274
275
275
_getProductFolder ( ) {
@@ -297,7 +297,7 @@ class Builder extends TreeNode {
297
297
298
298
const fileTestTree : any = { }
299
299
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 ) ) )
301
301
302
302
allTestFiles . filter ( file => file . endsWith ( ".test.js" ) || file . endsWith ( ".test.ts" ) ) . forEach ( file => ( fileTestTree [ file ] = require ( file ) . testTree ) )
303
303
@@ -314,7 +314,7 @@ treeNode
314
314
swim
315
315
testRacer
316
316
treeFileSystem
317
- grammar
317
+ parsers
318
318
utils
319
319
treeComponentFramework` . split ( "\n" )
320
320
const fileTree = { }
0 commit comments