Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package com.stevesoft.pat

File OrMark.java

 

Coverage histogram

../../../img/srcFileCovDistChart9.png
12% of files have more coverage

Code metrics

10
25
5
1
73
57
10
0.4
5
5
2

Classes

Class Line # Actions
OrMark 13 25 10
0.990%
 

Contributing tests

This file is covered by 29 tests. .

Source view

1    //
2    // This software is now distributed according to
3    // the Lesser Gnu Public License. Please see
4    // http://www.gnu.org/copyleft/lesser.txt for
5    // the details.
6    // -- Happy Computing!
7    //
8    package com.stevesoft.pat;
9   
10    import java.util.Hashtable;
11   
12    /** Implements the parenthesis pattern subelement. */
 
13    class OrMark extends Or
14    {
15    SubMark sm = new SubMark();
16   
17    int id;
18   
 
19  3471 toggle OrMark(int i)
20    {
21  3471 sm.om = this;
22  3471 id = i;
23    }
24   
 
25  1274 toggle String leftForm()
26    {
27  1274 return "(";
28    }
29   
 
30  43850 toggle public Pattern getNext()
31    {
32  43850 return sm;
33    }
34   
 
35  19785 toggle public int matchInternal(int pos, Pthings pt)
36    {
37  19785 sm.next = super.getNext();
38  19785 if (pt.marks == null)
39    {
40  5729 int n2 = 2 * pt.nMarks + 2;
41  5729 pt.marks = new int[n2];
42  43131 for (int i = 0; i < n2; i++)
43    {
44  37402 pt.marks[i] = -1;
45    }
46    }
47  19785 pt.marks[id] = pos;
48  19785 int ret = super.matchInternal(pos, pt);
49  19785 if (ret < 0)
50    {
51  7481 pt.marks[id] = -1;
52    }
53  12304 else if (pt.marks[id] > pt.marks[id + pt.nMarks])
54    {
55  0 int swap = pt.marks[id];
56  0 pt.marks[id] = pt.marks[id + pt.nMarks] + 1;
57  0 pt.marks[id + pt.nMarks] = swap + 1;
58    }
59  19785 return ret;
60    }
61   
 
62  1610 toggle public Pattern clone1(Hashtable h)
63    {
64  1610 OrMark om = new OrMark(id);
65  1610 h.put(om, om);
66  1610 h.put(this, om);
67  3220 for (int i = 0; i < v.size(); i++)
68    {
69  1610 om.v.addElement(((Pattern) v.elementAt(i)).clone(h));
70    }
71  1610 return om;
72    }
73    };