From 108999931f44184db0e73c922fe26ee5a0fa041d Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Mon, 11 Nov 2024 06:06:19 -0500 Subject: [PATCH] add summary stats for parser generation --- Cakefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Cakefile b/Cakefile index c40db7238a..2fdb045bef 100644 --- a/Cakefile +++ b/Cakefile @@ -78,7 +78,7 @@ option '-l', '--level [LEVEL]', 'log level [debug < info < log(default) < warn < setupConsole = ({level} = {}) -> global.cakeConsole = CakeConsole.stdio {level} global.console = global.cakeConsole - console.log "log level = #{level}" + console.info "log level = #{level}" consoleTask = (name, description, action) -> global.task name, description, ({level = 'log', ...opts} = {}) -> @@ -108,9 +108,18 @@ run = (args, callback) -> buildParser = -> helpers.extend global, require 'util' require 'jison' + + # Gather summary statistics about the grammar. + parser = require('./lib/coffeescript/grammar').parser + {symbols_, terminals_, productions_} = parser + countKeys = (obj) -> (Object.keys obj).length + numSyms = countKeys symbols_ + numTerms = countKeys terminals_ + numProds = countKeys productions_ + console.info "parser created (#{numSyms} symbols, #{numTerms} terminals, #{numProds} productions)" + # We don't need `moduleMain`, since the parser is unlikely to be run standalone. - parser = require('./lib/coffeescript/grammar').parser.generate(moduleMain: ->) - fs.writeFileSync 'lib/coffeescript/parser.js', parser + fs.writeFileSync 'lib/coffeescript/parser.js', parser.generate(moduleMain: ->) buildExceptParser = (callback) -> files = fs.readdirSync 'src'