diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/ParserGenerator.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/ParserGenerator.rsc index f19c70422a6..ddfeade3d52 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/ParserGenerator.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/ParserGenerator.rsc @@ -42,27 +42,27 @@ str getParserMethodName(conditional(Symbol s, _)) = getParserMethodName(s); default str getParserMethodName(Symbol s) = value2id(s); public str newGenerate(str package, str name, Grammar gr) { - JOB = "Generating parser ."; - jobStart("Generating parser ."); + str src = ""; + job("Generating parser .", void (void (str m, int w) worked) { int uniqueItem = 1; // -1 and -2 are reserved by the SGTDBF implementation int newItem() { uniqueItem += 1; return uniqueItem; }; - jobStep(JOB, "expanding parameterized symbols"); + worked("expanding parameterized symbols", 1); gr = expandParameterizedSymbols(gr); - jobStep(JOB, "generating stubs for regular"); + worked("generating stubs for regular", 1); gr = makeRegularStubs(gr); - jobStep(JOB, "generating syntax for holes"); + worked("generating syntax for holes", 1); gr = addHoles(gr); - jobStep(JOB, "generating literals"); + worked("generating literals", 1); gr = literals(gr); - jobStep(JOB, "establishing production set"); + worked("establishing production set", 1); uniqueProductions = {p | /Production p := gr, prod(_,_,_) := p || regular(_) := p}; - jobStep(JOB, "assigning unique ids to symbols"); + worked("assigning unique ids to symbols", 1); Production rewrite(Production p) = visit (p) { case Symbol s => s[id=newItem()] @@ -70,22 +70,22 @@ public str newGenerate(str package, str name, Grammar gr) { beforeUniqueGr = gr; gr.rules = (s : rewrite(gr.rules[s]) | s <- gr.rules); - jobStep(JOB, "generating item allocations"); + worked("generating item allocations", 1); newItems = generateNewItems(gr); - jobStep(JOB, "computing priority and associativity filter"); + worked("computing priority and associativity filter", 1); rel[int parent, int child] dontNest = computeDontNests(newItems, beforeUniqueGr, gr); // this creates groups of children that forbidden below certain parents rel[set[int] children, set[int] parents] dontNestGroups = { | rel[set[int] children, int parent] g := { | p <- dontNest.parent}, c <- g.children}; - //println("computing lookahead sets"); + //println("computing lookahead sets", 1); //gr = computeLookaheads(gr, extraLookaheads); - //println("optimizing lookahead automaton"); + //println("optimizing lookahead automaton", 1); //gr = compileLookaheads(gr); - jobStep(JOB, "printing the source code of the parser class"); + worked("printing the source code of the parser class", 1); src = "package ; ' @@ -238,8 +238,8 @@ public str newGenerate(str package, str name, Grammar gr) { ' ' <}> '}"; - jobEnd(JOB); - return src; + }, totalWork=9); + return src; } rel[int,int] computeDontNests(Items items, Grammar grammar, Grammar uniqueGrammar) { diff --git a/src/org/rascalmpl/library/util/Monitor.rsc b/src/org/rascalmpl/library/util/Monitor.rsc index 7dac4ca4582..5a30bb176b7 100644 --- a/src/org/rascalmpl/library/util/Monitor.rsc +++ b/src/org/rascalmpl/library/util/Monitor.rsc @@ -54,9 +54,9 @@ with a parameterized workload and the same label as the job name. @pitfalls{ * additional work with ((jobTodo)) is still possible, but you have to repeat the right job label. } -void job(str label, void (void (str message, int worked) step) block) { +void job(str label, void (void (str message, int worked) step) block, int totalWork=1) { try { - jobStart(label); + jobStart(label, totalWork=totalWork); block((str message, int worked) { jobStep(label, message, work=worked); }); @@ -81,9 +81,9 @@ with a parameterized workload and the same label as the job name. @pitfalls{ * additional work with ((jobTodo)) is still possible, but you have to repeat the right job label. } -void job(str label, void (void (int worked) step) block) { +void job(str label, void (void (int worked) step) block, int totalWork=1) { try { - jobStart(label); + jobStart(label, totalWork=totalWork); block((int worked) { jobStep(label, label, work=worked); }); @@ -108,9 +108,9 @@ with workload `1` and the same label as the job name. @pitfalls{ * additional work with ((jobTodo)) is still possible, but you have to repeat the right job label. } -void job(str label, void (void () step) block) { +void job(str label, void (void () step) block, int totalWork=1) { try { - jobStart(label); + jobStart(label, totalWork=totalWork); block(() { jobStep(label, label, work=1); }); @@ -128,9 +128,9 @@ void job(str label, void (void () step) block) { * the block code does not need to remember to end the job with the same job name. * the job is always properly ended, even when exceptions are thrown } -void job(str label, void () block) { +void job(str label, void () block, int totalWork=1) { try { - jobStart(label); + jobStart(label, totalWork=totalWork); block(); } catch x: {