diff options
Diffstat (limited to 'docs/jacoco-ut/bjc.everge/ReplPair.java.html')
| -rw-r--r-- | docs/jacoco-ut/bjc.everge/ReplPair.java.html | 764 |
1 files changed, 397 insertions, 367 deletions
diff --git a/docs/jacoco-ut/bjc.everge/ReplPair.java.html b/docs/jacoco-ut/bjc.everge/ReplPair.java.html index 9701d27..eea7307 100644 --- a/docs/jacoco-ut/bjc.everge/ReplPair.java.html +++ b/docs/jacoco-ut/bjc.everge/ReplPair.java.html @@ -1,13 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ReplPair.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">everge</a> > <a href="index.source.html" class="el_package">bjc.everge</a> > <span class="el_source">ReplPair.java</span></div><h1>ReplPair.java</h1><pre class="source lang-java linenums">package bjc.everge; -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; +import java.util.*; +import java.util.function.*; +import java.util.regex.*; -import java.util.function.UnaryOperator; - -import bjc.everge.ControlledString.Control; -import bjc.everge.ControlledString.ParseStrings; +import bjc.everge.ControlledString.*; /** * String pairs for replacements. @@ -22,7 +19,7 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St private int stage; // Status of this pair with regards to doing staging stuff -<span class="fc" id="L25"> private StageStatus stat = StageStatus.BOTH;</span> +<span class="fc" id="L22"> private StageStatus stat = StageStatus.BOTH;</span> /** * The priority for this replacement. @@ -37,6 +34,14 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St public String name; /** + * The guard for this replacement. + * + * The guard of the replacement is a regex that has to match before the pair will be considered. + * Defaults to being blank. + */ + public String guard; + + /** * The string to look for. */ public String find; @@ -50,8 +55,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * Create a new blank replacement pair. */ public ReplPair() { -<span class="fc" id="L53"> this("", "", 1, null);</span> -<span class="fc" id="L54"> }</span> +<span class="fc" id="L58"> this("", "", 1, null);</span> +<span class="fc" id="L59"> }</span> /** * Create a new replacement pair with a priority of 1. @@ -62,8 +67,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The string to replace. */ public ReplPair(String f, String r) { -<span class="fc" id="L65"> this(f, r, 1);</span> -<span class="fc" id="L66"> }</span> +<span class="fc" id="L70"> this(f, r, 1);</span> +<span class="fc" id="L71"> }</span> /** * Create a new named replacement pair with a priority of 1. @@ -76,8 +81,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The name of the replacement pair. */ public ReplPair(String f, String r, String n) { -<span class="nc" id="L79"> this(f, r, 1, n);</span> -<span class="nc" id="L80"> }</span> +<span class="nc" id="L84"> this(f, r, 1, n);</span> +<span class="nc" id="L85"> }</span> /** * Create a new replacement pair with a set priority. @@ -90,8 +95,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The priority for the replacement. */ public ReplPair(String f, String r, int p) { -<span class="fc" id="L93"> this(f, r, p, f);</span> -<span class="fc" id="L94"> }</span> +<span class="fc" id="L98"> this(f, r, p, f);</span> +<span class="fc" id="L99"> }</span> /** * Create a new replacement pair with a set priority and name. @@ -105,14 +110,14 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * @param p * The priority for the replacement. */ -<span class="fc" id="L108"> public ReplPair(String f, String r, int p, String n) {</span> -<span class="fc" id="L109"> find = f;</span> -<span class="fc" id="L110"> replace = r;</span> +<span class="fc" id="L113"> public ReplPair(String f, String r, int p, String n) {</span> +<span class="fc" id="L114"> find = f;</span> +<span class="fc" id="L115"> replace = r;</span> -<span class="fc" id="L112"> name = n;</span> +<span class="fc" id="L117"> name = n;</span> -<span class="fc" id="L114"> priority = p;</span> -<span class="fc" id="L115"> }</span> +<span class="fc" id="L119"> priority = p;</span> +<span class="fc" id="L120"> }</span> /** * Read a list of replacement pairs from an input source. @@ -123,9 +128,9 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(Scanner scn) { -<span class="fc" id="L126"> List<ReplPair> lst = new ArrayList<>();</span> +<span class="fc" id="L131"> List<ReplPair> lst = new ArrayList<>();</span> -<span class="fc" id="L128"> return readList(lst, scn);</span> +<span class="fc" id="L133"> return readList(lst, scn);</span> } /** @@ -140,15 +145,15 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn) { -<span class="fc" id="L143"> List<ReplError> errList = new ArrayList<>();</span> +<span class="fc" id="L148"> List<ReplError> errList = new ArrayList<>();</span> -<span class="fc" id="L145"> List<ReplPair> rplPar = readList(detals, scn, errList);</span> +<span class="fc" id="L150"> List<ReplPair> rplPar = readList(detals, scn, errList);</span> -<span class="fc bfc" id="L147" title="All 2 branches covered."> if (errList.size() != 0) {</span> -<span class="fc" id="L148"> throw new ReplParseException("", errList);</span> +<span class="fc bfc" id="L152" title="All 2 branches covered."> if (errList.size() != 0) {</span> +<span class="fc" id="L153"> throw new BadReplParse("", errList);</span> } -<span class="fc" id="L151"> return rplPar;</span> +<span class="fc" id="L156"> return rplPar;</span> } /** @@ -165,7 +170,7 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn, List<ReplError> errs) { -<span class="fc" id="L168"> return readList(detals, scn, errs, new ReplOpts());</span> +<span class="fc" id="L173"> return readList(detals, scn, errs, new ReplOpts());</span> } /** @@ -187,627 +192,652 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St List<ReplPair> detals, Scanner scn, List<ReplError> errs, ReplOpts ropts) { -<span class="fc" id="L190"> IntHolder lno = new IntHolder();</span> -<span class="fc" id="L191"> IntHolder pno = new IntHolder();</span> +<span class="fc" id="L195"> IntHolder lno = new IntHolder();</span> +<span class="fc" id="L196"> IntHolder pno = new IntHolder();</span> -<span class="fc" id="L193"> List<List<ReplPair>> stages = new ArrayList<>();</span> -<span class="fc" id="L194"> stages.add(new ArrayList<ReplPair>());</span> +<span class="fc" id="L198"> List<List<ReplPair>> stages = new ArrayList<>();</span> +<span class="fc" id="L199"> stages.add(new ArrayList<ReplPair>());</span> // For every line in the source... -<span class="fc bfc" id="L197" title="All 2 branches covered."> while (scn.hasNextLine()) {</span> -<span class="fc" id="L198"> String name = scn.nextLine().trim();</span> -<span class="fc" id="L199"> lno.incr();</span> +<span class="fc bfc" id="L202" title="All 2 branches covered."> while (scn.hasNextLine()) {</span> +<span class="fc" id="L203"> String name = scn.nextLine().trim();</span> +<span class="fc" id="L204"> lno.incr();</span> // If its commented or blank, skip it -<span class="fc bfc" id="L202" title="All 2 branches covered."> if (name.equals("")) continue;</span> -<span class="fc bfc" id="L203" title="All 2 branches covered."> if (name.startsWith("#")) continue;</span> +<span class="fc bfc" id="L207" title="All 2 branches covered."> if (name.equals("")) continue;</span> +<span class="fc bfc" id="L208" title="All 2 branches covered."> if (name.startsWith("#")) continue;</span> // Global control. Process it. -<span class="fc bfc" id="L206" title="All 2 branches covered."> if (name.startsWith("|//")) {</span> -<span class="fc" id="L207"> readGlobal(name, scn, errs, ropts, lno, pno);</span> +<span class="fc bfc" id="L211" title="All 2 branches covered."> if (name.startsWith("|//")) {</span> +<span class="fc" id="L212"> readGlobal(name, scn, errs, ropts, lno, pno);</span> -<span class="fc" id="L209"> continue;</span> +<span class="fc" id="L214"> continue;</span> } -<span class="fc" id="L212"> ReplPair rp = new ReplPair();</span> +<span class="fc" id="L217"> ReplPair rp = new ReplPair();</span> -<span class="fc" id="L214"> rp.priority = ropts.defPrior;</span> -<span class="fc" id="L215"> rp.stat = ropts.defStatus;</span> -<span class="fc" id="L216"> rp.lno = lno.get();</span> -<span class="fc" id="L217"> rp.stage = ropts.defStage;</span> +<span class="fc" id="L219"> rp.priority = ropts.defPrior;</span> +<span class="fc" id="L220"> rp.stat = ropts.defStatus;</span> +<span class="fc" id="L221"> rp.lno = lno.get();</span> +<span class="fc" id="L222"> rp.stage = ropts.defStage;</span> -<span class="fc" id="L219"> boolean isMulti = ropts.defMulti;</span> +<span class="fc" id="L224"> boolean isMulti = ropts.defMulti;</span> { -<span class="fc" id="L222"> String tmpName = readName(name, scn, errs, rp, ropts, lno, pno);</span> -<span class="pc bpc" id="L223" title="1 of 2 branches missed."> if (tmpName == null) continue;</span> -<span class="fc" id="L224"> name = tmpName;</span> +<span class="fc" id="L227"> String tmpName = readName(name, scn, errs, rp, ropts, lno, pno);</span> +<span class="pc bpc" id="L228" title="1 of 2 branches missed."> if (tmpName == null) continue;</span> +<span class="fc" id="L229"> name = tmpName;</span> } -<span class="fc" id="L227"> rp.find = name;</span> -<span class="pc bpc" id="L228" title="1 of 2 branches missed."> if (rp.name == null) rp.name = name;</span> +<span class="fc" id="L232"> rp.find = name;</span> +<span class="pc bpc" id="L233" title="1 of 2 branches missed."> if (rp.name == null) rp.name = name;</span> // We started to process the pair, mark it as being // started -<span class="fc" id="L232"> pno.incr();</span> -<span class="fc" id="L233"> String body = null;</span> +<span class="fc" id="L237"> pno.incr();</span> +<span class="fc" id="L238"> String body = null;</span> // Read in the next uncommented line do { -<span class="fc bfc" id="L237" title="All 2 branches covered."> if (!scn.hasNextLine()) break; </span> +<span class="fc bfc" id="L242" title="All 2 branches covered."> if (!scn.hasNextLine()) break; </span> -<span class="fc" id="L239"> body = scn.nextLine().trim();</span> -<span class="fc" id="L240"> lno.incr();</span> -<span class="pc bpc" id="L241" title="1 of 2 branches missed."> } while (body.startsWith("#"));</span> +<span class="fc" id="L244"> body = scn.nextLine().trim();</span> +<span class="fc" id="L245"> lno.incr();</span> +<span class="pc bpc" id="L246" title="1 of 2 branches missed."> } while (body.startsWith("#"));</span> -<span class="fc bfc" id="L243" title="All 2 branches covered."> if (body == null) {</span> -<span class="fc" id="L244"> String msg = String.format(</span> +<span class="fc bfc" id="L248" title="All 2 branches covered."> if (body == null) {</span> +<span class="fc" id="L249"> String msg = String.format(</span> "Ran out of input looking for replacement body for raw name '%s'", name); -<span class="fc" id="L247"> errs.add(new ReplError(lno, pno, msg, null));</span> -<span class="fc" id="L248"> break;</span> +<span class="fc" id="L252"> errs.add(new ReplError(lno, pno, msg, null));</span> +<span class="fc" id="L253"> break;</span> } -<span class="fc" id="L251"> isMulti = ropts.defMulti;</span> +<span class="fc" id="L256"> isMulti = ropts.defMulti;</span> -<span class="fc" id="L253"> ControlledString cs = getControls(body, errs, ropts, lno, pno, "body");</span> +<span class="fc" id="L258"> ControlledString cs = getControls(body, errs, ropts, lno, pno, "body");</span> // Body has attached controls, process them. -<span class="pc bpc" id="L255" title="1 of 2 branches missed."> if (cs.hasControls()) {</span> -<span class="nc bnc" id="L256" title="All 2 branches missed."> for (Control cont : cs.controls) {</span> -<span class="nc bnc" id="L257" title="All 4 branches missed."> switch (cont.name) {</span> +<span class="pc bpc" id="L260" title="1 of 2 branches missed."> if (cs.hasControls()) {</span> +<span class="nc bnc" id="L261" title="All 2 branches missed."> for (Control cont : cs.controls) {</span> +<span class="nc bnc" id="L262" title="All 4 branches missed."> switch (cont.name) {</span> case "MULTITRUE": case "MULTIT": case "MT": -<span class="nc" id="L261"> isMulti = true;</span> -<span class="nc" id="L262"> break;</span> +<span class="nc" id="L266"> isMulti = true;</span> +<span class="nc" id="L267"> break;</span> case "MULTIFALSE": case "MULTIF": case "MF": -<span class="nc" id="L266"> isMulti = false;</span> -<span class="nc" id="L267"> break;</span> +<span class="nc" id="L271"> isMulti = false;</span> +<span class="nc" id="L272"> break;</span> case "MULTI": case "M": -<span class="nc bnc" id="L270" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L271"> String errMsg = String.format("Expected one multi flag (got %d)", cont.count());</span> -<span class="nc" id="L272"> errs.add(new ReplError(lno, pno, errMsg, body));</span> -<span class="nc" id="L273"> } else {</span> -<span class="nc" id="L274"> isMulti = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc bnc" id="L275" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L276"> String errMsg = String.format("Expected one multi flag (got %d)", cont.count());</span> +<span class="nc" id="L277"> errs.add(new ReplError(lno, pno, errMsg, body));</span> +<span class="nc" id="L278"> } else {</span> +<span class="nc" id="L279"> isMulti = Boolean.parseBoolean(cont.get(0));</span> } -<span class="nc" id="L276"> break;</span> +<span class="nc" id="L281"> break;</span> default: { -<span class="nc" id="L279"> String errMsg = String.format("Invalid control name '%s'", cont.name);</span> -<span class="nc" id="L280"> errs.add(new ReplError(lno, pno, errMsg, body));</span> +<span class="nc" id="L284"> String errMsg = String.format("Invalid control name '%s'", cont.name);</span> +<span class="nc" id="L285"> errs.add(new ReplError(lno, pno, errMsg, body));</span> } break; } } -<span class="nc" id="L286"> body = cs.strang;</span> +<span class="nc" id="L291"> body = cs.strang;</span> } -<span class="fc bfc" id="L289" title="All 2 branches covered."> if (isMulti) {</span> -<span class="fc" id="L290"> String tmp = readMultiLine(body, scn, ropts, errs, "body", lno);</span> -<span class="pc bpc" id="L291" title="1 of 2 branches missed."> if (tmp == null) continue;</span> -<span class="fc" id="L292"> body = tmp;</span> +<span class="fc bfc" id="L294" title="All 2 branches covered."> if (isMulti) {</span> +<span class="fc" id="L295"> String tmp = readMultiLine(body, scn, ropts, errs, "body", lno);</span> +<span class="pc bpc" id="L296" title="1 of 2 branches missed."> if (tmp == null) continue;</span> +<span class="fc" id="L297"> body = tmp;</span> } -<span class="fc" id="L295"> rp.replace = body;</span> +<span class="fc" id="L300"> rp.replace = body;</span> -<span class="fc" id="L297"> List<ReplPair> stageList = null;</span> -<span class="pc bpc" id="L298" title="1 of 4 branches missed."> if (rp.stage == 0 || stages.size() < (rp.stage - 1)) {</span> -<span class="fc" id="L299"> stageList = stages.get(rp.stage);</span> +<span class="fc" id="L302"> List<ReplPair> stageList = null;</span> +<span class="pc bpc" id="L303" title="1 of 4 branches missed."> if (rp.stage == 0 || stages.size() < (rp.stage - 1)) {</span> +<span class="fc" id="L304"> stageList = stages.get(rp.stage);</span> -<span class="pc bpc" id="L301" title="1 of 2 branches missed."> if (stageList == null) {</span> -<span class="nc" id="L302"> stageList = new ArrayList<>();</span> +<span class="pc bpc" id="L306" title="1 of 2 branches missed."> if (stageList == null) {</span> +<span class="nc" id="L307"> stageList = new ArrayList<>();</span> -<span class="nc" id="L304"> stages.add(rp.stage, stageList);</span> +<span class="nc" id="L309"> stages.add(rp.stage, stageList);</span> } } else { -<span class="fc bfc" id="L307" title="All 2 branches covered."> for (int i = stages.size(); i <= rp.stage; i++) {</span> -<span class="fc" id="L308"> stages.add(new ArrayList<>());</span> +<span class="fc bfc" id="L312" title="All 2 branches covered."> for (int i = stages.size(); i <= rp.stage; i++) {</span> +<span class="fc" id="L313"> stages.add(new ArrayList<>());</span> } -<span class="fc" id="L311"> stageList = stages.get(rp.stage);</span> +<span class="fc" id="L316"> stageList = stages.get(rp.stage);</span> } -<span class="pc bpc" id="L314" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> -<span class="nc" id="L315"> ropts.errStream.printf("\t[DEBUG] Stage %d: Added %s\n\t\tContents: %s\n",</span> -<span class="nc" id="L316"> rp.stage, rp, stageList);</span> +<span class="pc bpc" id="L319" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> +<span class="nc" id="L320"> ropts.errStream.printf("\t[DEBUG] Stage %d: Added %s\n\t\tContents: %s\n",</span> +<span class="nc" id="L321"> rp.stage, rp, stageList);</span> } -<span class="fc" id="L319"> stageList.add(rp);</span> -<span class="fc" id="L320"> }</span> +<span class="fc" id="L324"> stageList.add(rp);</span> +<span class="fc" id="L325"> }</span> // Special-case one-stage processing. -<span class="fc bfc" id="L323" title="All 2 branches covered."> if (stages.size() == 1) {</span> -<span class="pc bpc" id="L324" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Executing single-stage bypass\n");</span> +<span class="fc bfc" id="L328" title="All 2 branches covered."> if (stages.size() == 1) {</span> +<span class="pc bpc" id="L329" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Executing single-stage bypass\n");</span> -<span class="fc bfc" id="L326" title="All 2 branches covered."> for (ReplPair rp : stages.iterator().next()) {</span> -<span class="pc bpc" id="L327" title="1 of 2 branches missed."> if (rp.stat == StageStatus.INTERNAL) {</span> -<span class="nc bnc" id="L328" title="All 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluding internal RP %s\n", rp);</span> +<span class="fc bfc" id="L331" title="All 2 branches covered."> for (ReplPair rp : stages.iterator().next()) {</span> +<span class="pc bpc" id="L332" title="1 of 2 branches missed."> if (rp.stat == StageStatus.INTERNAL) {</span> +<span class="nc bnc" id="L333" title="All 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluding internal RP %s\n", rp);</span> continue; } -<span class="fc" id="L333"> detals.add(rp);</span> -<span class="fc" id="L334"> }</span> +<span class="fc" id="L338"> detals.add(rp);</span> +<span class="fc" id="L339"> }</span> -<span class="fc" id="L336"> detals.sort(null);</span> +<span class="fc" id="L341"> detals.sort(null);</span> -<span class="fc" id="L338"> return detals;</span> +<span class="fc" id="L343"> return detals;</span> } // Handle stages -<span class="fc" id="L342"> List<ReplPair> tmpList = new ArrayList<>();</span> -<span class="fc" id="L343"> tmpList.addAll(detals);</span> +<span class="fc" id="L347"> List<ReplPair> tmpList = new ArrayList<>();</span> +<span class="fc" id="L348"> tmpList.addAll(detals);</span> -<span class="pc bpc" id="L345" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Stages: %s\n", stages);</span> +<span class="pc bpc" id="L350" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Stages: %s\n", stages);</span> -<span class="fc" id="L347"> int procStg = 0;</span> -<span class="fc bfc" id="L348" title="All 2 branches covered."> for (List<ReplPair> stageList : stages) {</span> -<span class="fc" id="L349"> procStg += 1;</span> -<span class="fc" id="L350"> List<ReplPair> curStage = new ArrayList<>();</span> +<span class="fc" id="L352"> int procStg = 0;</span> +<span class="fc bfc" id="L353" title="All 2 branches covered."> for (List<ReplPair> stageList : stages) {</span> +<span class="fc" id="L354"> procStg += 1;</span> +<span class="fc" id="L355"> List<ReplPair> curStage = new ArrayList<>();</span> -<span class="pc bpc" id="L352" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Staging stage %d of %d: %s\n",</span> -<span class="nc" id="L353"> procStg, stageList.size(), stageList);</span> +<span class="pc bpc" id="L357" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Staging stage %d of %d: %s\n",</span> +<span class="nc" id="L358"> procStg, stageList.size(), stageList);</span> -<span class="fc bfc" id="L355" title="All 2 branches covered."> for (ReplPair rp : stageList) {</span> +<span class="fc bfc" id="L360" title="All 2 branches covered."> for (ReplPair rp : stageList) {</span> // Process through every pair in the previous // stages -<span class="fc bfc" id="L358" title="All 2 branches covered."> for (ReplPair curPar : tmpList) {</span> -<span class="fc" id="L359"> String tmp = rp.replace.replaceAll(curPar.find, curPar.replace);</span> +<span class="fc bfc" id="L363" title="All 2 branches covered."> for (ReplPair curPar : tmpList) {</span> +<span class="fc" id="L364"> String tmp = rp.replace.replaceAll(curPar.find, curPar.replace);</span> -<span class="pc bpc" id="L361" title="3 of 4 branches missed."> if (ropts.isTrace && !rp.replace.equals(tmp)) {</span> -<span class="nc" id="L362"> ropts.errStream.printf("\t[DEBUG] Staged '%s' -> '%s'\t%s\n",</span> +<span class="pc bpc" id="L366" title="3 of 4 branches missed."> if (ropts.isTrace && !rp.replace.equals(tmp)) {</span> +<span class="nc" id="L367"> ropts.errStream.printf("\t[DEBUG] Staged '%s' -> '%s'\t%s\n",</span> rp.replace, tmp, curPar); } -<span class="fc" id="L366"> rp.replace = tmp;</span> -<span class="fc" id="L367"> }</span> +<span class="fc" id="L371"> rp.replace = tmp;</span> +<span class="fc" id="L372"> }</span> // If we're external; add straight to the output -<span class="fc bfc" id="L370" title="All 2 branches covered."> if (rp.stat == StageStatus.EXTERNAL) {</span> -<span class="pc bpc" id="L371" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> -<span class="nc" id="L372"> ropts.errStream.printf("\t[DEBUG] Skipped external for staging: %s\n",</span> +<span class="fc bfc" id="L375" title="All 2 branches covered."> if (rp.stat == StageStatus.EXTERNAL) {</span> +<span class="pc bpc" id="L376" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> +<span class="nc" id="L377"> ropts.errStream.printf("\t[DEBUG] Skipped external for staging: %s\n",</span> rp); } -<span class="fc" id="L376"> detals.add(rp);</span> +<span class="fc" id="L381"> detals.add(rp);</span> } else { -<span class="pc bpc" id="L378" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> -<span class="nc" id="L379"> ropts.errStream.printf("\t[DEBUG] Added to stage %d: %s\n\t\tContents: %s\n",</span> -<span class="nc" id="L380"> procStg, rp, curStage);</span> +<span class="pc bpc" id="L383" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> +<span class="nc" id="L384"> ropts.errStream.printf("\t[DEBUG] Added to stage %d: %s\n\t\tContents: %s\n",</span> +<span class="nc" id="L385"> procStg, rp, curStage);</span> } -<span class="fc" id="L383"> curStage.add(rp);</span> +<span class="fc" id="L388"> curStage.add(rp);</span> } -<span class="fc" id="L385"> }</span> +<span class="fc" id="L390"> }</span> -<span class="fc" id="L387"> tmpList.addAll(curStage);</span> -<span class="fc" id="L388"> tmpList.sort(null);</span> -<span class="fc" id="L389"> }</span> +<span class="fc" id="L392"> tmpList.addAll(curStage);</span> +<span class="fc" id="L393"> tmpList.sort(null);</span> +<span class="fc" id="L394"> }</span> // Copy over to output, excluding internals -<span class="fc bfc" id="L392" title="All 2 branches covered."> for (ReplPair rp : tmpList) {</span> -<span class="fc bfc" id="L393" title="All 2 branches covered."> if (rp.stat == StageStatus.INTERNAL) {</span> -<span class="pc bpc" id="L394" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluded internal: %s\n", rp);</span> +<span class="fc bfc" id="L397" title="All 2 branches covered."> for (ReplPair rp : tmpList) {</span> +<span class="fc bfc" id="L398" title="All 2 branches covered."> if (rp.stat == StageStatus.INTERNAL) {</span> +<span class="pc bpc" id="L399" title="1 of 2 branches missed."> if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluded internal: %s\n", rp);</span> continue; } -<span class="fc" id="L399"> detals.add(rp);</span> -<span class="fc" id="L400"> }</span> +<span class="fc" id="L404"> detals.add(rp);</span> +<span class="fc" id="L405"> }</span> -<span class="fc" id="L402"> detals.sort(null);</span> +<span class="fc" id="L407"> detals.sort(null);</span> -<span class="pc bpc" id="L404" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> -<span class="nc" id="L405"> ropts.errStream.printf("\t[DEBUG] Final output: %s\n", detals);</span> +<span class="pc bpc" id="L409" title="1 of 2 branches missed."> if (ropts.isTrace) {</span> +<span class="nc" id="L410"> ropts.errStream.printf("\t[DEBUG] Final output: %s\n", detals);</span> } -<span class="fc" id="L408"> return detals;</span> +<span class="fc" id="L413"> return detals;</span> } private static String readMultiLine(String lead, Scanner src, ReplOpts ropts, List<ReplError> errs, String typ, IntHolder lno) { -<span class="fc" id="L413"> String tmp = lead;</span> +<span class="fc" id="L418"> String tmp = lead;</span> -<span class="pc bpc" id="L415" title="3 of 4 branches missed."> if (ropts.isTrace && tmp.endsWith("\\")) </span> -<span class="nc" id="L416"> ropts.errStream.printf("\t[TRACE] Starting multi-line parse for %s '%s'\n", typ, tmp);</span> +<span class="pc bpc" id="L420" title="3 of 4 branches missed."> if (ropts.isTrace && tmp.endsWith("\\")) </span> +<span class="nc" id="L421"> ropts.errStream.printf("\t[TRACE] Starting multi-line parse for %s '%s'\n", typ, tmp);</span> -<span class="fc" id="L418"> boolean didMulti = tmp.endsWith("\\");</span> -<span class="fc bfc" id="L419" title="All 2 branches covered."> while (tmp.endsWith("\\")) {</span> -<span class="fc" id="L420"> boolean incNL = tmp.endsWith("|\\");</span> +<span class="fc" id="L423"> boolean didMulti = tmp.endsWith("\\");</span> +<span class="fc bfc" id="L424" title="All 2 branches covered."> while (tmp.endsWith("\\")) {</span> +<span class="fc" id="L425"> boolean incNL = tmp.endsWith("|\\");</span> -<span class="pc bpc" id="L422" title="1 of 2 branches missed."> if (!src.hasNextLine()) break;</span> +<span class="pc bpc" id="L427" title="1 of 2 branches missed."> if (!src.hasNextLine()) break;</span> -<span class="fc" id="L424"> String nxt = src.nextLine().trim();</span> -<span class="fc" id="L425"> lno.incr();</span> +<span class="fc" id="L429"> String nxt = src.nextLine().trim();</span> +<span class="fc" id="L430"> lno.incr();</span> -<span class="fc bfc" id="L427" title="All 2 branches covered."> if (nxt.startsWith("#")) continue;</span> +<span class="fc bfc" id="L432" title="All 2 branches covered."> if (nxt.startsWith("#")) continue;</span> -<span class="fc bfc" id="L429" title="All 2 branches covered."> String nlStr = incNL ? "\n" : "";</span> +<span class="fc bfc" id="L434" title="All 2 branches covered."> String nlStr = incNL ? "\n" : "";</span> -<span class="pc bpc" id="L431" title="1 of 2 branches missed."> if (tmp.endsWith("\\")) {</span> -<span class="fc bfc" id="L432" title="All 2 branches covered."> if (incNL) {</span> -<span class="fc" id="L433"> tmp = tmp.substring(0, tmp.length() - 2);</span> +<span class="pc bpc" id="L436" title="1 of 2 branches missed."> if (tmp.endsWith("\\")) {</span> +<span class="fc bfc" id="L437" title="All 2 branches covered."> if (incNL) {</span> +<span class="fc" id="L438"> tmp = tmp.substring(0, tmp.length() - 2);</span> } else { -<span class="fc" id="L435"> tmp = tmp.substring(0, tmp.length() - 1);</span> +<span class="fc" id="L440"> tmp = tmp.substring(0, tmp.length() - 1);</span> } } -<span class="fc" id="L439"> tmp = String.format("%s%s%s", tmp, nlStr, nxt);</span> -<span class="fc" id="L440"> }</span> +<span class="fc" id="L444"> tmp = String.format("%s%s%s", tmp, nlStr, nxt);</span> +<span class="fc" id="L445"> }</span> -<span class="pc bpc" id="L442" title="3 of 4 branches missed."> if (ropts.isTrace && didMulti)</span> -<span class="nc" id="L443"> ropts.errStream.printf("\t[TRACE] Finished multi-line parse for %s:\n%s\n.\n",</span> +<span class="pc bpc" id="L447" title="3 of 4 branches missed."> if (ropts.isTrace && didMulti)</span> +<span class="nc" id="L448"> ropts.errStream.printf("\t[TRACE] Finished multi-line parse for %s:\n%s\n.\n",</span> typ, tmp); -<span class="fc" id="L446"> return tmp;</span> +<span class="fc" id="L451"> return tmp;</span> } @Override public String apply(String inp) { -<span class="fc" id="L451"> return inp.replaceAll(find, replace);</span> +<span class="fc bfc" id="L456" title="All 2 branches covered."> if (guard != null) {</span> +<span class="fc bfc" id="L457" title="All 2 branches covered."> if (!inp.matches(guard)) return inp;</span> + } + +<span class="fc" id="L460"> return inp.replaceAll(find, replace);</span> } @Override public String toString() { -<span class="fc" id="L456"> String nameStr = "";</span> +<span class="fc" id="L465"> String nameStr = "";</span> -<span class="pc bpc" id="L458" title="1 of 2 branches missed."> if (!find.equals(name)) nameStr = String.format("(%s)", name);</span> +<span class="pc bpc" id="L467" title="1 of 2 branches missed."> if (!find.equals(name)) nameStr = String.format("(%s)", name);</span> -<span class="fc" id="L460"> return String.format("%ss/(%s)/(%s)/p(%d)", nameStr, find, replace, priority);</span> +<span class="fc" id="L469"> return String.format("%ss/(%s)/(%s)/p(%d)", nameStr, find, replace, priority);</span> } @Override public int compareTo(ReplPair rp) { -<span class="fc bfc" id="L465" title="All 2 branches covered."> if (this.priority == rp.priority) return this.lno - rp.lno;</span> +<span class="fc bfc" id="L474" title="All 2 branches covered."> if (this.priority == rp.priority) return this.lno - rp.lno;</span> -<span class="fc" id="L467"> return rp.priority - this.priority;</span> +<span class="fc" id="L476"> return rp.priority - this.priority;</span> } @Override public int hashCode() { -<span class="nc" id="L472"> final int prime = 31;</span> -<span class="nc" id="L473"> int result = 1;</span> -<span class="nc bnc" id="L474" title="All 2 branches missed."> result = prime * result + ((find == null) ? 0 : find.hashCode());</span> -<span class="nc bnc" id="L475" title="All 2 branches missed."> result = prime * result + ((name == null) ? 0 : name.hashCode());</span> -<span class="nc" id="L476"> result = prime * result + priority;</span> -<span class="nc bnc" id="L477" title="All 2 branches missed."> result = prime * result + ((replace == null) ? 0 : replace.hashCode());</span> -<span class="nc" id="L478"> result = prime * result + stage;</span> -<span class="nc" id="L479"> return result;</span> +<span class="nc" id="L481"> final int prime = 31;</span> +<span class="nc" id="L482"> int result = 1;</span> +<span class="nc bnc" id="L483" title="All 2 branches missed."> result = prime * result + ((find == null) ? 0 : find.hashCode());</span> +<span class="nc bnc" id="L484" title="All 2 branches missed."> result = prime * result + ((name == null) ? 0 : name.hashCode());</span> +<span class="nc" id="L485"> result = prime * result + priority;</span> +<span class="nc bnc" id="L486" title="All 2 branches missed."> result = prime * result + ((replace == null) ? 0 : replace.hashCode());</span> +<span class="nc" id="L487"> result = prime * result + stage;</span> +<span class="nc" id="L488"> return result;</span> } @Override public boolean equals(Object obj) { -<span class="pc bpc" id="L484" title="1 of 2 branches missed."> if (this == obj) return true;</span> -<span class="pc bpc" id="L485" title="1 of 2 branches missed."> if (obj == null) return false;</span> -<span class="pc bpc" id="L486" title="1 of 2 branches missed."> if (getClass() != obj.getClass()) return false;</span> -<span class="fc" id="L487"> ReplPair other = (ReplPair) obj;</span> -<span class="pc bpc" id="L488" title="1 of 2 branches missed."> if (find == null) {</span> -<span class="nc bnc" id="L489" title="All 2 branches missed."> if (other.find != null) return false;</span> -<span class="pc bpc" id="L490" title="1 of 2 branches missed."> } else if (!find.equals(other.find)) return false;</span> -<span class="pc bpc" id="L491" title="1 of 2 branches missed."> if (name == null) {</span> -<span class="nc bnc" id="L492" title="All 2 branches missed."> if (other.name != null) return false;</span> -<span class="pc bpc" id="L493" title="1 of 2 branches missed."> } else if (!name.equals(other.name)) return false;</span> -<span class="pc bpc" id="L494" title="1 of 2 branches missed."> if (priority != other.priority) return false;</span> -<span class="pc bpc" id="L495" title="1 of 2 branches missed."> if (replace == null) {</span> -<span class="nc bnc" id="L496" title="All 2 branches missed."> if (other.replace != null) return false;</span> -<span class="pc bpc" id="L497" title="1 of 2 branches missed."> } else if (!replace.equals(other.replace)) return false;</span> -<span class="pc bpc" id="L498" title="1 of 2 branches missed."> if (stage != other.stage) return false;</span> -<span class="fc" id="L499"> return true;</span> +<span class="pc bpc" id="L493" title="1 of 2 branches missed."> if (this == obj) return true;</span> +<span class="pc bpc" id="L494" title="1 of 2 branches missed."> if (obj == null) return false;</span> +<span class="pc bpc" id="L495" title="1 of 2 branches missed."> if (getClass() != obj.getClass()) return false;</span> +<span class="fc" id="L496"> ReplPair other = (ReplPair) obj;</span> +<span class="pc bpc" id="L497" title="1 of 2 branches missed."> if (find == null) {</span> +<span class="nc bnc" id="L498" title="All 2 branches missed."> if (other.find != null) return false;</span> +<span class="pc bpc" id="L499" title="1 of 2 branches missed."> } else if (!find.equals(other.find)) return false;</span> +<span class="pc bpc" id="L500" title="1 of 2 branches missed."> if (name == null) {</span> +<span class="nc bnc" id="L501" title="All 2 branches missed."> if (other.name != null) return false;</span> +<span class="pc bpc" id="L502" title="1 of 2 branches missed."> } else if (!name.equals(other.name)) return false;</span> +<span class="pc bpc" id="L503" title="1 of 2 branches missed."> if (priority != other.priority) return false;</span> +<span class="pc bpc" id="L504" title="1 of 2 branches missed."> if (replace == null) {</span> +<span class="nc bnc" id="L505" title="All 2 branches missed."> if (other.replace != null) return false;</span> +<span class="pc bpc" id="L506" title="1 of 2 branches missed."> } else if (!replace.equals(other.replace)) return false;</span> +<span class="pc bpc" id="L507" title="1 of 2 branches missed."> if (stage != other.stage) return false;</span> +<span class="fc" id="L508"> return true;</span> } private static String readName(String nam, Scanner scn, List<ReplError> errs, ReplPair rp, ReplOpts ropts, IntHolder lno, IntHolder pno) { -<span class="fc" id="L504"> ControlledString cs = getControls(nam, errs, ropts, lno, pno, "name");</span> +<span class="fc" id="L513"> ControlledString cs = getControls(nam, errs, ropts, lno, pno, "name");</span> -<span class="fc" id="L506"> boolean isMulti = ropts.defMulti;</span> +<span class="fc" id="L515"> boolean isMulti = ropts.defMulti;</span> -<span class="fc" id="L508"> String name = cs.strang;</span> +<span class="fc" id="L517"> String name = cs.strang;</span> -<span class="fc bfc" id="L510" title="All 2 branches covered."> if (cs.hasControls()) {</span> -<span class="fc bfc" id="L511" title="All 2 branches covered."> for (Control cont : cs.controls) {</span> -<span class="pc bpc" id="L512" title="6 of 10 branches missed."> switch (cont.name) {</span> +<span class="fc bfc" id="L519" title="All 2 branches covered."> if (cs.hasControls()) {</span> +<span class="fc bfc" id="L520" title="All 2 branches covered."> for (Control cont : cs.controls) {</span> +<span class="pc bpc" id="L521" title="6 of 11 branches missed."> switch (cont.name) {</span> case "NAME": case "N": -<span class="nc bnc" id="L515" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L516"> String errMsg = String.format("One name argument was expected (got %d)",</span> -<span class="nc" id="L517"> cont.count());</span> +<span class="nc bnc" id="L524" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L525"> String errMsg = String.format("One name argument was expected (got %d)",</span> +<span class="nc" id="L526"> cont.count());</span> -<span class="nc" id="L519"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L520"> } else {</span> -<span class="nc" id="L521"> rp.name = cont.get(0);</span> +<span class="nc" id="L528"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L529"> } else {</span> +<span class="nc" id="L530"> rp.name = cont.get(0);</span> } -<span class="nc" id="L523"> break;</span> +<span class="nc" id="L532"> break;</span> + case "GUARD": + case "G": +<span class="pc bpc" id="L535" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L536"> String errMsg = String.format("One guard argument was expected (got %d)",</span> +<span class="nc" id="L537"> cont.count());</span> + +<span class="nc" id="L539"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L540"> } else {</span> +<span class="fc" id="L541"> String pat = cont.get(0);</span> + + try { +<span class="fc" id="L544"> Pattern.compile(pat);</span> +<span class="nc" id="L545"> } catch (PatternSyntaxException psex) {</span> +<span class="nc" id="L546"> String errMsg = String.format("Guard argument '%s' is not a valid regex (%s)",</span> +<span class="nc" id="L547"> pat, psex.getMessage());</span> + +<span class="nc" id="L549"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="fc" id="L550"> }</span> + +<span class="fc" id="L552"> rp.guard = cont.get(0);</span> + } +<span class="fc" id="L554"> break;</span> case "PRIORITY": case "PRIOR": case "P": try { -<span class="pc bpc" id="L528" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L529"> String errMsg = String.format("One priority argument was expected (got %d",</span> -<span class="nc" id="L530"> cont.count());</span> +<span class="pc bpc" id="L559" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L560"> String errMsg = String.format("One priority argument was expected (got %d",</span> +<span class="nc" id="L561"> cont.count());</span> -<span class="nc" id="L532"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L533"> } else {</span> -<span class="fc" id="L534"> rp.priority = Integer.parseInt(cont.get(0));</span> +<span class="nc" id="L563"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L564"> } else {</span> +<span class="fc" id="L565"> rp.priority = Integer.parseInt(cont.get(0));</span> } -<span class="nc" id="L536"> } catch (NumberFormatException nfex) {</span> -<span class="nc" id="L537"> String errMsg = String.format("'%s' is not a valid priority (must be an integer)",</span> -<span class="nc" id="L538"> cont.get(0));</span> +<span class="nc" id="L567"> } catch (NumberFormatException nfex) {</span> +<span class="nc" id="L568"> String errMsg = String.format("'%s' is not a valid priority (must be an integer)",</span> +<span class="nc" id="L569"> cont.get(0));</span> -<span class="nc" id="L540"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="fc" id="L541"> }</span> -<span class="nc" id="L542"> break;</span> +<span class="nc" id="L571"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="fc" id="L572"> }</span> +<span class="nc" id="L573"> break;</span> case "STAGE": case "S": try { -<span class="pc bpc" id="L546" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L547"> String errMsg = String.format("One stage argument was expected (got %d",</span> -<span class="nc" id="L548"> cont.count());</span> - -<span class="nc" id="L550"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L551"> } else {</span> -<span class="fc" id="L552"> int tmpStage = Integer.parseInt(cont.get(0));</span> -<span class="pc bpc" id="L553" title="1 of 2 branches missed."> if (tmpStage < 0) {</span> -<span class="nc" id="L554"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> -<span class="nc" id="L555"> cont.get(0));</span> -<span class="nc" id="L556"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> - -<span class="nc" id="L558"> break;</span> +<span class="pc bpc" id="L577" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L578"> String errMsg = String.format("One stage argument was expected (got %d",</span> +<span class="nc" id="L579"> cont.count());</span> + +<span class="nc" id="L581"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L582"> } else {</span> +<span class="fc" id="L583"> int tmpStage = Integer.parseInt(cont.get(0));</span> +<span class="pc bpc" id="L584" title="1 of 2 branches missed."> if (tmpStage < 0) {</span> +<span class="nc" id="L585"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> +<span class="nc" id="L586"> cont.get(0));</span> +<span class="nc" id="L587"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> + +<span class="nc" id="L589"> break;</span> } -<span class="fc" id="L560"> rp.stage = tmpStage;</span> +<span class="fc" id="L591"> rp.stage = tmpStage;</span> } -<span class="nc" id="L562"> } catch (NumberFormatException nfex) {</span> -<span class="nc" id="L563"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> -<span class="nc" id="L564"> cont.get(0));</span> +<span class="nc" id="L593"> } catch (NumberFormatException nfex) {</span> +<span class="nc" id="L594"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> +<span class="nc" id="L595"> cont.get(0));</span> -<span class="nc" id="L566"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="fc" id="L567"> }</span> -<span class="nc" id="L568"> break;</span> +<span class="nc" id="L597"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="fc" id="L598"> }</span> +<span class="nc" id="L599"> break;</span> case "MULTITRUE": case "MULTIT": case "MT": -<span class="nc" id="L572"> isMulti = true;</span> -<span class="nc" id="L573"> break;</span> +<span class="nc" id="L603"> isMulti = true;</span> +<span class="nc" id="L604"> break;</span> case "MULTIFALSE": case "MULTIF": case "MF": -<span class="nc" id="L577"> isMulti = false;</span> -<span class="nc" id="L578"> break;</span> +<span class="nc" id="L608"> isMulti = false;</span> +<span class="nc" id="L609"> break;</span> case "MULTI": case "M": -<span class="nc bnc" id="L581" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L582"> String errMsg = String.format("One multi-flag argument was expected (got %d",</span> -<span class="nc" id="L583"> cont.count());</span> +<span class="nc bnc" id="L612" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L613"> String errMsg = String.format("One multi-flag argument was expected (got %d",</span> +<span class="nc" id="L614"> cont.count());</span> -<span class="nc" id="L585"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L586"> } else {</span> -<span class="nc" id="L587"> isMulti = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc" id="L616"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L617"> } else {</span> +<span class="nc" id="L618"> isMulti = Boolean.parseBoolean(cont.get(0));</span> } -<span class="nc" id="L589"> break;</span> +<span class="nc" id="L620"> break;</span> case "INTERNAL": case "INT": case "I": -<span class="fc" id="L593"> rp.stat = StageStatus.INTERNAL;</span> -<span class="fc" id="L594"> break;</span> +<span class="fc" id="L624"> rp.stat = StageStatus.INTERNAL;</span> +<span class="fc" id="L625"> break;</span> case "EXTERNAL": case "EXT": case "E": -<span class="fc" id="L598"> rp.stat = StageStatus.EXTERNAL;</span> -<span class="fc" id="L599"> break;</span> +<span class="fc" id="L629"> rp.stat = StageStatus.EXTERNAL;</span> +<span class="fc" id="L630"> break;</span> case "BOTH": case "B": -<span class="nc" id="L602"> rp.stat = StageStatus.BOTH;</span> -<span class="nc" id="L603"> break;</span> +<span class="nc" id="L633"> rp.stat = StageStatus.BOTH;</span> +<span class="nc" id="L634"> break;</span> default: { -<span class="nc" id="L606"> String errMsg = String.format("Unknown control name '%s' for name '%s'",</span> +<span class="nc" id="L637"> String errMsg = String.format("Unknown control name '%s' for name '%s'",</span> cont.name, nam); -<span class="nc" id="L609"> ReplError erd = new ReplError(lno, pno, errMsg, nam);</span> +<span class="nc" id="L640"> ReplError erd = new ReplError(lno, pno, errMsg, nam);</span> -<span class="nc" id="L611"> errs.add(erd);</span> +<span class="nc" id="L642"> errs.add(erd);</span> } break; } } -<span class="fc" id="L617"> name = cs.strang;</span> +<span class="fc" id="L648"> name = cs.strang;</span> } // Multi-line name with a trailer -<span class="fc bfc" id="L621" title="All 2 branches covered."> if (isMulti) {</span> -<span class="fc" id="L622"> String tmp = readMultiLine(name, scn, ropts, errs, "name", lno);</span> -<span class="pc bpc" id="L623" title="1 of 2 branches missed."> if (tmp == null) return null;</span> -<span class="fc" id="L624"> name = tmp;</span> +<span class="fc bfc" id="L652" title="All 2 branches covered."> if (isMulti) {</span> +<span class="fc" id="L653"> String tmp = readMultiLine(name, scn, ropts, errs, "name", lno);</span> +<span class="pc bpc" id="L654" title="1 of 2 branches missed."> if (tmp == null) return null;</span> +<span class="fc" id="L655"> name = tmp;</span> } -<span class="fc" id="L627"> return name;</span> +<span class="fc" id="L658"> return name;</span> } private static void readGlobal(String nam, Scanner scn, List<ReplError> errs, ReplOpts ropts, IntHolder lno, IntHolder pno) { -<span class="fc" id="L632"> ControlledString cs = getControls(nam.substring(1), errs, ropts, lno, pno, "global");</span> +<span class="fc" id="L663"> ControlledString cs = getControls(nam.substring(1), errs, ropts, lno, pno, "global");</span> -<span class="fc bfc" id="L634" title="All 2 branches covered."> for (Control cont : cs.controls) {</span> -<span class="pc bpc" id="L635" title="13 of 18 branches missed."> switch (cont.name) {</span> +<span class="fc bfc" id="L665" title="All 2 branches covered."> for (Control cont : cs.controls) {</span> +<span class="pc bpc" id="L666" title="13 of 18 branches missed."> switch (cont.name) {</span> case "PRIORITY": case "PRIOR": case "P": try { -<span class="pc bpc" id="L640" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L641"> String errMsg = String.format("Must specify 1 priority (%d specified)",</span> -<span class="nc" id="L642"> cont.count());</span> - -<span class="nc" id="L644"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L645"> } else {</span> -<span class="fc" id="L646"> int tmp = Integer.parseInt(cont.get(0));</span> -<span class="fc" id="L647"> ropts.defPrior = tmp;</span> +<span class="pc bpc" id="L671" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L672"> String errMsg = String.format("Must specify 1 priority (%d specified)",</span> +<span class="nc" id="L673"> cont.count());</span> + +<span class="nc" id="L675"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L676"> } else {</span> +<span class="fc" id="L677"> int tmp = Integer.parseInt(cont.get(0));</span> +<span class="fc" id="L678"> ropts.defPrior = tmp;</span> } -<span class="nc" id="L649"> } catch (NumberFormatException nfex) {</span> -<span class="nc" id="L650"> String errMsg = String.format("'%s' is not a valid priority (must be an integer)",</span> -<span class="nc" id="L651"> cont.get(0));</span> +<span class="nc" id="L680"> } catch (NumberFormatException nfex) {</span> +<span class="nc" id="L681"> String errMsg = String.format("'%s' is not a valid priority (must be an integer)",</span> +<span class="nc" id="L682"> cont.get(0));</span> -<span class="nc" id="L653"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="fc" id="L654"> }</span> -<span class="nc" id="L655"> break;</span> +<span class="nc" id="L684"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="fc" id="L685"> }</span> +<span class="nc" id="L686"> break;</span> case "STAGE": case "S": try { -<span class="pc bpc" id="L659" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L660"> String errMsg = String.format("Must specify 1 stage (%d specified)",</span> -<span class="nc" id="L661"> cont.count());</span> +<span class="pc bpc" id="L690" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L691"> String errMsg = String.format("Must specify 1 stage (%d specified)",</span> +<span class="nc" id="L692"> cont.count());</span> -<span class="nc" id="L663"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L664"> } else {</span> -<span class="fc" id="L665"> int tmpStage = Integer.parseInt(cont.get(0));</span> +<span class="nc" id="L694"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L695"> } else {</span> +<span class="fc" id="L696"> int tmpStage = Integer.parseInt(cont.get(0));</span> -<span class="pc bpc" id="L667" title="1 of 2 branches missed."> if (tmpStage < 0) {</span> -<span class="nc" id="L668"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> -<span class="nc" id="L669"> cont.get(0));</span> +<span class="pc bpc" id="L698" title="1 of 2 branches missed."> if (tmpStage < 0) {</span> +<span class="nc" id="L699"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> +<span class="nc" id="L700"> cont.get(0));</span> -<span class="nc" id="L671"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L672"> break;</span> +<span class="nc" id="L702"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L703"> break;</span> } -<span class="fc" id="L675"> ropts.defStage = tmpStage;</span> +<span class="fc" id="L706"> ropts.defStage = tmpStage;</span> } -<span class="nc" id="L677"> } catch (NumberFormatException nfex) {</span> -<span class="nc" id="L678"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> -<span class="nc" id="L679"> cont.get(0));</span> +<span class="nc" id="L708"> } catch (NumberFormatException nfex) {</span> +<span class="nc" id="L709"> String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)",</span> +<span class="nc" id="L710"> cont.get(0));</span> -<span class="nc" id="L681"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="fc" id="L682"> }</span> -<span class="nc" id="L683"> break;</span> +<span class="nc" id="L712"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="fc" id="L713"> }</span> +<span class="nc" id="L714"> break;</span> case "MULTITRUE": case "MULTIT": case "MT": -<span class="nc" id="L687"> ropts.defMulti = true;</span> -<span class="nc" id="L688"> break;</span> +<span class="nc" id="L718"> ropts.defMulti = true;</span> +<span class="nc" id="L719"> break;</span> case "MULTIFALSE": case "MULTIF": case "MF": -<span class="nc" id="L692"> ropts.defMulti = false;</span> -<span class="nc" id="L693"> break;</span> +<span class="nc" id="L723"> ropts.defMulti = false;</span> +<span class="nc" id="L724"> break;</span> case "MULTI": case "M": -<span class="pc bpc" id="L696" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L697"> String errMsg = String.format("Must specify 1 multi-flag (%d specified)",</span> -<span class="nc" id="L698"> cont.count());</span> +<span class="pc bpc" id="L727" title="1 of 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L728"> String errMsg = String.format("Must specify 1 multi-flag (%d specified)",</span> +<span class="nc" id="L729"> cont.count());</span> -<span class="nc" id="L700"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L701"> } else {</span> -<span class="fc" id="L702"> ropts.defMulti = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc" id="L731"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L732"> } else {</span> +<span class="fc" id="L733"> ropts.defMulti = Boolean.parseBoolean(cont.get(0));</span> } -<span class="fc" id="L704"> break;</span> +<span class="fc" id="L735"> break;</span> case "INTERNAL": case "INT": case "I": -<span class="nc" id="L708"> ropts.defStatus = StageStatus.INTERNAL;</span> -<span class="nc" id="L709"> break;</span> +<span class="nc" id="L739"> ropts.defStatus = StageStatus.INTERNAL;</span> +<span class="nc" id="L740"> break;</span> case "EXTERNAL": case "EXT": case "E": -<span class="nc" id="L713"> ropts.defStatus = StageStatus.EXTERNAL;</span> -<span class="nc" id="L714"> break;</span> +<span class="nc" id="L744"> ropts.defStatus = StageStatus.EXTERNAL;</span> +<span class="nc" id="L745"> break;</span> case "BOTH": case "B": -<span class="nc" id="L717"> ropts.defStatus = StageStatus.BOTH;</span> -<span class="nc" id="L718"> break;</span> +<span class="nc" id="L748"> ropts.defStatus = StageStatus.BOTH;</span> +<span class="nc" id="L749"> break;</span> case "DEBUGTRUE": case "DEBUGT": case "DT": -<span class="nc" id="L722"> ropts.isDebug = true;</span> -<span class="nc" id="L723"> break;</span> +<span class="nc" id="L753"> ropts.isDebug = true;</span> +<span class="nc" id="L754"> break;</span> case "DEBUGFALSE": case "DEBUGF": case "DF": -<span class="fc" id="L727"> ropts.isDebug = false;</span> -<span class="fc" id="L728"> break;</span> +<span class="fc" id="L758"> ropts.isDebug = false;</span> +<span class="fc" id="L759"> break;</span> case "DEBUG": case "D": -<span class="nc bnc" id="L731" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L732"> String errMsg = String.format("Must specify 1 debug flag (%d specified)",</span> -<span class="nc" id="L733"> cont.count());</span> +<span class="nc bnc" id="L762" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L763"> String errMsg = String.format("Must specify 1 debug flag (%d specified)",</span> +<span class="nc" id="L764"> cont.count());</span> -<span class="nc" id="L735"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L736"> } else {</span> -<span class="nc" id="L737"> ropts.isDebug = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc" id="L766"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L767"> } else {</span> +<span class="nc" id="L768"> ropts.isDebug = Boolean.parseBoolean(cont.get(0));</span> } -<span class="nc" id="L739"> break;</span> +<span class="nc" id="L770"> break;</span> case "TRACETRUE": case "TRACET": case "TT": -<span class="nc" id="L743"> ropts.isTrace = true;</span> -<span class="nc" id="L744"> break;</span> +<span class="nc" id="L774"> ropts.isTrace = true;</span> +<span class="nc" id="L775"> break;</span> case "TRACEFALSE": case "TRACEF": case "TF": -<span class="fc" id="L748"> ropts.isTrace = false;</span> -<span class="fc" id="L749"> break;</span> +<span class="fc" id="L779"> ropts.isTrace = false;</span> +<span class="fc" id="L780"> break;</span> case "TRACE": case "T": -<span class="nc bnc" id="L752" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L753"> String errMsg = String.format("Must specify 1 trace flag (%d specified)",</span> -<span class="nc" id="L754"> cont.count());</span> +<span class="nc bnc" id="L783" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L784"> String errMsg = String.format("Must specify 1 trace flag (%d specified)",</span> +<span class="nc" id="L785"> cont.count());</span> -<span class="nc" id="L756"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L757"> } else {</span> -<span class="nc" id="L758"> ropts.isTrace = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc" id="L787"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L788"> } else {</span> +<span class="nc" id="L789"> ropts.isTrace = Boolean.parseBoolean(cont.get(0));</span> } -<span class="nc" id="L760"> break;</span> +<span class="nc" id="L791"> break;</span> case "PERFTRUE": case "PERFT": case "PRFT": -<span class="nc" id="L764"> ropts.isPerf = true;</span> -<span class="nc" id="L765"> break;</span> +<span class="nc" id="L795"> ropts.isPerf = true;</span> +<span class="nc" id="L796"> break;</span> case "PERFFALSE": case "PERFF": case "PRFF": -<span class="nc" id="L769"> ropts.isPerf = false;</span> -<span class="nc" id="L770"> break;</span> +<span class="nc" id="L800"> ropts.isPerf = false;</span> +<span class="nc" id="L801"> break;</span> case "PERF": case "PRF": -<span class="nc bnc" id="L773" title="All 2 branches missed."> if (cont.count() != 1) {</span> -<span class="nc" id="L774"> String errMsg = String.format("Must specify 1 perf. flag (%d specified)",</span> -<span class="nc" id="L775"> cont.count());</span> +<span class="nc bnc" id="L804" title="All 2 branches missed."> if (cont.count() != 1) {</span> +<span class="nc" id="L805"> String errMsg = String.format("Must specify 1 perf. flag (%d specified)",</span> +<span class="nc" id="L806"> cont.count());</span> -<span class="nc" id="L777"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> -<span class="nc" id="L778"> } else {</span> -<span class="nc" id="L779"> ropts.isPerf = Boolean.parseBoolean(cont.get(0));</span> +<span class="nc" id="L808"> errs.add(new ReplError(lno, pno, errMsg, nam));</span> +<span class="nc" id="L809"> } else {</span> +<span class="nc" id="L810"> ropts.isPerf = Boolean.parseBoolean(cont.get(0));</span> } -<span class="nc" id="L781"> break;</span> +<span class="nc" id="L812"> break;</span> default: { -<span class="nc" id="L784"> String msg = String.format("Invalid global control name '%s'", cont.name);</span> -<span class="nc" id="L785"> ReplError err = new ReplError(lno, pno, msg, nam);</span> -<span class="nc" id="L786"> errs.add(err);</span> +<span class="nc" id="L815"> String msg = String.format("Invalid global control name '%s'", cont.name);</span> +<span class="nc" id="L816"> ReplError err = new ReplError(lno, pno, msg, nam);</span> +<span class="nc" id="L817"> errs.add(err);</span> } break; } -<span class="pc bpc" id="L791" title="1 of 2 branches missed."> if (ropts.isTrace) </span> -<span class="nc" id="L792"> ropts.errStream.printf("\t[TRACE] Processed global control '%s'\n", cont);</span> +<span class="pc bpc" id="L822" title="1 of 2 branches missed."> if (ropts.isTrace) </span> +<span class="nc" id="L823"> ropts.errStream.printf("\t[TRACE] Processed global control '%s'\n", cont);</span> } -<span class="fc" id="L795"> return;</span> +<span class="fc" id="L826"> return;</span> } private static ControlledString getControls(String lne, List<ReplError> errs, - ReplOpts ropts, IntHolder lno, IntHolder pno, String type) - { + ReplOpts ropts, IntHolder lno, IntHolder pno, String type) { try { -<span class="fc" id="L802"> return ControlledString.parse(lne, new ParseStrings("//", ";", "/", "|"));</span> -<span class="nc" id="L803"> } catch (IllegalArgumentException iaex) {</span> -<span class="nc" id="L804"> String msg = "Did not find control terminator (//) in %s where it should be";</span> -<span class="nc" id="L805"> msg = String.format(msg, type);</span> +<span class="fc" id="L832"> return ControlledString.parse(lne, new ParseStrings("//", ";", "/", "|"));</span> +<span class="nc" id="L833"> } catch (IllegalArgumentException iaex) {</span> +<span class="nc" id="L834"> String msg = "Did not find control terminator (//) in %s where it should be";</span> +<span class="nc" id="L835"> msg = String.format(msg, type);</span> -<span class="nc" id="L807"> ReplError re = new ReplError(lno, pno, msg, lne);</span> -<span class="nc" id="L808"> errs.add(re);</span> +<span class="nc" id="L837"> ReplError re = new ReplError(lno, pno, msg, lne);</span> +<span class="nc" id="L838"> errs.add(re);</span> -<span class="nc" id="L810"> return null;</span> +<span class="nc" id="L840"> return null;</span> } } } |
