Skip to content

Commit 1089999

Browse files
add summary stats for parser generation
1 parent 7fba3da commit 1089999

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Cakefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ option '-l', '--level [LEVEL]', 'log level [debug < info < log(default) < warn <
7878
setupConsole = ({level} = {}) ->
7979
global.cakeConsole = CakeConsole.stdio {level}
8080
global.console = global.cakeConsole
81-
console.log "log level = #{level}"
81+
console.info "log level = #{level}"
8282

8383
consoleTask = (name, description, action) ->
8484
global.task name, description, ({level = 'log', ...opts} = {}) ->
@@ -108,9 +108,18 @@ run = (args, callback) ->
108108
buildParser = ->
109109
helpers.extend global, require 'util'
110110
require 'jison'
111+
112+
# Gather summary statistics about the grammar.
113+
parser = require('./lib/coffeescript/grammar').parser
114+
{symbols_, terminals_, productions_} = parser
115+
countKeys = (obj) -> (Object.keys obj).length
116+
numSyms = countKeys symbols_
117+
numTerms = countKeys terminals_
118+
numProds = countKeys productions_
119+
console.info "parser created (#{numSyms} symbols, #{numTerms} terminals, #{numProds} productions)"
120+
111121
# We don't need `moduleMain`, since the parser is unlikely to be run standalone.
112-
parser = require('./lib/coffeescript/grammar').parser.generate(moduleMain: ->)
113-
fs.writeFileSync 'lib/coffeescript/parser.js', parser
122+
fs.writeFileSync 'lib/coffeescript/parser.js', parser.generate(moduleMain: ->)
114123

115124
buildExceptParser = (callback) ->
116125
files = fs.readdirSync 'src'

0 commit comments

Comments
 (0)