├── .project ├── CCM Command Line Tool ├── CCMCL │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── res │ │ ├── JavaPlot.jar │ │ ├── choco-solver-2.1.5-with-sources.jar │ │ ├── choco-solver-2.1.5.jar │ │ ├── jcommon-1.0.23.jar │ │ └── jfreechart-1.0.19.jar │ └── src │ │ ├── ConstraintChocoParser.jj │ │ ├── ConstraintParser.jj │ │ ├── Images │ │ ├── ._nistLogo.jpg │ │ ├── ._print.gif │ │ ├── nistLogo.jpg │ │ └── print.gif │ │ └── com │ │ └── nist │ │ └── ccmcl │ │ ├── CSolver.java │ │ ├── ChocoVariable.java │ │ ├── Constants.java │ │ ├── ConstraintChocoParser.java │ │ ├── ConstraintChocoParserConstants.java │ │ ├── ConstraintChocoParserTokenManager.java │ │ ├── ConstraintManager.java │ │ ├── ConstraintParser.java │ │ ├── ConstraintParserConstants.java │ │ ├── ConstraintParserTokenManager.java │ │ ├── Main.java │ │ ├── Parameter.java │ │ ├── ParseException.java │ │ ├── ReadOperation.java │ │ ├── ReadProgramOutputOperation.java │ │ ├── ReadStandardInputOperation.java │ │ ├── ReadTCPInputOperation.java │ │ ├── SimpleCharStream.java │ │ ├── TestData.java │ │ ├── Token.java │ │ ├── TokenMgrError.java │ │ ├── Tools.java │ │ ├── Tway.java │ │ ├── TypeInfo.java │ │ └── meConstraint.java ├── Combinatorial Coverage Measurement Command Line Tool - User Manual.pdf ├── Examples │ ├── Example1 │ │ ├── EXAMPLE1.txt │ │ └── command.txt │ ├── Example2 │ │ ├── apache.xml │ │ └── command.txt │ ├── Example3 │ │ ├── ACTSfile.txt │ │ └── command.txt │ ├── Example4 │ │ ├── command.txt │ │ └── input_test.csv │ ├── RealTime Example 1 │ │ ├── ACTSfile.txt │ │ ├── command.txt.txt │ │ └── generate_fast.jar │ ├── RealTime Example 2 │ │ ├── ACTSfile.txt │ │ ├── command.txt │ │ └── generate_fastest.jar │ └── RealTime Example 3 │ │ ├── apache.txt │ │ ├── apache_simulation.jar │ │ └── command.txt ├── README.md ├── ccmcl.jar └── demo.bat ├── CCM-GUI ├── CCM-bin.tar ├── CCM-src.tar └── readme.txt ├── CCM-bin.tar ├── CCM-src.tar ├── CCM17.jar ├── FaultID User Guide.pdf ├── Faultloc.exe ├── Images ├── ACTSfile.txt.png ├── ccmcl_graphs.png └── input_test.csv.png ├── Measuring the Combinatorial Coverage of Software in Real Time.pdf ├── README.md ├── SequenceCoveringArrays ├── newseq3.c ├── newseq4.c └── readme ├── _config.yml ├── pev-cli.jar ├── pev.jar ├── pev_guide_2.pdf └── t-way-fault-dist.png /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | combinatorial-testing-tools 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CCM Server 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/res/JavaPlot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/res/JavaPlot.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/res/choco-solver-2.1.5-with-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/res/choco-solver-2.1.5-with-sources.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/res/choco-solver-2.1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/res/choco-solver-2.1.5.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/res/jcommon-1.0.23.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/res/jcommon-1.0.23.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/res/jfreechart-1.0.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/res/jfreechart-1.0.19.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/ConstraintParser.jj: -------------------------------------------------------------------------------- 1 | options { 2 | static = false; 3 | } 4 | 5 | PARSER_BEGIN(ConstraintParser) 6 | 7 | 8 | import java.util.HashMap; 9 | import java.util.ArrayList; 10 | import java.io.StringReader; 11 | 12 | public class ConstraintParser { 13 | 14 | // store parameter values 15 | private HashMap params; 16 | 17 | // a list of parameters that appear in the constraint 18 | private ArrayList usedParams; 19 | 20 | public ConstraintParser (String constraint) { 21 | this(new StringReader (constraint)); 22 | params = new HashMap (); 23 | usedParams = new ArrayList (); 24 | } 25 | 26 | public ConstraintParser (String constraint,HashMap paramsMap) { 27 | this(new StringReader (constraint)); 28 | params = paramsMap; 29 | usedParams = new ArrayList (); 30 | } 31 | 32 | // add a param/value pair 33 | public void addParam (String pname, Object pvalue) { 34 | params.put(pname, pvalue); 35 | } 36 | 37 | // get the list of used parameters 38 | public ArrayList getUsedParamList () { 39 | return usedParams; 40 | } 41 | 42 | public Object lookup (String pname) { 43 | return params.get(pname); 44 | } 45 | 46 | public void parse () throws ParseException { 47 | Constraint (true); 48 | } 49 | 50 | public boolean evaluate () { 51 | boolean rval = true; 52 | try { 53 | rval = ((Boolean) Constraint (false)).booleanValue(); 54 | } 55 | catch (Exception ex) { 56 | System.out.println("Parser Exception: " + ex); 57 | rval = false; 58 | } 59 | 60 | return rval; 61 | } 62 | 63 | public static void main (String args[]) { 64 | ConstraintParser parser = new ConstraintParser (args[0]); 65 | //parser.addParam ("x", Boolean.TRUE); 66 | //parser.addParam ("y", new Integer(10)); 67 | //parser.addParam ("z", "test"); 68 | //System.out.println(parser.evaluate()); 69 | //System.out.println(parser.parse()); 70 | } 71 | } 72 | 73 | PARSER_END(ConstraintParser) 74 | 75 | SKIP: 76 | { 77 | " " 78 | | "\t" 79 | | "\n" 80 | | "\r" 81 | } 82 | 83 | TOKEN: 84 | { 85 | < INTEGER_LITERAL: ["0"-"9"] (["0"-"9"])* > 86 | | 87 | < STRING_LITERAL: 88 | "\"" 89 | (~["\"","\\","\n","\r"])* 90 | "\"" 91 | > 92 | | 93 | < TRUE: "true" | "TRUE" | "True" > 94 | | 95 | < FALSE: "false" | "FALSE" | "False" > 96 | | 97 | < IDENTIFIER: ( | )* > 98 | | 99 | < #LETTER: ["A"-"Z", "a"-"z", "_"] > 100 | | 101 | < #DIGIT: ["0"-"9"] > 102 | | 103 | < EQ : "=" | "==" > 104 | | 105 | < GT: ">" > 106 | | 107 | < LT: "<" > 108 | | 109 | < LE: "<=" > 110 | | 111 | < GE: ">=" > 112 | | 113 | < NE: "!=" > 114 | | 115 | < AND: "&&" > 116 | | 117 | < OR: "||" > 118 | | 119 | < NOT: "!" | "~"> 120 | | 121 | < IM: "=>" > 122 | | 123 | < PLUS: "+" > 124 | | 125 | < MINUS: "-" > 126 | | 127 | < MUL: "*" > 128 | | 129 | < DIV: "/" > 130 | | 131 | < MOD: "%" > 132 | | 133 | < OPENPAR: "(" > 134 | | 135 | < CLOSEPAR: ")" > 136 | } 137 | 138 | Object Constraint (boolean parse_only) : 139 | { 140 | Object rval; 141 | } 142 | { 143 | (rval = LogicalExpression (parse_only)) { 144 | if (parse_only) { 145 | TypeInfo rvalTI = (TypeInfo) rval; 146 | if (rvalTI.getType() != Constants.TYPE_BOOL) { 147 | throw new ParseException("Boolean expression expected:\n" + rvalTI.getText()); 148 | } 149 | } 150 | return rval; 151 | } 152 | } 153 | 154 | Object LogicalExpression (boolean parse_only) : 155 | { 156 | Object rval; 157 | } 158 | { 159 | (rval = ImplicativeExpression (parse_only)) { 160 | return rval; 161 | } 162 | } 163 | 164 | Object ImplicativeExpression (boolean parse_only) : 165 | { 166 | Token t = null; 167 | Object rval; 168 | Object temp; 169 | TypeInfo rvalTI = new TypeInfo(); 170 | TypeInfo tempTI = new TypeInfo(); 171 | } 172 | { 173 | (rval = OrExpression (parse_only)) 174 | ((t = ) (temp = OrExpression (parse_only)) { 175 | if(parse_only){ 176 | tempTI = (TypeInfo)temp; 177 | rvalTI = (TypeInfo)rval; 178 | 179 | TypeInfo rv = new TypeInfo(); 180 | rv.setType(Constants.TYPE_BOOL); 181 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 182 | 183 | if(rvalTI.getType() != Constants.TYPE_BOOL) { 184 | throw new ParseException("Boolean type expected: " + rvalTI.getText() 185 | + "\n" + " in expression: " + rv.getText()); 186 | } 187 | else if(tempTI.getType() != Constants.TYPE_BOOL) { 188 | throw new ParseException("Boolean type expected: " + tempTI.getText() 189 | + "\n" + " in expression: " + rv.getText()); 190 | } 191 | rval = rv; 192 | } else { 193 | rval = new Boolean ( 194 | !((Boolean) rval).booleanValue () 195 | || ((Boolean) temp).booleanValue ()); 196 | } 197 | } 198 | ) * 199 | { 200 | return rval; 201 | } 202 | } 203 | 204 | Object OrExpression (boolean parse_only) : 205 | { 206 | Token t = null; 207 | Object rval; 208 | Object temp; 209 | TypeInfo rvalTI = new TypeInfo(); 210 | TypeInfo tempTI = new TypeInfo(); 211 | } 212 | { 213 | (rval = AndExpression (parse_only)) 214 | ((t = ) (temp = AndExpression (parse_only)) { 215 | if(parse_only){ 216 | tempTI = (TypeInfo)temp; 217 | rvalTI = (TypeInfo)rval; 218 | 219 | TypeInfo rv = new TypeInfo(); 220 | rv.setType(Constants.TYPE_BOOL); 221 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 222 | if(rvalTI.getType() != Constants.TYPE_BOOL) { 223 | throw new ParseException("Boolean type expected: " + rvalTI.getText() 224 | + "\n" + " in expression: " + rv.getText()); 225 | } 226 | else if(tempTI.getType() != Constants.TYPE_BOOL) { 227 | throw new ParseException("Boolean type expected: " + tempTI.getText() 228 | + "\n" + " in expression: " + rv.getText()); 229 | } 230 | rval = rv; 231 | } else { 232 | rval = new Boolean ( 233 | ((Boolean) rval).booleanValue() 234 | || ((Boolean) temp).booleanValue()); 235 | } 236 | }) * 237 | { 238 | return rval; 239 | } 240 | } 241 | 242 | Object AndExpression (boolean parse_only) : 243 | { 244 | Token t = null; 245 | Object rval; 246 | Object temp; 247 | TypeInfo rvalTI = null; 248 | TypeInfo tempTI = null; 249 | } 250 | { 251 | (rval = RelationalExpression (parse_only)) 252 | ( (t = ) (temp = RelationalExpression (parse_only)) { 253 | if(parse_only){ 254 | tempTI = (TypeInfo)temp; 255 | rvalTI = (TypeInfo)rval; 256 | 257 | TypeInfo rv = new TypeInfo(); 258 | rv.setType(Constants.TYPE_BOOL); 259 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 260 | 261 | if(rvalTI.getType() != Constants.TYPE_BOOL) { 262 | throw new ParseException("Boolean type expected: " + rvalTI.getText() 263 | + "\n" + " in expression: " + rv.getText()); 264 | } 265 | else if(tempTI.getType() != Constants.TYPE_BOOL) { 266 | throw new ParseException("Boolean type expected: " + tempTI.getText() 267 | + "\n" + " in expression: " + rv.getText()); 268 | } 269 | rval = rv; 270 | } else { 271 | rval = new Boolean( 272 | ((Boolean) rval).booleanValue () 273 | && ((Boolean) temp).booleanValue ()); 274 | } 275 | } 276 | ) * 277 | { 278 | return rval; 279 | } 280 | } 281 | 282 | Object RelationalExpression (boolean parse_only) : 283 | { 284 | Token t = null; 285 | Object rval; 286 | Object temp; 287 | TypeInfo rvalTI = null; 288 | TypeInfo tempTI = null; 289 | } 290 | { 291 | (rval = AdditiveExpression (parse_only)) 292 | ( 293 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 294 | if(parse_only){ 295 | tempTI = (TypeInfo)temp; 296 | rvalTI = (TypeInfo)rval; 297 | 298 | TypeInfo rv = new TypeInfo(); 299 | rv.setType(Constants.TYPE_BOOL); 300 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 301 | 302 | if(rvalTI.getType() != Constants.TYPE_INT 303 | && rvalTI.getType () != Constants.TYPE_STRING) { 304 | throw new ParseException("Integer or String type expected: " + rvalTI.getText() 305 | + "\n" + " in expression: " + rv.getText()); 306 | } 307 | else if(tempTI.getType() != Constants.TYPE_INT 308 | && tempTI.getType() != Constants.TYPE_STRING) { 309 | throw new ParseException("Integer or String type expected: " + tempTI.getText() 310 | + "\n" + " in expression: " + rv.getText()); 311 | } 312 | else if (tempTI.getType () != rvalTI.getType ()) { 313 | throw new ParseException("Type mismatch: " + rvalTI.getText() 314 | + " " + t.image + " " + tempTI.getText()); 315 | } 316 | rval = rv; 317 | } else { 318 | if (temp instanceof Integer) { 319 | if(((Integer) rval).intValue() < ((Integer) temp).intValue ()) { 320 | rval = Boolean.TRUE; 321 | } 322 | else { 323 | rval = Boolean.FALSE; 324 | } 325 | } 326 | else if (temp instanceof String) { 327 | int tmp = ((String) rval).compareTo ((String) temp); 328 | if (tmp < 0) { 329 | rval = Boolean.TRUE; 330 | } 331 | else { 332 | rval = Boolean.FALSE; 333 | } 334 | } 335 | } 336 | } 337 | | 338 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 339 | if(parse_only){ 340 | tempTI = (TypeInfo)temp; 341 | rvalTI = (TypeInfo)rval; 342 | 343 | TypeInfo rv = new TypeInfo(); 344 | rv.setType(Constants.TYPE_BOOL); 345 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 346 | 347 | if(rvalTI.getType() != Constants.TYPE_INT 348 | && rvalTI.getType () != Constants.TYPE_STRING) { 349 | throw new ParseException("Integer or String type expected: " + rvalTI.getText() 350 | + "\n" + " in expression: " + rv.getText()); 351 | } 352 | else if(tempTI.getType() != Constants.TYPE_INT 353 | && tempTI.getType() != Constants.TYPE_STRING) { 354 | throw new ParseException("Integer or String type expected: " + tempTI.getText() 355 | + "\n" + " in expression: " + rv.getText()); 356 | } 357 | else if (tempTI.getType () != rvalTI.getType ()) { 358 | throw new ParseException("Type mismatch: " + rvalTI.getText() 359 | + " " + t.image + " " + tempTI.getText()); 360 | } 361 | rval = rv; 362 | } else { 363 | if (temp instanceof Integer) { 364 | if(((Integer) rval).intValue() > ((Integer) temp).intValue()) { 365 | rval = Boolean.TRUE; 366 | } else { 367 | rval = Boolean.FALSE; 368 | } 369 | } 370 | else if (temp instanceof String) { 371 | int tmp = ((String) rval).compareTo ((String) temp); 372 | if (tmp > 0) { 373 | rval = Boolean.TRUE; 374 | } 375 | else { 376 | rval = Boolean.FALSE; 377 | } 378 | } 379 | } 380 | } 381 | | 382 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 383 | if(parse_only){ 384 | tempTI = (TypeInfo)temp; 385 | rvalTI = (TypeInfo)rval; 386 | 387 | TypeInfo rv = new TypeInfo(); 388 | rv.setType(Constants.TYPE_BOOL); 389 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 390 | 391 | if(rvalTI.getType() != Constants.TYPE_INT 392 | && rvalTI.getType () != Constants.TYPE_STRING) { 393 | throw new ParseException("Integer or String type expected: " + rvalTI.getText() 394 | + "\n" + " in expression: " + rv.getText()); 395 | } 396 | else if(tempTI.getType() != Constants.TYPE_INT 397 | && tempTI.getType() != Constants.TYPE_STRING) { 398 | throw new ParseException("Integer or String type expected: " + tempTI.getText() 399 | + "\n" + " in expression: " + rv.getText()); 400 | } 401 | else if (tempTI.getType () != rvalTI.getType ()) { 402 | throw new ParseException("Type mismatch: " + rvalTI.getText() 403 | + " " + t.image + " " + tempTI.getText()); 404 | } 405 | rval = rv; 406 | } else { 407 | if (temp instanceof Integer) { 408 | if(((Integer) rval).intValue() <= ((Integer) temp).intValue()) { 409 | rval = Boolean.TRUE; 410 | } 411 | else { 412 | rval = Boolean.FALSE; 413 | } 414 | } 415 | else if (temp instanceof String) { 416 | int tmp = ((String) rval).compareTo ((String) temp); 417 | if (tmp <= 0) { 418 | rval = Boolean.TRUE; 419 | } 420 | else { 421 | rval = Boolean.FALSE; 422 | } 423 | } 424 | } 425 | } 426 | | 427 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 428 | if(parse_only){ 429 | tempTI = (TypeInfo)temp; 430 | rvalTI = (TypeInfo)rval; 431 | 432 | TypeInfo rv = new TypeInfo(); 433 | rv.setType(Constants.TYPE_BOOL); 434 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 435 | 436 | if(rvalTI.getType() != Constants.TYPE_INT 437 | && rvalTI.getType () != Constants.TYPE_STRING) { 438 | throw new ParseException("Integer or String type expected: " + rvalTI.getText() 439 | + "\n" + " in expression: " + rv.getText()); 440 | } 441 | else if(tempTI.getType() != Constants.TYPE_INT 442 | && tempTI.getType() != Constants.TYPE_STRING) { 443 | throw new ParseException("Integer or String type expected: " + tempTI.getText() 444 | + "\n" + " in expression: " + rv.getText()); 445 | } 446 | else if (tempTI.getType () != rvalTI.getType ()) { 447 | throw new ParseException("Type mismatch: " + rvalTI.getText() 448 | + " " + t.image + " " + tempTI.getText()); 449 | } 450 | rval = rv; 451 | } else { 452 | if (temp instanceof Integer) { 453 | if(((Integer) rval).intValue() >= ((Integer) temp).intValue()) { 454 | rval = Boolean.TRUE; 455 | } 456 | else { 457 | rval = Boolean.FALSE; 458 | } 459 | } 460 | else if (temp instanceof String) { 461 | int tmp = ((String) rval).compareTo ((String) temp); 462 | if (tmp >= 0) { 463 | rval = Boolean.TRUE; 464 | } 465 | else { 466 | rval = Boolean.FALSE; 467 | } 468 | } 469 | } 470 | } 471 | | 472 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 473 | if(parse_only){ 474 | tempTI = (TypeInfo)temp; 475 | rvalTI = (TypeInfo)rval; 476 | 477 | if(rvalTI.getType() != tempTI.getType()) { 478 | throw new ParseException ("Type mismatch: " 479 | + rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 480 | } else { 481 | TypeInfo ti = new TypeInfo(); 482 | ti.setType(Constants.TYPE_BOOL); 483 | ti.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 484 | rval = ti;; 485 | } 486 | } else { 487 | if (temp instanceof Integer) { 488 | if(((Integer) rval).intValue() == ((Integer) temp).intValue()) { 489 | rval = Boolean.TRUE; 490 | } 491 | else { 492 | rval = Boolean.FALSE; 493 | } 494 | } 495 | else if (temp instanceof String) { 496 | int tmp = ((String) rval).compareTo ((String) temp); 497 | if (tmp == 0) { 498 | rval = Boolean.TRUE; 499 | } 500 | else { 501 | rval = Boolean.FALSE; 502 | } 503 | } 504 | else if (temp instanceof Boolean) { 505 | if(((Boolean) rval).equals(temp)) { 506 | rval = Boolean.TRUE; 507 | } 508 | else { 509 | rval = Boolean.FALSE; 510 | } 511 | } 512 | } 513 | } 514 | | 515 | ( (t=) (temp = AdditiveExpression (parse_only)) ) { 516 | if(parse_only){ 517 | tempTI = (TypeInfo)temp; 518 | rvalTI = (TypeInfo)rval; 519 | 520 | TypeInfo ti = new TypeInfo(); 521 | ti.setType(Constants.TYPE_BOOL); 522 | ti.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 523 | 524 | if(rvalTI.getType() != tempTI.getType()) { 525 | throw new ParseException ("Type mismatch: " 526 | + rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 527 | } 528 | rval = ti;; 529 | } else { 530 | if (temp instanceof Integer) { 531 | if(((Integer) rval).intValue() != ((Integer) temp).intValue()) { 532 | rval = Boolean.TRUE; 533 | } 534 | else { 535 | rval = Boolean.FALSE; 536 | } 537 | } 538 | else if (temp instanceof String) { 539 | int tmp = ((String) rval).compareTo ((String) temp); 540 | if (tmp != 0) { 541 | rval = Boolean.TRUE; 542 | } 543 | else { 544 | rval = Boolean.FALSE; 545 | } 546 | } 547 | else if (temp instanceof Boolean) { 548 | if(!((Boolean) rval).equals(temp)) { 549 | rval = Boolean.TRUE; 550 | } 551 | else { 552 | rval = Boolean.FALSE; 553 | } 554 | } 555 | } 556 | } 557 | )* 558 | { 559 | return rval; 560 | } 561 | } 562 | 563 | Object AdditiveExpression (boolean parse_only) : 564 | { 565 | Token t = null; 566 | Object rval = null; 567 | Object temp; 568 | TypeInfo rvalTI = null; 569 | TypeInfo tempTI = null; 570 | } 571 | { 572 | (rval = MultiplicativeExpression (parse_only)) ( 573 | ( (t=) (temp = MultiplicativeExpression (parse_only)) ) { 574 | if(parse_only){ 575 | tempTI = (TypeInfo)temp; 576 | rvalTI = (TypeInfo)rval; 577 | 578 | TypeInfo rv = new TypeInfo(); 579 | rv.setType(Constants.TYPE_INT); 580 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 581 | 582 | if(rvalTI.getType() != Constants.TYPE_INT) { 583 | throw new ParseException("Integer type expected: " + rvalTI.getText() 584 | + "\n" + " in expression: " + rv.getText()); 585 | } 586 | else if(tempTI.getType() != Constants.TYPE_INT) { 587 | throw new ParseException("Integer type expected: " + tempTI.getText() 588 | + "\n" + " in expression: " + rv.getText()); 589 | } 590 | rval = rv; 591 | } else { 592 | rval = new Integer(((Integer) rval).intValue() + ((Integer) temp).intValue ()); 593 | } 594 | } 595 | | 596 | ( (t=) (temp = MultiplicativeExpression (parse_only)) ) { 597 | if(parse_only){ 598 | tempTI = (TypeInfo)temp; 599 | rvalTI = (TypeInfo)rval; 600 | 601 | TypeInfo rv = new TypeInfo(); 602 | rv.setType(Constants.TYPE_INT); 603 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 604 | 605 | if(rvalTI.getType() != Constants.TYPE_INT) { 606 | throw new ParseException("Integer type expected: " + rvalTI.getText() 607 | + "\n" + " in expression: " + rv.getText()); 608 | } 609 | else if(tempTI.getType() != Constants.TYPE_INT) { 610 | throw new ParseException("Integer type expected: " + tempTI.getText() 611 | + "\n" + " in expression: " + rv.getText()); 612 | } 613 | rval = rv; 614 | } else { 615 | rval = new Integer(((Integer) rval).intValue() - ((Integer) temp).intValue ()); 616 | } 617 | } 618 | )* 619 | { 620 | return rval; 621 | } 622 | } 623 | 624 | Object MultiplicativeExpression (boolean parse_only) : 625 | { 626 | Token t = null; 627 | Object rval = null; 628 | Object temp; 629 | TypeInfo rvalTI = null; 630 | TypeInfo tempTI = null; 631 | } 632 | { 633 | (rval = UnaryExpression (parse_only)) 634 | ( 635 | ((t=) (temp = UnaryExpression (parse_only))) { 636 | if(parse_only){ 637 | tempTI = (TypeInfo)temp; 638 | rvalTI = (TypeInfo)rval; 639 | 640 | TypeInfo rv = new TypeInfo(); 641 | rv.setType(Constants.TYPE_INT); 642 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 643 | 644 | if(rvalTI.getType() != Constants.TYPE_INT) { 645 | throw new ParseException("Integer type expected: " + rvalTI.getText() 646 | + "\n" + " in expression: " + rv.getText()); 647 | } 648 | else if(tempTI.getType() != Constants.TYPE_INT) { 649 | throw new ParseException("Integer type expected: " + tempTI.getText() 650 | + "\n" + " in expression: " + rv.getText()); 651 | } 652 | rval = rv; 653 | } else { 654 | rval = new Integer(((Integer) rval).intValue() * ((Integer) temp).intValue ()); 655 | } 656 | } 657 | | 658 | ((t=
) (temp = UnaryExpression (parse_only) )) { 659 | if(parse_only){ 660 | tempTI = (TypeInfo)temp; 661 | rvalTI = (TypeInfo)rval; 662 | 663 | TypeInfo rv = new TypeInfo(); 664 | rv.setType(Constants.TYPE_INT); 665 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 666 | 667 | if(rvalTI.getType() != Constants.TYPE_INT) { 668 | throw new ParseException("Integer type expected: " + rvalTI.getText() 669 | + "\n" + " in expression: " + rv.getText()); 670 | } 671 | else if(tempTI.getType() != Constants.TYPE_INT) { 672 | throw new ParseException("Integer type expected: " + tempTI.getText() 673 | + "\n" + " in expression: " + rv.getText()); 674 | } 675 | rval = rv; 676 | } else { 677 | rval = new Integer(((Integer) rval).intValue() / ((Integer) temp).intValue ()); 678 | } 679 | } 680 | | 681 | ((t=) (temp = UnaryExpression (parse_only) )) { 682 | if(parse_only){ 683 | tempTI = (TypeInfo)temp; 684 | rvalTI = (TypeInfo)rval; 685 | 686 | TypeInfo rv = new TypeInfo(); 687 | rv.setType(Constants.TYPE_INT); 688 | rv.setText(rvalTI.getText() + " " + t.image + " " + tempTI.getText()); 689 | 690 | if(rvalTI.getType() != Constants.TYPE_INT) { 691 | throw new ParseException("Integer type expected: " + rvalTI.getText() 692 | + "\n" + " in expression: " + rv.getText()); 693 | 694 | } 695 | else if(tempTI.getType() != Constants.TYPE_INT) { 696 | throw new ParseException("Integer type expected: " + tempTI.getText() 697 | + "\n" + " in expression: " + rv.getText()); 698 | } 699 | rval = rv; 700 | } else { 701 | rval = new Integer(((Integer) rval).intValue() % ((Integer) temp).intValue ()); 702 | } 703 | } 704 | )* 705 | { return rval; } 706 | } 707 | 708 | Object UnaryExpression (boolean parse_only) : 709 | { 710 | Token t = null; 711 | Token tt = null; 712 | Object temp; 713 | Object rval = null; 714 | } 715 | { 716 | ((t=) { 717 | if(parse_only) { 718 | TypeInfo rv = new TypeInfo(); 719 | rv.setType(Constants.TYPE_INT); 720 | rv.setText(t.image); 721 | rval = rv; 722 | } else { 723 | int val = Integer.parseInt (t.image); 724 | rval = new Integer (val); 725 | } 726 | } 727 | | 728 | (t=) { 729 | if(parse_only) { 730 | TypeInfo rv = new TypeInfo(); 731 | rv.setType(Constants.TYPE_STRING); 732 | rv.setText(t.image); 733 | rval = rv; 734 | } else { 735 | // strip the quotes 736 | rval = t.image.substring(1, t.image.length()-1).trim(); 737 | } 738 | } 739 | | 740 | (t=) { 741 | if(parse_only){ 742 | TypeInfo rv = new TypeInfo(); 743 | rv.setType(Constants.TYPE_BOOL); 744 | rv.setText(t.image); 745 | rval = rv; 746 | } else { 747 | rval = Boolean.TRUE; 748 | } 749 | } 750 | | 751 | (t=) { 752 | if(parse_only){ 753 | TypeInfo rv = new TypeInfo(); 754 | rv.setType(Constants.TYPE_BOOL); 755 | rv.setText(t.image); 756 | rval = rv; 757 | } else { 758 | rval = Boolean.FALSE; 759 | } 760 | } 761 | | 762 | (t=) { 763 | if(parse_only){ 764 | Parameter param = (Parameter) lookup(t.image); 765 | if (param == null) { 766 | throw new ParseException("Unrecognized parameter: " + t.image 767 | + "\nIf this is a param value (i.e., not a param name), it needs to be quoted."); 768 | } else { 769 | // TODO:Enum needs to be converted to string. 770 | TypeInfo rv = new TypeInfo(); 771 | rv.setType (param.getParamType ()); 772 | rv.setText (t.image); 773 | rval = rv; 774 | 775 | // add this valid parameter into usedParam list 776 | usedParams.add (param); 777 | } 778 | } else { 779 | // look up the value of a variable 780 | rval = lookup (t.image); 781 | if (rval == null) { 782 | throw new ParseException ("Unrecognized parameter: " + t.image 783 | + "\nIf this is a param value (i.e., not a param name), it needs to be quoted."); 784 | } 785 | } 786 | } 787 | | (t=) (temp = UnaryExpression (parse_only)) { 788 | if(parse_only) { 789 | TypeInfo ti = (TypeInfo) temp; 790 | if (ti.getType() != Constants.TYPE_BOOL) { 791 | throw new ParseException ("Boolean type expected: " + ti.getText() 792 | + "\n" + " in expression: " + t.image + " " + ti.getText()); 793 | } 794 | TypeInfo rv = new TypeInfo(); 795 | rv.setType(Constants.TYPE_BOOL); 796 | rv.setText(t.image + " " + ti.getText()); 797 | rval = rv; 798 | } else { 799 | rval = new Boolean( 800 | !((Boolean) temp).booleanValue () 801 | ); 802 | } 803 | } 804 | | (t=) (rval = LogicalExpression (parse_only)) (tt=) { 805 | if(parse_only) { 806 | TypeInfo rvalTI = (TypeInfo) rval; 807 | TypeInfo ti = new TypeInfo (); 808 | ti.setType (rvalTI.getType()); 809 | ti.setText (t.image + rvalTI.getText() + tt.image); 810 | rval = ti; 811 | } 812 | }) 813 | { 814 | return rval; 815 | } 816 | 817 | } 818 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/Images/._nistLogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/src/Images/._nistLogo.jpg -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/Images/._print.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/src/Images/._print.gif -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/Images/nistLogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/src/Images/nistLogo.jpg -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/Images/print.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/CCMCL/src/Images/print.gif -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/CSolver.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import choco.cp.model.CPModel; 4 | import choco.cp.solver.CPSolver; 5 | import choco.cp.solver.search.integer.valselector.RandomIntValSelector; 6 | import choco.kernel.model.variables.integer.IntegerVariable; 7 | import choco.kernel.solver.Configuration; 8 | import choco.kernel.solver.search.ISolutionPool; 9 | 10 | import javax.swing.*; 11 | import java.io.BufferedWriter; 12 | import java.io.File; 13 | import java.io.FileWriter; 14 | import java.io.IOException; 15 | import java.util.*; 16 | 17 | public class CSolver 18 | { 19 | 20 | 21 | ArrayList chocoVariables; 22 | ArrayList paraNames; 23 | List lp; 24 | List lc; 25 | CPModel m; 26 | ArrayList enumList; 27 | LinkedHashMap parameters; 28 | ISolutionPool solutions; 29 | String[][] solutionMa; 30 | 31 | int[][] resultIndex; 32 | String[][] resultmapped; 33 | String[] _infile; 34 | int _countRandomTests = 0; 35 | JFrame parentFrame = null; 36 | 37 | public CSolver() //constructor, initialize arrays for parameters and constraints 38 | { 39 | 40 | lp = new ArrayList(); 41 | lc = new ArrayList(); 42 | } 43 | 44 | //set list of parameters 45 | public void SetParameter(List l) 46 | { 47 | lp = l; 48 | } 49 | 50 | public int NoRandomTests() 51 | { 52 | return _countRandomTests; 53 | } 54 | 55 | //set list of constraints 56 | public void SetConstraints(List l) 57 | { 58 | lc = l; 59 | } 60 | 61 | public void setFrame(JFrame f) 62 | { 63 | parentFrame = f; 64 | } 65 | 66 | public String[] infile() 67 | { 68 | return _infile; 69 | } 70 | 71 | //get solution by indexes 72 | public int[][] getSolutionIndex() 73 | { 74 | return resultIndex; 75 | } 76 | 77 | //get solution mapped 78 | public String[][] getSolutionMapped() 79 | { 80 | return resultmapped; 81 | } 82 | 83 | 84 | private void CreateCombinationsVariables(List listParams) 85 | { 86 | java.util.LinkedHashMap rvalue = new LinkedHashMap(); 87 | LinkedHashSet strings = new LinkedHashSet(); 88 | parameters = new LinkedHashMap(); 89 | 90 | chocoVariables = new ArrayList(lp.size()); 91 | paraNames = new ArrayList(lp.size()); 92 | 93 | 94 | for (Parameter p : lp) 95 | { 96 | if (p.getType() == Parameter.PARAM_TYPE_ENUM)//get all enum values from each parameter in a single list 97 | { 98 | strings.addAll(p.getValues()); 99 | 100 | } 101 | parameters.put(p.getName(), p); //add all parameters 102 | 103 | } 104 | 105 | enumList = new ArrayList(strings); 106 | Collections.sort(enumList); 107 | 108 | 109 | //load parameters 110 | 111 | for (String[] parm : listParams) 112 | { 113 | 114 | Parameter p = (Parameter) parameters.get(parm[0]); 115 | 116 | rvalue.put(p.getName(), p); 117 | paraNames.add(p.getName());// create a list with parameters name 118 | 119 | ArrayList values = new ArrayList(); 120 | 121 | 122 | // add in the single arrayList, values, all the values from each parameter 123 | if (p.getType() == Parameter.PARAM_TYPE_INT)// for int type is the same value 124 | { 125 | if (!parm[1].equals("")) 126 | { 127 | values.add(Integer.parseInt(parm[1])); 128 | } else 129 | { 130 | for (String v : p.getValues()) 131 | { 132 | values.add(new java.lang.Integer(v)); 133 | } 134 | 135 | } 136 | 137 | if (!values.isEmpty()) 138 | { 139 | chocoVariables.add(new ChocoVariable(p, values)); 140 | } 141 | } else if (p.getType() == Parameter.PARAM_TYPE_BOOL) // for bool type, true=1 and false=0 142 | { 143 | if (!parm[1].equals("")) 144 | { 145 | if (parm[1].toLowerCase().equals("true")) 146 | { 147 | values.add(new java.lang.Integer(1)); 148 | } else 149 | { 150 | values.add(new java.lang.Integer(0)); 151 | } 152 | } else 153 | { 154 | values.add(new java.lang.Integer(1)); 155 | values.add(new java.lang.Integer(0)); 156 | 157 | } 158 | if (!values.isEmpty()) 159 | { 160 | chocoVariables.add(new ChocoVariable(p, values)); 161 | } 162 | } else if (p.getType() 163 | == 164 | Parameter.PARAM_TYPE_ENUM) //for enum type is the index from the general list of enum values created above 165 | { 166 | if (!parm[1].equals("")) 167 | { 168 | values.add(enumList.indexOf(parm[1])); 169 | } else 170 | { 171 | for (String v : p.getValues()) 172 | { 173 | values.add(new java.lang.Integer(enumList.indexOf(v))); 174 | } 175 | } 176 | if (!values.isEmpty()) 177 | { 178 | chocoVariables.add( 179 | new ChocoVariable( 180 | p, values 181 | ) 182 | );//add to the chocoVariable list all parameters with their values 183 | } 184 | } 185 | } 186 | 187 | 188 | //add all variables to the choco model 189 | for (ChocoVariable c : chocoVariables) 190 | { 191 | m.addVariable(c.getVar()); 192 | 193 | } 194 | 195 | } 196 | 197 | //create variables for choco model with parameters 198 | public void CreateVariables() 199 | { 200 | 201 | java.util.LinkedHashMap rvalue = new LinkedHashMap(); 202 | LinkedHashSet strings = new LinkedHashSet(); 203 | parameters = new LinkedHashMap(); 204 | 205 | chocoVariables = new ArrayList(lp.size()); 206 | paraNames = new ArrayList(lp.size()); 207 | 208 | 209 | for (Parameter p : lp) 210 | { 211 | 212 | if (p.getType() == Parameter.PARAM_TYPE_ENUM)//get all enum values from each parameter in a single list 213 | { 214 | strings.addAll(p.getValues()); 215 | 216 | } 217 | parameters.put(p.getName(), p); //add all parameters 218 | 219 | } 220 | 221 | 222 | enumList = new ArrayList(strings); 223 | Collections.sort(enumList); 224 | 225 | //load parameters 226 | for (Parameter p : lp) 227 | { 228 | 229 | rvalue.put(p.getName(), p); 230 | paraNames.add(p.getName());// create a list with parameters name 231 | 232 | ArrayList values = new ArrayList(); 233 | 234 | // add in the single arrayList, values, all the values from each parameter 235 | if (p.getType() == Parameter.PARAM_TYPE_INT)// for int type is the same value 236 | { 237 | 238 | 239 | for (String v : p.getValues()) 240 | { 241 | values.add(new java.lang.Integer(v.trim())); 242 | } 243 | 244 | chocoVariables.add(new ChocoVariable(p, values)); 245 | } else if (p.getType() == Parameter.PARAM_TYPE_BOOL) // for bool type, true=1 and false=0 246 | { 247 | values.add(new java.lang.Integer(1)); 248 | values.add(new java.lang.Integer(0)); 249 | chocoVariables.add(new ChocoVariable(p, values)); 250 | } else if (p.getType() 251 | == 252 | Parameter.PARAM_TYPE_ENUM) //for enum type is the index from the general list of enum values created above 253 | { 254 | 255 | 256 | for (String v : p.getValues()) 257 | { 258 | values.add(new java.lang.Integer(enumList.indexOf(v))); 259 | } 260 | 261 | 262 | chocoVariables.add( 263 | new ChocoVariable( 264 | p, values 265 | ) 266 | );//add to the chocoVariable list all parameters with their values 267 | } 268 | } 269 | 270 | 271 | //add all variables to the choco model 272 | for (ChocoVariable c : chocoVariables) 273 | { 274 | m.addVariable(c.getVar()); 275 | 276 | } 277 | 278 | } 279 | 280 | 281 | //create constraints for random tests 282 | public void CreateConstraintsForRandomTests() 283 | { 284 | //CONSTRAINT 285 | java.util.ArrayList p = new java.util.ArrayList(); 286 | java.util.ArrayList stringConstList = new ArrayList(); 287 | 288 | for (meConstraint i : lc) 289 | { 290 | stringConstList.add(i.get_cons()); //add all constraints to single ArrayList 291 | 292 | 293 | java.util.LinkedHashSet varInUse; 294 | 295 | varInUse = new java.util.LinkedHashSet(); 296 | 297 | choco.kernel.model.constraints.Constraint c = null; 298 | 299 | //create parser object 300 | ConstraintChocoParser parser = new ConstraintChocoParser( 301 | i.get_cons(), parameters, new Constants( 302 | enumList, 303 | varInUse, 304 | chocoVariables 305 | ) 306 | ); 307 | varInUse.clear(); 308 | try 309 | { 310 | //change constraint to valid format constraint for choco 311 | c = parser.parse(); 312 | 313 | } 314 | catch (ParseException e) 315 | { 316 | //throw e; 317 | } 318 | if (c == null) 319 | { 320 | 321 | 322 | throw new Error(); 323 | 324 | } 325 | 326 | m.addConstraint(c); //add constraint to model 327 | } 328 | } 329 | 330 | //create choco constraints for invalid combinations 331 | 332 | public void CreateConstraints(meConstraint cons) 333 | { 334 | //CONSTRAINT 335 | java.util.ArrayList p = new java.util.ArrayList(); 336 | java.util.ArrayList stringConstList = new ArrayList(); 337 | 338 | //for (meConstraint i : lc) 339 | //{ 340 | // stringConstList.add(i.get_cons()); //add all constraints to single ArrayList 341 | 342 | 343 | java.util.LinkedHashSet varInUse; 344 | 345 | varInUse = new java.util.LinkedHashSet(); 346 | 347 | choco.kernel.model.constraints.Constraint c = null; 348 | 349 | //create parser object 350 | ConstraintChocoParser parser = new ConstraintChocoParser( 351 | cons.get_cons(), parameters, new Constants( 352 | enumList, 353 | varInUse, 354 | chocoVariables 355 | ) 356 | ); 357 | varInUse.clear(); 358 | try 359 | { 360 | //change constraint to valid format constraint for choco 361 | c = parser.parse(); 362 | //obtain all the invalid combinations -> not constraints 363 | // c = choco.Choco.not(c); 364 | } 365 | catch (ParseException e) 366 | { 367 | //throw e; 368 | } 369 | if (c == null) 370 | { 371 | 372 | 373 | throw new Error(); 374 | 375 | } 376 | 377 | m.addConstraint(c); //add constraint to model 378 | 379 | //} 380 | 381 | } 382 | 383 | 384 | public void SolverRandomTests(int NoSolutions, BufferedWriter bw) 385 | { 386 | try 387 | { 388 | ArrayList> solution = new ArrayList>(); 389 | String paramnames = ""; 390 | for (int i = 0; i < Main.parameters.size(); i++) 391 | { 392 | paramnames += Main.parameters.get(i).getName() + ","; 393 | } 394 | paramnames = paramnames.substring(0, paramnames.lastIndexOf(",")); 395 | bw.write(paramnames); 396 | bw.newLine(); 397 | m = new CPModel(); 398 | 399 | CreateVariables();//crate variable for the model 400 | 401 | CreateConstraintsForRandomTests(); //create chco constraint 402 | 403 | CPSolver s = new CPSolver(); //create object solver 404 | 405 | s.read(m); //read model (contains variables and constraints) 406 | s.getConfiguration().putInt(Configuration.SOLUTION_POOL_CAPACITY, 1); 407 | s.setValIntSelector(new RandomIntValSelector()); 408 | s.setRandomSelectors(); 409 | 410 | int rootworld = s.getEnvironment().getWorldIndex(); 411 | s.worldPush(); 412 | 413 | s.solve(); 414 | int count = 0; 415 | 416 | ISolutionPool pool = s.getSearchStrategy().getSolutionPool(); 417 | 418 | 419 | ArrayList t = new ArrayList(); 420 | int value; 421 | 422 | IntegerVariable var; 423 | 424 | 425 | String line = ""; 426 | Object[] x; 427 | 428 | _infile = new String[NoSolutions]; 429 | 430 | 431 | // for (Solution sol:pool.asList()) 432 | //{ 433 | // t.clear(); 434 | 435 | do 436 | { 437 | // s.worldPopUntil(rootworld); // restore the original state, where domains were as declared (not yet instantiated) 438 | //s.worldPush(); // backup the current state of the solver, to allow other solution restoration 439 | //s.restoreSolution(sol); // restore the solution 440 | 441 | count = 0; 442 | while (count < parameters.size()) 443 | { 444 | var = m.getIntVar(count++); 445 | value = s.getVar(var).getVal(); 446 | line = line + value + ","; 447 | } 448 | 449 | while (line.endsWith(",")) 450 | { 451 | line = line.substring(0, line.length() - 1); 452 | } 453 | x = line.split(","); 454 | Parameter p; 455 | line = ""; 456 | 457 | for (int j = 0; j < x.length; j++) 458 | { 459 | p = lp.get(j); 460 | if (p.getType() == Parameter.PARAM_TYPE_ENUM) 461 | { 462 | line = line + enumList.get(Integer.parseInt((String) x[j])).toString() + ","; 463 | } 464 | 465 | if (p.getType() == Parameter.PARAM_TYPE_BOOL) 466 | { 467 | line = line 468 | + (x[j].equals("0") ? Boolean.toString(false).toUpperCase() : Boolean.toString(true) 469 | .toUpperCase()) 470 | + ","; 471 | } 472 | 473 | if (p.getType() == Parameter.PARAM_TYPE_INT) 474 | { 475 | line = line + x[j] + ","; 476 | } 477 | 478 | } 479 | 480 | 481 | while (line.endsWith(",")) 482 | { 483 | line = line.substring(0, line.length() - 1); 484 | } 485 | _infile[_countRandomTests++] = line; 486 | 487 | try 488 | { 489 | bw.write(line); 490 | bw.newLine(); 491 | line = ""; 492 | } 493 | catch (Exception ex) 494 | { 495 | } 496 | 497 | } 498 | while (s.nextSolution() && _countRandomTests < NoSolutions); 499 | 500 | 501 | try 502 | { 503 | bw.close(); 504 | } 505 | catch (IOException e) 506 | { 507 | 508 | e.printStackTrace(); 509 | } 510 | 511 | } 512 | catch (Exception ex) 513 | { 514 | if (ex.getMessage().equals("")) 515 | { 516 | JOptionPane.showMessageDialog(parentFrame, "Error getting random test!!"); 517 | } else 518 | { 519 | JOptionPane.showMessageDialog(parentFrame, ex.getMessage()); 520 | } 521 | } 522 | } 523 | 524 | 525 | public boolean Solver(JFrame screen, JProgressBar pb) 526 | { 527 | try 528 | { 529 | ArrayList> solution = new ArrayList>(); 530 | 531 | 532 | //for each constraints get its solutions 533 | // for (meConstraint mc : lc) 534 | //{ 535 | 536 | 537 | m = new CPModel(); 538 | CreateVariables();//crate variable for the model 539 | 540 | // CreateConstraints(lc.indexOf(mc)); //create chco constraint 541 | // CreateConstraints(); 542 | 543 | CPSolver s = new CPSolver(); //create object solver 544 | m.setDefaultExpressionDecomposition(true); 545 | s.read(m); //read model (contains variables and constraints) 546 | s.getConfiguration().putInt(Configuration.SOLUTION_POOL_CAPACITY, Integer.MAX_VALUE); 547 | 548 | 549 | IntegerVariable var; 550 | Iterator variables = m.getIntVarIterator(); 551 | 552 | 553 | s.solveAll(); //solve model 554 | // int rootworld = s.getEnvironment().getWorldIndex(); 555 | // s.worldPush(); 556 | 557 | 558 | // s.solveAll(); 559 | // ISolutionPool pool = s.getSearchStrategy().getSolutionPool(); 560 | // 561 | if (!s.isFeasible()) 562 | { 563 | JOptionPane.showMessageDialog(screen, "Constraints don't have a feasible solution!!"); 564 | return false; 565 | } 566 | 567 | // pb.setIndeterminate(false); 568 | // pb.setStringPainted(true); 569 | // pb.setValue(0); 570 | // pb.setMaximum(s.getNbSolutions()); 571 | 572 | File fileInvalid = new File("C:\\Users\\ind1\\Documents\\mendoza\\My Documents\\tmpInvalid.txt"); 573 | FileWriter fwInvalid = new FileWriter(fileInvalid); 574 | BufferedWriter bwInvalid = new BufferedWriter(fwInvalid); 575 | 576 | Parameter p = null; 577 | //get first solution 578 | 579 | ArrayList t = new ArrayList(); 580 | // StringBuilder line = null; 581 | String line; 582 | 583 | int value; 584 | String valueMap; 585 | 586 | 587 | do 588 | { 589 | 590 | 591 | line = "";//new StringBuilder(); 592 | t.clear(); 593 | variables = m.getIntVarIterator(); 594 | 595 | 596 | while (variables.hasNext()) 597 | { 598 | var = variables.next(); 599 | value = s.getVar(var).getVal(); 600 | valueMap = ""; 601 | t.add(value); 602 | 603 | 604 | p = lp.get(t.size() - 1); 605 | if (p.getType() == Parameter.PARAM_TYPE_ENUM) 606 | { 607 | valueMap = enumList.get(value).toString(); 608 | } 609 | 610 | if (p.getType() == Parameter.PARAM_TYPE_BOOL) 611 | { 612 | valueMap = value == 0 ? Boolean.toString(false).toUpperCase() : Boolean.toString(true) 613 | .toUpperCase(); 614 | } 615 | 616 | if (p.getType() == Parameter.PARAM_TYPE_INT) 617 | { 618 | valueMap = Integer.toString(value); 619 | } 620 | 621 | //if (line.length() > 0) line.append(", "); 622 | //line.append(valueMap).append(","); 623 | line = line + valueMap + ","; 624 | 625 | 626 | } 627 | 628 | 629 | bwInvalid.write(line); 630 | bwInvalid.newLine(); 631 | bwInvalid.flush(); 632 | 633 | variables = null; 634 | 635 | } 636 | while (s.nextSolution().booleanValue()); 637 | 638 | 639 | bwInvalid.close(); 640 | 641 | 642 | /* 643 | while (variables.hasNext()) 644 | { 645 | var = (IntegerVariable)variables.next(); 646 | value = s.getVar(var).getVal(); 647 | 648 | 649 | t.add(value); 650 | 651 | 652 | 653 | p = lp.get(t.size()-1); 654 | if (p.getType() == Parameter.PARAM_TYPE_ENUM) 655 | valueMap = enumList.get((int) value).toString(); 656 | 657 | if (p.getType() == Parameter.PARAM_TYPE_BOOL) 658 | valueMap = (int) value==0 ? Boolean.toString(false).toUpperCase() : Boolean.toString(true).toUpperCase(); 659 | 660 | if (p.getType() == Parameter.PARAM_TYPE_INT) 661 | valueMap = Integer.toString((int) value); 662 | 663 | 664 | 665 | 666 | 667 | line=line + valueMap + ","; 668 | } 669 | 670 | bwInvalid.write(line); 671 | bwInvalid.newLine(); 672 | //bwInvalid.flush(); 673 | 674 | // solution.add(t); 675 | 676 | //get all solutions 677 | while (s.nextSolution().booleanValue() ) 678 | { 679 | //variables = m.getIntVarIterator(); 680 | var = null; 681 | t = new ArrayList(); 682 | line=""; 683 | p=null; 684 | 685 | while (variables.hasNext()) 686 | { 687 | var = (IntegerVariable)variables.next(); 688 | value = s.getVar(var).getVal(); 689 | t.add(value); 690 | 691 | 692 | 693 | p = lp.get(t.size()-1); 694 | if (p.getType() == Parameter.PARAM_TYPE_ENUM) 695 | valueMap = enumList.get((int) value).toString(); 696 | 697 | if (p.getType() == Parameter.PARAM_TYPE_BOOL) 698 | valueMap = (int) value==0 ? Boolean.toString(false).toUpperCase() : Boolean.toString(true).toUpperCase(); 699 | 700 | if (p.getType() == Parameter.PARAM_TYPE_INT) 701 | valueMap = Integer.toString((int) value); 702 | 703 | 704 | 705 | line=line + valueMap + ","; 706 | } 707 | 708 | 709 | bwInvalid.write(line); 710 | bwInvalid.newLine(); 711 | // bwInvalid.flush(); 712 | 713 | // solution.add(t); 714 | 715 | 716 | 717 | if (s.isFeasible()==null || s.isFeasible()==Boolean.FALSE) 718 | break; 719 | } 720 | 721 | bwInvalid.close(); 722 | // if (!solution.contains(t)) 723 | 724 | 725 | 726 | 727 | /* IntegerVariable var = null; 728 | int value; 729 | 730 | 731 | 732 | for (Solution sol:pool.asList()) 733 | { 734 | ArrayList t = new ArrayList(); 735 | Iterator variables =m.getIntVarIterator(); 736 | 737 | s.worldPopUntil(rootworld); // restore the original state, where domains were as declared (not yet instantiated) 738 | s.worldPush(); // backup the current state of the solver, to allow other solution restoration 739 | s.restoreSolution(sol); // restore the solution 740 | 741 | 742 | 743 | int count=0; 744 | while (count0) 763 | resultmapped = new String[solution.size()][]; 764 | 765 | //get mapped solution 766 | for (List l : solution) 767 | { 768 | x = l.toArray(); 769 | 770 | resultmapped[i] = new String[x.length]; 771 | 772 | 773 | for (int j = 0; j < x.length; j++) 774 | { 775 | p = lp.get(j); 776 | if (p.getType() == Parameter.PARAM_TYPE_ENUM) 777 | resultmapped[i][j] = enumList.get((int) x[j]).toString(); 778 | 779 | if (p.getType() == Parameter.PARAM_TYPE_BOOL) 780 | resultmapped[i][j] = (int) x[j]==0 ? Boolean.toString(false).toUpperCase() : Boolean.toString(true).toUpperCase(); 781 | 782 | if (p.getType() == Parameter.PARAM_TYPE_INT) 783 | resultmapped[i][j] = Integer.toString((int) x[j]); 784 | 785 | } 786 | i++; 787 | 788 | }*/ 789 | 790 | return true; 791 | } 792 | catch (Exception ex) 793 | { 794 | System.out.println(ex.getMessage()); 795 | return false; 796 | 797 | } 798 | } 799 | 800 | public boolean EvaluateCombination(String[][] Parm_Value) 801 | { 802 | 803 | 804 | CPSolver s; 805 | List listparams = new ArrayList(); 806 | 807 | for (meConstraint c : lc) 808 | { 809 | m = new CPModel(); 810 | listparams.clear(); 811 | 812 | for (String[] o : Parm_Value) 813 | { 814 | listparams.add(o); 815 | } 816 | 817 | for (String name : c.get_params()) 818 | { 819 | boolean fnd = false; 820 | 821 | for (String[] a : listparams) 822 | { 823 | 824 | if (a[0].trim().equals(name.trim())) 825 | { 826 | fnd = true; 827 | break; 828 | } 829 | } 830 | if (!fnd) 831 | { 832 | String[] o = new String[2]; 833 | o[0] = name; 834 | o[1] = ""; 835 | listparams.add(o); 836 | } 837 | } 838 | 839 | 840 | CreateCombinationsVariables(listparams);//crate variable for the model 841 | CreateConstraints(c); 842 | 843 | s = new CPSolver(); //create object solver 844 | m.setDefaultExpressionDecomposition(false); 845 | s.read(m); //read model (contains variables and constraints) 846 | s.getConfiguration().putInt(Configuration.SOLUTION_POOL_CAPACITY, Integer.MAX_VALUE); 847 | s.solveAll(); //solve model 848 | 849 | if (!s.isFeasible()) 850 | { 851 | return false; 852 | } 853 | m = null; 854 | s = null; 855 | } 856 | 857 | return true; 858 | } 859 | 860 | } 861 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ChocoVariable.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | 4 | import choco.Choco; 5 | import choco.kernel.model.variables.integer.IntegerVariable; 6 | import choco.kernel.solver.variables.integer.IntDomain; 7 | 8 | import java.util.ArrayList; 9 | 10 | 11 | public class ChocoVariable 12 | { 13 | 14 | 15 | String name; 16 | IntegerVariable var; //used for choco 17 | Parameter param; //related parameter 18 | ArrayList values; //domain from parameter 19 | 20 | private IntDomain newDomain; //reduced domain 21 | private int groupID; //constraint group 22 | private int[] countSolved; 23 | 24 | public ChocoVariable(Parameter par, ArrayList val) 25 | { 26 | param = par; 27 | name = par.getName(); 28 | values = new ArrayList(val); 29 | var = Choco.makeIntVar(par.getName(), values); 30 | groupID = -1; 31 | countSolved = new int[val.size()]; 32 | } 33 | 34 | 35 | public String getName() 36 | { 37 | return name; 38 | } 39 | 40 | public void setName(String name) 41 | { 42 | this.name = name; 43 | } 44 | 45 | public IntegerVariable getVar() 46 | { 47 | return var; 48 | } 49 | 50 | 51 | public void setVar(IntegerVariable var) 52 | { 53 | this.var = var; 54 | } 55 | 56 | 57 | public int getGroupID() 58 | { 59 | return groupID; 60 | } 61 | 62 | public void setGroupID(int groupID) 63 | { 64 | this.groupID = groupID; 65 | } 66 | 67 | 68 | public boolean checkValue(int v) 69 | { 70 | if (newDomain == null) 71 | { 72 | if (values.contains(v)) 73 | { 74 | return true; 75 | } 76 | else 77 | { 78 | return false; 79 | } 80 | } 81 | return newDomain.contains(v); 82 | } 83 | 84 | public void setNewDomain(IntDomain newDomain) 85 | { 86 | this.newDomain = newDomain; 87 | } 88 | 89 | public int getValue(int idx) 90 | { 91 | countSolved[idx]++; 92 | return values.get(idx); 93 | } 94 | 95 | public int getIdx(int value) 96 | { 97 | return values.indexOf(value); 98 | } 99 | 100 | public void printInfo() 101 | { 102 | System.out.print(name + ": \t"); 103 | for (int i : countSolved) 104 | { 105 | if (i > 0) 106 | { 107 | System.out.print(i + "\t"); 108 | } 109 | } 110 | System.out.println("\t" + newDomain); 111 | 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/Constants.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import choco.Choco; 4 | import choco.kernel.model.constraints.Constraint; 5 | import choco.kernel.model.variables.integer.IntegerExpressionVariable; 6 | import choco.kernel.model.variables.integer.IntegerVariable; 7 | 8 | import java.util.ArrayList; 9 | import java.util.LinkedHashSet; 10 | 11 | 12 | public class Constants 13 | { 14 | 15 | public static final int TYPE_INVALID = -1; 16 | public static final int TYPE_INT = 0; 17 | public static final int TYPE_STRING = 1; 18 | public static final int TYPE_BOOL = 2; 19 | public static final String INT_TYPE = "int"; 20 | public static final String INTEGER_TYPE = "integer"; 21 | public static final String BOOL_TYPE = "bool"; 22 | public static final String BOOLEAN_TYPE = "boolean"; 23 | public static final String ENUM_TYPE = "enum"; 24 | static String SYSTEM_MODIFIED = "Modify"; 25 | static String PARAM_TYPE_BOOL = "@bool@"; 26 | static String PARAM_TYPE_INT = "@int@"; 27 | static String PARAM_TYPE_ENUM = "@enum@"; 28 | static String FALSE = "false"; 29 | static String TRUE = "true"; 30 | static String DIGIT = "\\d*"; 31 | static String LETTER = "\\w*"; 32 | static String MOD = "%"; 33 | static String DIV = "/"; 34 | static String MUL = "*"; 35 | static String MINUS = "-"; 36 | static String PLUS = "+"; 37 | static String NOT_str = "NOT"; 38 | static String NOT = "!"; 39 | static String OR_str = "OR"; 40 | static String OR = "||"; 41 | static String OR_regex = "|"; 42 | static String NE = "-"; 43 | static String GE = ">="; 44 | static String GE_STR = "GE"; 45 | static String LE = "<="; 46 | static String LE_STR = "LE"; 47 | static String LT = "<"; 48 | static String GT = ">"; 49 | static String EQ2 = "=="; 50 | static String EQ = "="; 51 | static String AND = "&&"; 52 | static String AND_str = "AND"; 53 | static String AND_regex = "&"; 54 | static String IMP = "=>"; 55 | static String IMP_STR = "\"=>\""; 56 | static String NEQ = "!="; 57 | static String NEQ_STR = "NEQ"; 58 | static String OPEN_PAR = "("; 59 | static String CLOSE_PAR = ")"; 60 | static String BSLASH = "\\"; 61 | static String SPACE = " "; 62 | static String DOUBLEQUOTE = "\""; 63 | ArrayList enumList; 64 | ArrayList chocoVariables; 65 | private LinkedHashSet varInUse; 66 | 67 | public Constants(ArrayList al_e, LinkedHashSet lh_vu, ArrayList al_cv) 68 | { 69 | enumList = al_e; 70 | chocoVariables = al_cv; 71 | varInUse = lh_vu; 72 | } 73 | 74 | public IntegerExpressionVariable mk_enum(String s) 75 | { 76 | int v = enumList.indexOf(s); 77 | if (v < 0) 78 | { 79 | enumList.add(s); 80 | System.out.println("Warning: No domain contains this enum value - " + s); 81 | return mk_int(enumList.size() - 1); 82 | } 83 | return mk_int(v); 84 | } 85 | 86 | public IntegerVariable mk_int(int v) 87 | { 88 | 89 | return Choco.constant(v); 90 | } 91 | 92 | public IntegerVariable mk_int_var(String s) 93 | { 94 | for (ChocoVariable cv : chocoVariables) 95 | { 96 | if (s.equals(cv.getName())) 97 | { 98 | 99 | varInUse.add(cv.getVar()); 100 | return cv.getVar(); 101 | } 102 | } 103 | return null; 104 | } 105 | 106 | public IntegerVariable mk_bool_var(String s) 107 | { 108 | return mk_int_var(s); 109 | } 110 | 111 | public IntegerVariable mk_true() 112 | { 113 | 114 | return Choco.constant(1); 115 | } 116 | 117 | public IntegerVariable mk_false() 118 | { 119 | 120 | return Choco.constant(0); 121 | } 122 | 123 | public IntegerExpressionVariable mk_op(String op, IntegerExpressionVariable oprnd1, IntegerExpressionVariable oprnd2) 124 | { 125 | 126 | if (op.equalsIgnoreCase(PLUS)) 127 | { 128 | return Choco.plus(oprnd1, oprnd2); 129 | } 130 | if (op.equalsIgnoreCase(MUL)) 131 | { 132 | return Choco.mult(oprnd1, oprnd2); 133 | } 134 | if (op.equalsIgnoreCase(MINUS)) 135 | { 136 | return Choco.minus(oprnd1, oprnd2); 137 | } 138 | if (op.equalsIgnoreCase(DIV)) 139 | { 140 | return Choco.div(oprnd1, oprnd2); 141 | } 142 | if (op.equalsIgnoreCase(MOD)) 143 | { 144 | return Choco.mod(oprnd1, oprnd2); 145 | } 146 | return null; 147 | } 148 | 149 | public Constraint mk_comp(String op, IntegerExpressionVariable oprnd1, IntegerExpressionVariable oprnd2) 150 | { 151 | 152 | if (op.equalsIgnoreCase(EQ) || op.equalsIgnoreCase(EQ2)) 153 | { 154 | return Choco.eq(oprnd1, oprnd2); 155 | } 156 | if (op.equalsIgnoreCase(NEQ)) 157 | { 158 | return Choco.neq(oprnd1, oprnd2); 159 | } 160 | if (op.equalsIgnoreCase(LT)) 161 | { 162 | return Choco.lt(oprnd1, oprnd2); 163 | } 164 | if (op.equalsIgnoreCase(LE)) 165 | { 166 | return Choco.leq(oprnd1, oprnd2); 167 | } 168 | if (op.equalsIgnoreCase(GT)) 169 | { 170 | return Choco.gt(oprnd1, oprnd2); 171 | } 172 | if (op.equalsIgnoreCase(GE)) 173 | { 174 | return Choco.geq(oprnd1, oprnd2); 175 | } 176 | return null; 177 | } 178 | 179 | public Constraint mk_cst(String op, Constraint oprnd1, Constraint oprnd2) 180 | { 181 | 182 | if (op.equalsIgnoreCase(NOT)) 183 | { 184 | return Choco.not(oprnd2); 185 | } 186 | if (op.equalsIgnoreCase(AND)) 187 | { 188 | return Choco.and(oprnd1, oprnd2); 189 | } 190 | if (op.equalsIgnoreCase(OR)) 191 | { 192 | return Choco.or(oprnd1, oprnd2); 193 | } 194 | if (op.equalsIgnoreCase(IMP)) 195 | { 196 | return Choco.implies(oprnd1, oprnd2); 197 | } 198 | return null; 199 | } 200 | } -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ConstraintChocoParserConstants.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. ConstraintChocoParserConstants.java */ 3 | 4 | /** 5 | * Token literal values and constants. 6 | * Generated by org.javacc.parser.OtherFilesGen#start() 7 | */ 8 | public interface ConstraintChocoParserConstants { 9 | 10 | /** End of File. */ 11 | int EOF = 0; 12 | /** RegularExpression Id. */ 13 | int INTEGER_LITERAL = 5; 14 | /** RegularExpression Id. */ 15 | int STRING_LITERAL = 6; 16 | /** RegularExpression Id. */ 17 | int TRUE = 7; 18 | /** RegularExpression Id. */ 19 | int FALSE = 8; 20 | /** RegularExpression Id. */ 21 | int IDENTIFIER = 9; 22 | /** RegularExpression Id. */ 23 | int LETTER = 10; 24 | /** RegularExpression Id. */ 25 | int DIGIT = 11; 26 | /** RegularExpression Id. */ 27 | int EQ = 12; 28 | /** RegularExpression Id. */ 29 | int GT = 13; 30 | /** RegularExpression Id. */ 31 | int LT = 14; 32 | /** RegularExpression Id. */ 33 | int LE = 15; 34 | /** RegularExpression Id. */ 35 | int GE = 16; 36 | /** RegularExpression Id. */ 37 | int NE = 17; 38 | /** RegularExpression Id. */ 39 | int AND = 18; 40 | /** RegularExpression Id. */ 41 | int OR = 19; 42 | /** RegularExpression Id. */ 43 | int NOT = 20; 44 | /** RegularExpression Id. */ 45 | int IM = 21; 46 | /** RegularExpression Id. */ 47 | int PLUS = 22; 48 | /** RegularExpression Id. */ 49 | int MINUS = 23; 50 | /** RegularExpression Id. */ 51 | int MUL = 24; 52 | /** RegularExpression Id. */ 53 | int DIV = 25; 54 | /** RegularExpression Id. */ 55 | int MOD = 26; 56 | /** RegularExpression Id. */ 57 | int OPENPAR = 27; 58 | /** RegularExpression Id. */ 59 | int CLOSEPAR = 28; 60 | 61 | /** Lexical state. */ 62 | int DEFAULT = 0; 63 | 64 | /** Literal token values. */ 65 | String[] tokenImage = { 66 | "", 67 | "\" \"", 68 | "\"\\t\"", 69 | "\"\\n\"", 70 | "\"\\r\"", 71 | "", 72 | "", 73 | "", 74 | "", 75 | "", 76 | "", 77 | "", 78 | "", 79 | "\">\"", 80 | "\"<\"", 81 | "\"<=\"", 82 | "\">=\"", 83 | "\"!=\"", 84 | "\"&&\"", 85 | "\"||\"", 86 | "", 87 | "\"=>\"", 88 | "\"+\"", 89 | "\"-\"", 90 | "\"*\"", 91 | "\"/\"", 92 | "\"%\"", 93 | "\"(\"", 94 | "\")\"", 95 | }; 96 | 97 | } 98 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ConstraintChocoParserTokenManager.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. ConstraintChocoParserTokenManager.java */ 3 | 4 | 5 | /** Token Manager. */ 6 | public class ConstraintChocoParserTokenManager implements ConstraintChocoParserConstants 7 | { 8 | 9 | /** Debug output. */ 10 | public java.io.PrintStream debugStream = System.out; 11 | /** Set debug output. */ 12 | public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } 13 | private final int jjStopStringLiteralDfa_0(int pos, long active0) 14 | { 15 | switch (pos) 16 | { 17 | case 0: 18 | if ((active0 & 0x200000L) != 0L) 19 | { 20 | jjmatchedKind = 12; 21 | return 16; 22 | } 23 | if ((active0 & 0x20000L) != 0L) 24 | { 25 | jjmatchedKind = 20; 26 | return -1; 27 | } 28 | return -1; 29 | default : 30 | return -1; 31 | } 32 | } 33 | private final int jjStartNfa_0(int pos, long active0) 34 | { 35 | return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); 36 | } 37 | private int jjStopAtPos(int pos, int kind) 38 | { 39 | jjmatchedKind = kind; 40 | jjmatchedPos = pos; 41 | return pos + 1; 42 | } 43 | private int jjMoveStringLiteralDfa0_0() 44 | { 45 | switch(curChar) 46 | { 47 | case 33: 48 | return jjMoveStringLiteralDfa1_0(0x20000L); 49 | case 37: 50 | return jjStopAtPos(0, 26); 51 | case 38: 52 | return jjMoveStringLiteralDfa1_0(0x40000L); 53 | case 40: 54 | return jjStopAtPos(0, 27); 55 | case 41: 56 | return jjStopAtPos(0, 28); 57 | case 42: 58 | return jjStopAtPos(0, 24); 59 | case 43: 60 | return jjStopAtPos(0, 22); 61 | case 45: 62 | return jjStopAtPos(0, 23); 63 | case 47: 64 | return jjStopAtPos(0, 25); 65 | case 60: 66 | jjmatchedKind = 14; 67 | return jjMoveStringLiteralDfa1_0(0x8000L); 68 | case 61: 69 | return jjMoveStringLiteralDfa1_0(0x200000L); 70 | case 62: 71 | jjmatchedKind = 13; 72 | return jjMoveStringLiteralDfa1_0(0x10000L); 73 | case 124: 74 | return jjMoveStringLiteralDfa1_0(0x80000L); 75 | default : 76 | return jjMoveNfa_0(1, 0); 77 | } 78 | } 79 | private int jjMoveStringLiteralDfa1_0(long active0) 80 | { 81 | try { curChar = input_stream.readChar(); } 82 | catch(java.io.IOException e) { 83 | jjStopStringLiteralDfa_0(0, active0); 84 | return 1; 85 | } 86 | switch(curChar) 87 | { 88 | case 38: 89 | if ((active0 & 0x40000L) != 0L) 90 | return jjStopAtPos(1, 18); 91 | break; 92 | case 61: 93 | if ((active0 & 0x8000L) != 0L) 94 | return jjStopAtPos(1, 15); 95 | else if ((active0 & 0x10000L) != 0L) 96 | return jjStopAtPos(1, 16); 97 | else if ((active0 & 0x20000L) != 0L) 98 | return jjStopAtPos(1, 17); 99 | break; 100 | case 62: 101 | if ((active0 & 0x200000L) != 0L) 102 | return jjStopAtPos(1, 21); 103 | break; 104 | case 124: 105 | if ((active0 & 0x80000L) != 0L) 106 | return jjStopAtPos(1, 19); 107 | break; 108 | default : 109 | break; 110 | } 111 | return jjStartNfa_0(0, active0); 112 | } 113 | static final long[] jjbitVec0 = { 114 | 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL 115 | }; 116 | private int jjMoveNfa_0(int startState, int curPos) 117 | { 118 | int startsAt = 0; 119 | jjnewStateCnt = 33; 120 | int i = 1; 121 | jjstateSet[0] = startState; 122 | int kind = 0x7fffffff; 123 | for (;;) 124 | { 125 | if (++jjround == 0x7fffffff) 126 | ReInitRounds(); 127 | if (curChar < 64) 128 | { 129 | long l = 1L << curChar; 130 | do 131 | { 132 | switch(jjstateSet[--i]) 133 | { 134 | case 1: 135 | if ((0x3ff000000000000L & l) != 0L) 136 | { 137 | if (kind > 5) 138 | kind = 5; 139 | jjCheckNAdd(0); 140 | } 141 | else if (curChar == 33) 142 | { 143 | if (kind > 20) 144 | kind = 20; 145 | } 146 | else if (curChar == 61) 147 | jjstateSet[jjnewStateCnt++] = 16; 148 | else if (curChar == 34) 149 | jjCheckNAddTwoStates(2, 3); 150 | if (curChar == 61) 151 | { 152 | if (kind > 12) 153 | kind = 12; 154 | } 155 | break; 156 | case 0: 157 | if ((0x3ff000000000000L & l) == 0L) 158 | break; 159 | if (kind > 5) 160 | kind = 5; 161 | jjCheckNAdd(0); 162 | break; 163 | case 2: 164 | if ((0xfffffffbffffdbffL & l) != 0L) 165 | jjCheckNAddTwoStates(2, 3); 166 | break; 167 | case 3: 168 | if (curChar == 34 && kind > 6) 169 | kind = 6; 170 | break; 171 | case 14: 172 | if ((0x3ff000000000000L & l) == 0L) 173 | break; 174 | if (kind > 9) 175 | kind = 9; 176 | jjstateSet[jjnewStateCnt++] = 14; 177 | break; 178 | case 15: 179 | case 16: 180 | if (curChar == 61 && kind > 12) 181 | kind = 12; 182 | break; 183 | case 17: 184 | if (curChar == 61) 185 | jjstateSet[jjnewStateCnt++] = 16; 186 | break; 187 | case 18: 188 | if (curChar == 33 && kind > 20) 189 | kind = 20; 190 | break; 191 | default : break; 192 | } 193 | } while(i != startsAt); 194 | } 195 | else if (curChar < 128) 196 | { 197 | long l = 1L << (curChar & 077); 198 | do 199 | { 200 | switch(jjstateSet[--i]) 201 | { 202 | case 1: 203 | if ((0x7fffffe87fffffeL & l) != 0L) 204 | { 205 | if (kind > 9) 206 | kind = 9; 207 | jjCheckNAdd(14); 208 | } 209 | else if (curChar == 126) 210 | { 211 | if (kind > 20) 212 | kind = 20; 213 | } 214 | if (curChar == 84) 215 | jjAddStates(0, 1); 216 | else if (curChar == 70) 217 | jjAddStates(2, 3); 218 | else if (curChar == 102) 219 | jjstateSet[jjnewStateCnt++] = 11; 220 | else if (curChar == 116) 221 | jjstateSet[jjnewStateCnt++] = 6; 222 | break; 223 | case 2: 224 | if ((0xffffffffefffffffL & l) != 0L) 225 | jjAddStates(4, 5); 226 | break; 227 | case 4: 228 | if (curChar == 101 && kind > 7) 229 | kind = 7; 230 | break; 231 | case 5: 232 | case 31: 233 | if (curChar == 117) 234 | jjCheckNAdd(4); 235 | break; 236 | case 6: 237 | if (curChar == 114) 238 | jjstateSet[jjnewStateCnt++] = 5; 239 | break; 240 | case 7: 241 | if (curChar == 116) 242 | jjstateSet[jjnewStateCnt++] = 6; 243 | break; 244 | case 8: 245 | if (curChar == 101 && kind > 8) 246 | kind = 8; 247 | break; 248 | case 9: 249 | case 24: 250 | if (curChar == 115) 251 | jjCheckNAdd(8); 252 | break; 253 | case 10: 254 | if (curChar == 108) 255 | jjstateSet[jjnewStateCnt++] = 9; 256 | break; 257 | case 11: 258 | if (curChar == 97) 259 | jjstateSet[jjnewStateCnt++] = 10; 260 | break; 261 | case 12: 262 | if (curChar == 102) 263 | jjstateSet[jjnewStateCnt++] = 11; 264 | break; 265 | case 13: 266 | case 14: 267 | if ((0x7fffffe87fffffeL & l) == 0L) 268 | break; 269 | if (kind > 9) 270 | kind = 9; 271 | jjCheckNAdd(14); 272 | break; 273 | case 18: 274 | if (curChar == 126 && kind > 20) 275 | kind = 20; 276 | break; 277 | case 19: 278 | if (curChar == 70) 279 | jjAddStates(2, 3); 280 | break; 281 | case 20: 282 | if (curChar == 69 && kind > 8) 283 | kind = 8; 284 | break; 285 | case 21: 286 | if (curChar == 83) 287 | jjstateSet[jjnewStateCnt++] = 20; 288 | break; 289 | case 22: 290 | if (curChar == 76) 291 | jjstateSet[jjnewStateCnt++] = 21; 292 | break; 293 | case 23: 294 | if (curChar == 65) 295 | jjstateSet[jjnewStateCnt++] = 22; 296 | break; 297 | case 25: 298 | if (curChar == 108) 299 | jjstateSet[jjnewStateCnt++] = 24; 300 | break; 301 | case 26: 302 | if (curChar == 97) 303 | jjstateSet[jjnewStateCnt++] = 25; 304 | break; 305 | case 27: 306 | if (curChar == 84) 307 | jjAddStates(0, 1); 308 | break; 309 | case 28: 310 | if (curChar == 69 && kind > 7) 311 | kind = 7; 312 | break; 313 | case 29: 314 | if (curChar == 85) 315 | jjstateSet[jjnewStateCnt++] = 28; 316 | break; 317 | case 30: 318 | if (curChar == 82) 319 | jjstateSet[jjnewStateCnt++] = 29; 320 | break; 321 | case 32: 322 | if (curChar == 114) 323 | jjstateSet[jjnewStateCnt++] = 31; 324 | break; 325 | default : break; 326 | } 327 | } while(i != startsAt); 328 | } 329 | else 330 | { 331 | int i2 = (curChar & 0xff) >> 6; 332 | long l2 = 1L << (curChar & 077); 333 | do 334 | { 335 | switch(jjstateSet[--i]) 336 | { 337 | case 2: 338 | if ((jjbitVec0[i2] & l2) != 0L) 339 | jjAddStates(4, 5); 340 | break; 341 | default : break; 342 | } 343 | } while(i != startsAt); 344 | } 345 | if (kind != 0x7fffffff) 346 | { 347 | jjmatchedKind = kind; 348 | jjmatchedPos = curPos; 349 | kind = 0x7fffffff; 350 | } 351 | ++curPos; 352 | if ((i = jjnewStateCnt) == (startsAt = 33 - (jjnewStateCnt = startsAt))) 353 | return curPos; 354 | try { curChar = input_stream.readChar(); } 355 | catch(java.io.IOException e) { return curPos; } 356 | } 357 | } 358 | static final int[] jjnextStates = { 359 | 30, 32, 23, 26, 2, 3, 360 | }; 361 | 362 | /** Token literal values. */ 363 | public static final String[] jjstrLiteralImages = { 364 | "", null, null, null, null, null, null, null, null, null, null, null, null, 365 | "\76", "\74", "\74\75", "\76\75", "\41\75", "\46\46", "\174\174", null, "\75\76", 366 | "\53", "\55", "\52", "\57", "\45", "\50", "\51", }; 367 | 368 | /** Lexer state names. */ 369 | public static final String[] lexStateNames = { 370 | "DEFAULT", 371 | }; 372 | static final long[] jjtoToken = { 373 | 0x1ffff3e1L, 374 | }; 375 | static final long[] jjtoSkip = { 376 | 0x1eL, 377 | }; 378 | protected SimpleCharStream input_stream; 379 | private final int[] jjrounds = new int[33]; 380 | private final int[] jjstateSet = new int[66]; 381 | protected char curChar; 382 | /** Constructor. */ 383 | public ConstraintChocoParserTokenManager(SimpleCharStream stream){ 384 | if (SimpleCharStream.staticFlag) 385 | throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); 386 | input_stream = stream; 387 | } 388 | 389 | /** Constructor. */ 390 | public ConstraintChocoParserTokenManager(SimpleCharStream stream, int lexState){ 391 | this(stream); 392 | SwitchTo(lexState); 393 | } 394 | 395 | /** Reinitialise parser. */ 396 | public void ReInit(SimpleCharStream stream) 397 | { 398 | jjmatchedPos = jjnewStateCnt = 0; 399 | curLexState = defaultLexState; 400 | input_stream = stream; 401 | ReInitRounds(); 402 | } 403 | private void ReInitRounds() 404 | { 405 | int i; 406 | jjround = 0x80000001; 407 | for (i = 33; i-- > 0;) 408 | jjrounds[i] = 0x80000000; 409 | } 410 | 411 | /** Reinitialise parser. */ 412 | public void ReInit(SimpleCharStream stream, int lexState) 413 | { 414 | ReInit(stream); 415 | SwitchTo(lexState); 416 | } 417 | 418 | /** Switch to specified lex state. */ 419 | public void SwitchTo(int lexState) 420 | { 421 | if (lexState >= 1 || lexState < 0) 422 | throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); 423 | else 424 | curLexState = lexState; 425 | } 426 | 427 | protected Token jjFillToken() 428 | { 429 | final Token t; 430 | final String curTokenImage; 431 | final int beginLine; 432 | final int endLine; 433 | final int beginColumn; 434 | final int endColumn; 435 | String im = jjstrLiteralImages[jjmatchedKind]; 436 | curTokenImage = (im == null) ? input_stream.GetImage() : im; 437 | beginLine = input_stream.getBeginLine(); 438 | beginColumn = input_stream.getBeginColumn(); 439 | endLine = input_stream.getEndLine(); 440 | endColumn = input_stream.getEndColumn(); 441 | t = Token.newToken(jjmatchedKind, curTokenImage); 442 | 443 | t.beginLine = beginLine; 444 | t.endLine = endLine; 445 | t.beginColumn = beginColumn; 446 | t.endColumn = endColumn; 447 | 448 | return t; 449 | } 450 | 451 | int curLexState = 0; 452 | int defaultLexState = 0; 453 | int jjnewStateCnt; 454 | int jjround; 455 | int jjmatchedPos; 456 | int jjmatchedKind; 457 | 458 | /** Get the next Token. */ 459 | public Token getNextToken() 460 | { 461 | Token matchedToken; 462 | int curPos = 0; 463 | 464 | EOFLoop : 465 | for (;;) 466 | { 467 | try 468 | { 469 | curChar = input_stream.BeginToken(); 470 | } 471 | catch(java.io.IOException e) 472 | { 473 | jjmatchedKind = 0; 474 | matchedToken = jjFillToken(); 475 | return matchedToken; 476 | } 477 | 478 | try { input_stream.backup(0); 479 | while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) 480 | curChar = input_stream.BeginToken(); 481 | } 482 | catch (java.io.IOException e1) { continue EOFLoop; } 483 | jjmatchedKind = 0x7fffffff; 484 | jjmatchedPos = 0; 485 | curPos = jjMoveStringLiteralDfa0_0(); 486 | if (jjmatchedKind != 0x7fffffff) 487 | { 488 | if (jjmatchedPos + 1 < curPos) 489 | input_stream.backup(curPos - jjmatchedPos - 1); 490 | if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) 491 | { 492 | matchedToken = jjFillToken(); 493 | return matchedToken; 494 | } 495 | else 496 | { 497 | continue EOFLoop; 498 | } 499 | } 500 | int error_line = input_stream.getEndLine(); 501 | int error_column = input_stream.getEndColumn(); 502 | String error_after = null; 503 | boolean EOFSeen = false; 504 | try { input_stream.readChar(); input_stream.backup(1); } 505 | catch (java.io.IOException e1) { 506 | EOFSeen = true; 507 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); 508 | if (curChar == '\n' || curChar == '\r') { 509 | error_line++; 510 | error_column = 0; 511 | } 512 | else 513 | error_column++; 514 | } 515 | if (!EOFSeen) { 516 | input_stream.backup(1); 517 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); 518 | } 519 | throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); 520 | } 521 | } 522 | 523 | private void jjCheckNAdd(int state) 524 | { 525 | if (jjrounds[state] != jjround) 526 | { 527 | jjstateSet[jjnewStateCnt++] = state; 528 | jjrounds[state] = jjround; 529 | } 530 | } 531 | private void jjAddStates(int start, int end) 532 | { 533 | do { 534 | jjstateSet[jjnewStateCnt++] = jjnextStates[start]; 535 | } while (start++ != end); 536 | } 537 | private void jjCheckNAddTwoStates(int state1, int state2) 538 | { 539 | jjCheckNAdd(state1); 540 | jjCheckNAdd(state2); 541 | } 542 | 543 | } 544 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ConstraintManager.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | 7 | public class ConstraintManager 8 | { 9 | 10 | public static String[] JustParameterValues(String text) 11 | { 12 | 13 | 14 | for (String s : Tools.ArithmeticsOperators) 15 | { 16 | text = text.replace(s, "?"); 17 | } 18 | for (String s : Tools.RelationalOperators) 19 | { 20 | text = text.replace(s, "?"); 21 | } 22 | for (String s : Tools.BooleanOperators) 23 | { 24 | text = text.replace(s, "?"); 25 | } 26 | 27 | for (String s : Tools.GroupOperators) 28 | { 29 | text = text.replace(s, "?"); 30 | } 31 | 32 | 33 | return text.split("\\?"); 34 | } 35 | 36 | public static Boolean isParameter(String text, HashMap parameters) 37 | { 38 | if (parameters.containsKey(text)) 39 | { 40 | return true; 41 | } 42 | return false; 43 | } 44 | 45 | 46 | public static Boolean isVariableValue(String text) 47 | { 48 | 49 | if (text.isEmpty()) 50 | { 51 | return false; 52 | } 53 | if (Tools.isNumeric(text)) 54 | { 55 | return true; 56 | } 57 | if (text.toUpperCase().equals(Boolean.toString(true).toUpperCase()) || text.toUpperCase().equals( 58 | Boolean.toString(false).toUpperCase() 59 | )) 60 | { 61 | return true; 62 | } 63 | if (text.startsWith("\"") && text.endsWith("\"")) 64 | { 65 | return true; 66 | } 67 | 68 | return false; 69 | } 70 | 71 | public static Boolean isValidParameterValue(String text, Parameter anterior) 72 | { 73 | 74 | ArrayList p = anterior.getValues(); 75 | 76 | if (p.contains(Tools.WithoutQuoations(text.trim()))) 77 | { 78 | return true; 79 | } 80 | return false; 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ConstraintParserConstants.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. ConstraintParserConstants.java */ 3 | 4 | /** 5 | * Token literal values and constants. 6 | * Generated by org.javacc.parser.OtherFilesGen#start() 7 | */ 8 | public interface ConstraintParserConstants { 9 | 10 | /** End of File. */ 11 | int EOF = 0; 12 | /** RegularExpression Id. */ 13 | int INTEGER_LITERAL = 5; 14 | /** RegularExpression Id. */ 15 | int STRING_LITERAL = 6; 16 | /** RegularExpression Id. */ 17 | int TRUE = 7; 18 | /** RegularExpression Id. */ 19 | int FALSE = 8; 20 | /** RegularExpression Id. */ 21 | int IDENTIFIER = 9; 22 | /** RegularExpression Id. */ 23 | int LETTER = 10; 24 | /** RegularExpression Id. */ 25 | int DIGIT = 11; 26 | /** RegularExpression Id. */ 27 | int EQ = 12; 28 | /** RegularExpression Id. */ 29 | int GT = 13; 30 | /** RegularExpression Id. */ 31 | int LT = 14; 32 | /** RegularExpression Id. */ 33 | int LE = 15; 34 | /** RegularExpression Id. */ 35 | int GE = 16; 36 | /** RegularExpression Id. */ 37 | int NE = 17; 38 | /** RegularExpression Id. */ 39 | int AND = 18; 40 | /** RegularExpression Id. */ 41 | int OR = 19; 42 | /** RegularExpression Id. */ 43 | int NOT = 20; 44 | /** RegularExpression Id. */ 45 | int IM = 21; 46 | /** RegularExpression Id. */ 47 | int PLUS = 22; 48 | /** RegularExpression Id. */ 49 | int MINUS = 23; 50 | /** RegularExpression Id. */ 51 | int MUL = 24; 52 | /** RegularExpression Id. */ 53 | int DIV = 25; 54 | /** RegularExpression Id. */ 55 | int MOD = 26; 56 | /** RegularExpression Id. */ 57 | int OPENPAR = 27; 58 | /** RegularExpression Id. */ 59 | int CLOSEPAR = 28; 60 | 61 | 62 | /** Lexical state. */ 63 | int DEFAULT = 0; 64 | 65 | /** Literal token values. */ 66 | String[] tokenImage = { 67 | "", 68 | "\" \"", 69 | "\"\\t\"", 70 | "\"\\n\"", 71 | "\"\\r\"", 72 | "", 73 | "", 74 | "", 75 | "", 76 | "", 77 | "", 78 | "", 79 | "", 80 | "\">\"", 81 | "\"<\"", 82 | "\"<=\"", 83 | "\">=\"", 84 | "\"!=\"", 85 | "\"&&\"", 86 | "\"||\"", 87 | "", 88 | "\"=>\"", 89 | "\"+\"", 90 | "\"-\"", 91 | "\"*\"", 92 | "\"/\"", 93 | "\"%\"", 94 | "\"(\"", 95 | "\")\"", 96 | }; 97 | 98 | } 99 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ConstraintParserTokenManager.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. ConstraintParserTokenManager.java */ 3 | 4 | 5 | /** Token Manager. */ 6 | public class ConstraintParserTokenManager implements ConstraintParserConstants 7 | { 8 | 9 | /** Debug output. */ 10 | public java.io.PrintStream debugStream = System.out; 11 | /** Set debug output. */ 12 | public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } 13 | private final int jjStopStringLiteralDfa_0(int pos, long active0) 14 | { 15 | switch (pos) 16 | { 17 | case 0: 18 | if ((active0 & 0x200000L) != 0L) 19 | { 20 | jjmatchedKind = 12; 21 | return 16; 22 | } 23 | if ((active0 & 0x20000L) != 0L) 24 | { 25 | jjmatchedKind = 20; 26 | return -1; 27 | } 28 | return -1; 29 | default : 30 | return -1; 31 | } 32 | } 33 | private final int jjStartNfa_0(int pos, long active0) 34 | { 35 | return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); 36 | } 37 | private int jjStopAtPos(int pos, int kind) 38 | { 39 | jjmatchedKind = kind; 40 | jjmatchedPos = pos; 41 | return pos + 1; 42 | } 43 | private int jjMoveStringLiteralDfa0_0() 44 | { 45 | switch(curChar) 46 | { 47 | case 33: 48 | return jjMoveStringLiteralDfa1_0(0x20000L); 49 | case 37: 50 | return jjStopAtPos(0, 26); 51 | case 38: 52 | return jjMoveStringLiteralDfa1_0(0x40000L); 53 | case 40: 54 | return jjStopAtPos(0, 27); 55 | case 41: 56 | return jjStopAtPos(0, 28); 57 | case 42: 58 | return jjStopAtPos(0, 24); 59 | case 43: 60 | return jjStopAtPos(0, 22); 61 | case 45: 62 | return jjStopAtPos(0, 23); 63 | case 47: 64 | return jjStopAtPos(0, 25); 65 | case 60: 66 | jjmatchedKind = 14; 67 | return jjMoveStringLiteralDfa1_0(0x8000L); 68 | case 61: 69 | return jjMoveStringLiteralDfa1_0(0x200000L); 70 | case 62: 71 | jjmatchedKind = 13; 72 | return jjMoveStringLiteralDfa1_0(0x10000L); 73 | case 124: 74 | return jjMoveStringLiteralDfa1_0(0x80000L); 75 | default : 76 | return jjMoveNfa_0(1, 0); 77 | } 78 | } 79 | private int jjMoveStringLiteralDfa1_0(long active0) 80 | { 81 | try { curChar = input_stream.readChar(); } 82 | catch(java.io.IOException e) { 83 | jjStopStringLiteralDfa_0(0, active0); 84 | return 1; 85 | } 86 | switch(curChar) 87 | { 88 | case 38: 89 | if ((active0 & 0x40000L) != 0L) 90 | return jjStopAtPos(1, 18); 91 | break; 92 | case 61: 93 | if ((active0 & 0x8000L) != 0L) 94 | return jjStopAtPos(1, 15); 95 | else if ((active0 & 0x10000L) != 0L) 96 | return jjStopAtPos(1, 16); 97 | else if ((active0 & 0x20000L) != 0L) 98 | return jjStopAtPos(1, 17); 99 | break; 100 | case 62: 101 | if ((active0 & 0x200000L) != 0L) 102 | return jjStopAtPos(1, 21); 103 | break; 104 | case 124: 105 | if ((active0 & 0x80000L) != 0L) 106 | return jjStopAtPos(1, 19); 107 | break; 108 | default : 109 | break; 110 | } 111 | return jjStartNfa_0(0, active0); 112 | } 113 | static final long[] jjbitVec0 = { 114 | 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL 115 | }; 116 | private int jjMoveNfa_0(int startState, int curPos) 117 | { 118 | int startsAt = 0; 119 | jjnewStateCnt = 33; 120 | int i = 1; 121 | jjstateSet[0] = startState; 122 | int kind = 0x7fffffff; 123 | for (;;) 124 | { 125 | if (++jjround == 0x7fffffff) 126 | ReInitRounds(); 127 | if (curChar < 64) 128 | { 129 | long l = 1L << curChar; 130 | do 131 | { 132 | switch(jjstateSet[--i]) 133 | { 134 | case 1: 135 | if ((0x3ff000000000000L & l) != 0L) 136 | { 137 | if (kind > 5) 138 | kind = 5; 139 | jjCheckNAdd(0); 140 | } 141 | else if (curChar == 33) 142 | { 143 | if (kind > 20) 144 | kind = 20; 145 | } 146 | else if (curChar == 61) 147 | jjstateSet[jjnewStateCnt++] = 16; 148 | else if (curChar == 34) 149 | jjCheckNAddTwoStates(2, 3); 150 | if (curChar == 61) 151 | { 152 | if (kind > 12) 153 | kind = 12; 154 | } 155 | break; 156 | case 0: 157 | if ((0x3ff000000000000L & l) == 0L) 158 | break; 159 | if (kind > 5) 160 | kind = 5; 161 | jjCheckNAdd(0); 162 | break; 163 | case 2: 164 | if ((0xfffffffbffffdbffL & l) != 0L) 165 | jjCheckNAddTwoStates(2, 3); 166 | break; 167 | case 3: 168 | if (curChar == 34 && kind > 6) 169 | kind = 6; 170 | break; 171 | case 14: 172 | if ((0x3ff000000000000L & l) == 0L) 173 | break; 174 | if (kind > 9) 175 | kind = 9; 176 | jjstateSet[jjnewStateCnt++] = 14; 177 | break; 178 | case 15: 179 | case 16: 180 | if (curChar == 61 && kind > 12) 181 | kind = 12; 182 | break; 183 | case 17: 184 | if (curChar == 61) 185 | jjstateSet[jjnewStateCnt++] = 16; 186 | break; 187 | case 18: 188 | if (curChar == 33 && kind > 20) 189 | kind = 20; 190 | break; 191 | default : break; 192 | } 193 | } while(i != startsAt); 194 | } 195 | else if (curChar < 128) 196 | { 197 | long l = 1L << (curChar & 077); 198 | do 199 | { 200 | switch(jjstateSet[--i]) 201 | { 202 | case 1: 203 | if ((0x7fffffe87fffffeL & l) != 0L) 204 | { 205 | if (kind > 9) 206 | kind = 9; 207 | jjCheckNAdd(14); 208 | } 209 | else if (curChar == 126) 210 | { 211 | if (kind > 20) 212 | kind = 20; 213 | } 214 | if (curChar == 84) 215 | jjAddStates(0, 1); 216 | else if (curChar == 70) 217 | jjAddStates(2, 3); 218 | else if (curChar == 102) 219 | jjstateSet[jjnewStateCnt++] = 11; 220 | else if (curChar == 116) 221 | jjstateSet[jjnewStateCnt++] = 6; 222 | break; 223 | case 2: 224 | if ((0xffffffffefffffffL & l) != 0L) 225 | jjAddStates(4, 5); 226 | break; 227 | case 4: 228 | if (curChar == 101 && kind > 7) 229 | kind = 7; 230 | break; 231 | case 5: 232 | case 31: 233 | if (curChar == 117) 234 | jjCheckNAdd(4); 235 | break; 236 | case 6: 237 | if (curChar == 114) 238 | jjstateSet[jjnewStateCnt++] = 5; 239 | break; 240 | case 7: 241 | if (curChar == 116) 242 | jjstateSet[jjnewStateCnt++] = 6; 243 | break; 244 | case 8: 245 | if (curChar == 101 && kind > 8) 246 | kind = 8; 247 | break; 248 | case 9: 249 | case 24: 250 | if (curChar == 115) 251 | jjCheckNAdd(8); 252 | break; 253 | case 10: 254 | if (curChar == 108) 255 | jjstateSet[jjnewStateCnt++] = 9; 256 | break; 257 | case 11: 258 | if (curChar == 97) 259 | jjstateSet[jjnewStateCnt++] = 10; 260 | break; 261 | case 12: 262 | if (curChar == 102) 263 | jjstateSet[jjnewStateCnt++] = 11; 264 | break; 265 | case 13: 266 | case 14: 267 | if ((0x7fffffe87fffffeL & l) == 0L) 268 | break; 269 | if (kind > 9) 270 | kind = 9; 271 | jjCheckNAdd(14); 272 | break; 273 | case 18: 274 | if (curChar == 126 && kind > 20) 275 | kind = 20; 276 | break; 277 | case 19: 278 | if (curChar == 70) 279 | jjAddStates(2, 3); 280 | break; 281 | case 20: 282 | if (curChar == 69 && kind > 8) 283 | kind = 8; 284 | break; 285 | case 21: 286 | if (curChar == 83) 287 | jjstateSet[jjnewStateCnt++] = 20; 288 | break; 289 | case 22: 290 | if (curChar == 76) 291 | jjstateSet[jjnewStateCnt++] = 21; 292 | break; 293 | case 23: 294 | if (curChar == 65) 295 | jjstateSet[jjnewStateCnt++] = 22; 296 | break; 297 | case 25: 298 | if (curChar == 108) 299 | jjstateSet[jjnewStateCnt++] = 24; 300 | break; 301 | case 26: 302 | if (curChar == 97) 303 | jjstateSet[jjnewStateCnt++] = 25; 304 | break; 305 | case 27: 306 | if (curChar == 84) 307 | jjAddStates(0, 1); 308 | break; 309 | case 28: 310 | if (curChar == 69 && kind > 7) 311 | kind = 7; 312 | break; 313 | case 29: 314 | if (curChar == 85) 315 | jjstateSet[jjnewStateCnt++] = 28; 316 | break; 317 | case 30: 318 | if (curChar == 82) 319 | jjstateSet[jjnewStateCnt++] = 29; 320 | break; 321 | case 32: 322 | if (curChar == 114) 323 | jjstateSet[jjnewStateCnt++] = 31; 324 | break; 325 | default : break; 326 | } 327 | } while(i != startsAt); 328 | } 329 | else 330 | { 331 | int i2 = (curChar & 0xff) >> 6; 332 | long l2 = 1L << (curChar & 077); 333 | do 334 | { 335 | switch(jjstateSet[--i]) 336 | { 337 | case 2: 338 | if ((jjbitVec0[i2] & l2) != 0L) 339 | jjAddStates(4, 5); 340 | break; 341 | default : break; 342 | } 343 | } while(i != startsAt); 344 | } 345 | if (kind != 0x7fffffff) 346 | { 347 | jjmatchedKind = kind; 348 | jjmatchedPos = curPos; 349 | kind = 0x7fffffff; 350 | } 351 | ++curPos; 352 | if ((i = jjnewStateCnt) == (startsAt = 33 - (jjnewStateCnt = startsAt))) 353 | return curPos; 354 | try { curChar = input_stream.readChar(); } 355 | catch(java.io.IOException e) { return curPos; } 356 | } 357 | } 358 | static final int[] jjnextStates = { 359 | 30, 32, 23, 26, 2, 3, 360 | }; 361 | 362 | /** Token literal values. */ 363 | public static final String[] jjstrLiteralImages = { 364 | "", null, null, null, null, null, null, null, null, null, null, null, null, 365 | "\76", "\74", "\74\75", "\76\75", "\41\75", "\46\46", "\174\174", null, "\75\76", 366 | "\53", "\55", "\52", "\57", "\45", "\50", "\51", }; 367 | 368 | /** Lexer state names. */ 369 | public static final String[] lexStateNames = { 370 | "DEFAULT", 371 | }; 372 | static final long[] jjtoToken = { 373 | 0x1ffff3e1L, 374 | }; 375 | static final long[] jjtoSkip = { 376 | 0x1eL, 377 | }; 378 | protected SimpleCharStream input_stream; 379 | private final int[] jjrounds = new int[33]; 380 | private final int[] jjstateSet = new int[66]; 381 | protected char curChar; 382 | /** Constructor. */ 383 | public ConstraintParserTokenManager(SimpleCharStream stream){ 384 | if (SimpleCharStream.staticFlag) 385 | throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); 386 | input_stream = stream; 387 | } 388 | 389 | /** Constructor. */ 390 | public ConstraintParserTokenManager(SimpleCharStream stream, int lexState){ 391 | this(stream); 392 | SwitchTo(lexState); 393 | } 394 | 395 | /** Reinitialise parser. */ 396 | public void ReInit(SimpleCharStream stream) 397 | { 398 | jjmatchedPos = jjnewStateCnt = 0; 399 | curLexState = defaultLexState; 400 | input_stream = stream; 401 | ReInitRounds(); 402 | } 403 | private void ReInitRounds() 404 | { 405 | int i; 406 | jjround = 0x80000001; 407 | for (i = 33; i-- > 0;) 408 | jjrounds[i] = 0x80000000; 409 | } 410 | 411 | /** Reinitialise parser. */ 412 | public void ReInit(SimpleCharStream stream, int lexState) 413 | { 414 | ReInit(stream); 415 | SwitchTo(lexState); 416 | } 417 | 418 | /** Switch to specified lex state. */ 419 | public void SwitchTo(int lexState) 420 | { 421 | if (lexState >= 1 || lexState < 0) 422 | throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); 423 | else 424 | curLexState = lexState; 425 | } 426 | 427 | protected Token jjFillToken() 428 | { 429 | final Token t; 430 | final String curTokenImage; 431 | final int beginLine; 432 | final int endLine; 433 | final int beginColumn; 434 | final int endColumn; 435 | String im = jjstrLiteralImages[jjmatchedKind]; 436 | curTokenImage = (im == null) ? input_stream.GetImage() : im; 437 | beginLine = input_stream.getBeginLine(); 438 | beginColumn = input_stream.getBeginColumn(); 439 | endLine = input_stream.getEndLine(); 440 | endColumn = input_stream.getEndColumn(); 441 | t = Token.newToken(jjmatchedKind, curTokenImage); 442 | 443 | t.beginLine = beginLine; 444 | t.endLine = endLine; 445 | t.beginColumn = beginColumn; 446 | t.endColumn = endColumn; 447 | 448 | return t; 449 | } 450 | 451 | int curLexState = 0; 452 | int defaultLexState = 0; 453 | int jjnewStateCnt; 454 | int jjround; 455 | int jjmatchedPos; 456 | int jjmatchedKind; 457 | 458 | /** Get the next Token. */ 459 | public Token getNextToken() 460 | { 461 | Token matchedToken; 462 | int curPos = 0; 463 | 464 | EOFLoop : 465 | for (;;) 466 | { 467 | try 468 | { 469 | curChar = input_stream.BeginToken(); 470 | } 471 | catch(java.io.IOException e) 472 | { 473 | jjmatchedKind = 0; 474 | matchedToken = jjFillToken(); 475 | return matchedToken; 476 | } 477 | 478 | try { input_stream.backup(0); 479 | while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) 480 | curChar = input_stream.BeginToken(); 481 | } 482 | catch (java.io.IOException e1) { continue EOFLoop; } 483 | jjmatchedKind = 0x7fffffff; 484 | jjmatchedPos = 0; 485 | curPos = jjMoveStringLiteralDfa0_0(); 486 | if (jjmatchedKind != 0x7fffffff) 487 | { 488 | if (jjmatchedPos + 1 < curPos) 489 | input_stream.backup(curPos - jjmatchedPos - 1); 490 | if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) 491 | { 492 | matchedToken = jjFillToken(); 493 | return matchedToken; 494 | } 495 | else 496 | { 497 | continue EOFLoop; 498 | } 499 | } 500 | int error_line = input_stream.getEndLine(); 501 | int error_column = input_stream.getEndColumn(); 502 | String error_after = null; 503 | boolean EOFSeen = false; 504 | try { input_stream.readChar(); input_stream.backup(1); } 505 | catch (java.io.IOException e1) { 506 | EOFSeen = true; 507 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); 508 | if (curChar == '\n' || curChar == '\r') { 509 | error_line++; 510 | error_column = 0; 511 | } 512 | else 513 | error_column++; 514 | } 515 | if (!EOFSeen) { 516 | input_stream.backup(1); 517 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); 518 | } 519 | throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); 520 | } 521 | } 522 | 523 | private void jjCheckNAdd(int state) 524 | { 525 | if (jjrounds[state] != jjround) 526 | { 527 | jjstateSet[jjnewStateCnt++] = state; 528 | jjrounds[state] = jjround; 529 | } 530 | } 531 | private void jjAddStates(int start, int end) 532 | { 533 | do { 534 | jjstateSet[jjnewStateCnt++] = jjnextStates[start]; 535 | } while (start++ != end); 536 | } 537 | private void jjCheckNAddTwoStates(int state1, int state2) 538 | { 539 | jjCheckNAdd(state1); 540 | jjCheckNAdd(state2); 541 | } 542 | 543 | } 544 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/Parameter.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.util.ArrayList; 4 | 5 | 6 | public class Parameter 7 | { 8 | 9 | //types 10 | /** 11 | * Indicates an integer parameter 12 | */ 13 | public static final int PARAM_TYPE_INT = 0; 14 | 15 | /** 16 | * Indicates an parameter 17 | */ 18 | public static final int PARAM_TYPE_ENUM = 1; 19 | 20 | /** 21 | * indicates a boolean parameter 22 | */ 23 | public static final int PARAM_TYPE_BOOL = 2; 24 | 25 | private String _name; 26 | private int _type; 27 | private ArrayList _values; 28 | private ArrayList _realValues; 29 | private ArrayList _bound; 30 | private ArrayList _groups; 31 | private boolean _boundary; 32 | private boolean _group; 33 | 34 | 35 | //constructor specifying the name, and initializing values and boundaries 36 | public Parameter(String name) 37 | { 38 | _name = name; 39 | _values = new ArrayList(); 40 | _bound = new ArrayList(); 41 | _groups = new ArrayList(); 42 | } 43 | 44 | //get type 45 | public int getType() 46 | { 47 | return _type; 48 | } 49 | 50 | //set type 51 | public void setType(int t) 52 | { 53 | _type = t; 54 | } 55 | 56 | //set name 57 | public String getName() 58 | { 59 | return _name; 60 | } 61 | 62 | //get if the parameter has or not boundaries specified, this property does not get the boundaries 63 | public boolean getBoundary() 64 | { 65 | return _boundary; 66 | } 67 | 68 | //set if the parameter has or not boundaries specified, this property does not set boundaries 69 | public void setBoundary(boolean b) 70 | { 71 | _boundary = b; 72 | } 73 | 74 | public boolean getGroup() 75 | { 76 | return _group; 77 | } 78 | 79 | public void setGroup(boolean b) 80 | { 81 | _group = b; 82 | } 83 | 84 | //Add a single value 85 | public void addValue(String v) 86 | { 87 | if (!_values.contains(v)) 88 | { 89 | _values.add(v); 90 | } 91 | } 92 | 93 | //remove a single value by value 94 | public void removeValue(String v) 95 | { 96 | _values.remove(v); 97 | } 98 | 99 | //remove a single value by index 100 | public void removeByIndex(int i) 101 | { 102 | _values.remove(i); 103 | } 104 | 105 | //remove all values 106 | public void removeAllValues() 107 | { 108 | _values = new ArrayList(); 109 | } 110 | 111 | //get the list of values 112 | public ArrayList getValues() 113 | { 114 | return _values; 115 | } 116 | 117 | //set the list of values for the parameter 118 | public void setValues(ArrayList v) 119 | { 120 | _values = v; 121 | } 122 | 123 | //get list of boundaries 124 | public ArrayList getBounds() 125 | { 126 | return _bound; 127 | } 128 | 129 | public ArrayList getGroups() 130 | { 131 | return _groups; 132 | } 133 | 134 | public void setGroups(ArrayList b) 135 | { 136 | _groups = b; 137 | } 138 | 139 | //add boundary 140 | public void addBound(Double i) 141 | { 142 | 143 | if (!_bound.contains(i)) 144 | { 145 | _bound.add(i); 146 | } 147 | 148 | } 149 | 150 | public void addGroup(Object i) 151 | { 152 | if (!_groups.contains(i)) 153 | { 154 | _groups.add(i); 155 | } 156 | } 157 | 158 | //remove boundary 159 | public void removeBound(Double b) 160 | { 161 | _bound.remove(b); 162 | } 163 | 164 | public void removeGroup(Object i) 165 | { 166 | _groups.remove(i); 167 | } 168 | 169 | //remove boundary by index 170 | public void removeBoundByIndex(int i) 171 | { 172 | _bound.remove(i); 173 | } 174 | 175 | //remove all boundaries 176 | public void removeAllBoundaries() 177 | { 178 | _bound = new ArrayList(); 179 | } 180 | 181 | public void removeAllGroups() 182 | { 183 | _groups = new ArrayList(); 184 | } 185 | 186 | //set list of boundaries 187 | public void setBoundaries(ArrayList b) 188 | { 189 | _bound = b; 190 | } 191 | 192 | //get original values, in case of using boundaries 193 | public ArrayList getValuesO() 194 | { 195 | return _realValues; 196 | } 197 | 198 | //set original values, in case of specifying boundaries 199 | public void setValuesO(ArrayList o) 200 | { 201 | _realValues = o; 202 | } 203 | 204 | //remove original values 205 | public void removeAllValuesO() 206 | { 207 | _realValues.clear(); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ParseException.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ 3 | /* JavaCCOptions:KEEP_LINE_COL=null */ 4 | /** 5 | * This exception is thrown when parse errors are encountered. 6 | * You can explicitly create objects of this exception type by 7 | * calling the method generateParseException in the generated 8 | * parser. 9 | * 10 | * You can modify this class to customize your error reporting 11 | * mechanisms so long as you retain the public fields. 12 | */ 13 | public class ParseException extends Exception { 14 | 15 | /** 16 | * The version identifier for this Serializable class. 17 | * Increment only if the serialized form of the 18 | * class changes. 19 | */ 20 | private static final long serialVersionUID = 1L; 21 | 22 | /** 23 | * This constructor is used by the method "generateParseException" 24 | * in the generated parser. Calling this constructor generates 25 | * a new object of this type with the fields "currentToken", 26 | * "expectedTokenSequences", and "tokenImage" set. 27 | */ 28 | public ParseException(Token currentTokenVal, 29 | int[][] expectedTokenSequencesVal, 30 | String[] tokenImageVal 31 | ) 32 | { 33 | super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); 34 | currentToken = currentTokenVal; 35 | expectedTokenSequences = expectedTokenSequencesVal; 36 | tokenImage = tokenImageVal; 37 | } 38 | 39 | /** 40 | * The following constructors are for use by you for whatever 41 | * purpose you can think of. Constructing the exception in this 42 | * manner makes the exception behave in the normal way - i.e., as 43 | * documented in the class "Throwable". The fields "errorToken", 44 | * "expectedTokenSequences", and "tokenImage" do not contain 45 | * relevant information. The JavaCC generated code does not use 46 | * these constructors. 47 | */ 48 | 49 | public ParseException() { 50 | super(); 51 | } 52 | 53 | /** Constructor with message. */ 54 | public ParseException(String message) { 55 | super(message); 56 | } 57 | 58 | 59 | /** 60 | * This is the last token that has been consumed successfully. If 61 | * this object has been created due to a parse error, the token 62 | * followng this token will (therefore) be the first error token. 63 | */ 64 | public Token currentToken; 65 | 66 | /** 67 | * Each entry in this array is an array of integers. Each array 68 | * of integers represents a sequence of tokens (by their ordinal 69 | * values) that is expected at this point of the parse. 70 | */ 71 | public int[][] expectedTokenSequences; 72 | 73 | /** 74 | * This is a reference to the "tokenImage" array of the generated 75 | * parser within which the parse error occurred. This array is 76 | * defined in the generated ...Constants interface. 77 | */ 78 | public String[] tokenImage; 79 | 80 | /** 81 | * It uses "currentToken" and "expectedTokenSequences" to generate a parse 82 | * error message and returns it. If this object has been created 83 | * due to a parse error, and you do not catch it (it gets thrown 84 | * from the parser) the correct error message 85 | * gets displayed. 86 | */ 87 | private static String initialise(Token currentToken, 88 | int[][] expectedTokenSequences, 89 | String[] tokenImage) { 90 | String eol = System.getProperty("line.separator", "\n"); 91 | StringBuffer expected = new StringBuffer(); 92 | int maxSize = 0; 93 | for (int i = 0; i < expectedTokenSequences.length; i++) { 94 | if (maxSize < expectedTokenSequences[i].length) { 95 | maxSize = expectedTokenSequences[i].length; 96 | } 97 | for (int j = 0; j < expectedTokenSequences[i].length; j++) { 98 | expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); 99 | } 100 | if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { 101 | expected.append("..."); 102 | } 103 | expected.append(eol).append(" "); 104 | } 105 | String retval = "Encountered \""; 106 | Token tok = currentToken.next; 107 | for (int i = 0; i < maxSize; i++) { 108 | if (i != 0) retval += " "; 109 | if (tok.kind == 0) { 110 | retval += tokenImage[0]; 111 | break; 112 | } 113 | retval += " " + tokenImage[tok.kind]; 114 | retval += " \""; 115 | retval += add_escapes(tok.image); 116 | retval += " \""; 117 | tok = tok.next; 118 | } 119 | retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; 120 | retval += "." + eol; 121 | if (expectedTokenSequences.length == 1) { 122 | retval += "Was expecting:" + eol + " "; 123 | } else { 124 | retval += "Was expecting one of:" + eol + " "; 125 | } 126 | retval += expected.toString(); 127 | return retval; 128 | } 129 | 130 | /** 131 | * The end of line string for this machine. 132 | */ 133 | protected String eol = System.getProperty("line.separator", "\n"); 134 | 135 | /** 136 | * Used to convert raw characters to their escaped version 137 | * when these raw version cannot be used as part of an ASCII 138 | * string literal. 139 | */ 140 | static String add_escapes(String str) { 141 | StringBuffer retval = new StringBuffer(); 142 | char ch; 143 | for (int i = 0; i < str.length(); i++) { 144 | switch (str.charAt(i)) 145 | { 146 | case 0 : 147 | continue; 148 | case '\b': 149 | retval.append("\\b"); 150 | continue; 151 | case '\t': 152 | retval.append("\\t"); 153 | continue; 154 | case '\n': 155 | retval.append("\\n"); 156 | continue; 157 | case '\f': 158 | retval.append("\\f"); 159 | continue; 160 | case '\r': 161 | retval.append("\\r"); 162 | continue; 163 | case '\"': 164 | retval.append("\\\""); 165 | continue; 166 | case '\'': 167 | retval.append("\\\'"); 168 | continue; 169 | case '\\': 170 | retval.append("\\\\"); 171 | continue; 172 | default: 173 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 174 | String s = "0000" + Integer.toString(ch, 16); 175 | retval.append("\\u" + s.substring(s.length() - 4, s.length())); 176 | } else { 177 | retval.append(ch); 178 | } 179 | continue; 180 | } 181 | } 182 | return retval.toString(); 183 | } 184 | 185 | } 186 | /* JavaCC - OriginalChecksum=e25b01bc55ed9d08151448657bb75b17 (do not edit this line) */ 187 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ReadOperation.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | import java.nio.file.StandardOpenOption; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | 9 | public abstract class ReadOperation implements Runnable 10 | { 11 | 12 | public static volatile boolean running; 13 | private static LinkedBlockingQueue buffer = new LinkedBlockingQueue(); 14 | 15 | final static private void consume() throws InterruptedException 16 | { 17 | Thread load_data = new Thread( 18 | new Runnable() 19 | { 20 | 21 | @Override 22 | public void run() 23 | { 24 | running = true; 25 | try 26 | { 27 | if (Main.logRT) 28 | { 29 | Files.write( 30 | Paths.get(Main.log_path), System.getProperty("line.separator").getBytes(), 31 | StandardOpenOption.APPEND 32 | ); 33 | Files.write( 34 | Paths.get(Main.log_path), System.getProperty("line.separator").getBytes(), 35 | StandardOpenOption.APPEND 36 | ); 37 | String title = "NEW TEST CASES:"; 38 | Files.write(Paths.get(Main.log_path), title.getBytes(), StandardOpenOption.APPEND); 39 | Files.write( 40 | Paths.get(Main.log_path), System.getProperty("line.separator").getBytes(), 41 | StandardOpenOption.APPEND 42 | ); 43 | Files.write( 44 | Paths.get(Main.log_path), System.getProperty("line.separator").getBytes(), 45 | StandardOpenOption.APPEND 46 | ); 47 | } 48 | 49 | } 50 | catch (IOException e1) 51 | { 52 | // TODO Auto-generated catch block 53 | e1.printStackTrace(); 54 | } 55 | 56 | Runtime.getRuntime().addShutdownHook( 57 | new Thread() 58 | { 59 | @Override 60 | public void run() 61 | { 62 | try 63 | { 64 | running = false; 65 | Thread.sleep(1000); 66 | for (int i = 0; i < 5; i++) 67 | { 68 | 69 | if (Main.tway_objects[i] != null) 70 | { 71 | try 72 | { 73 | Files.write( 74 | Paths.get(Main.log_path), System.getProperty( 75 | "line.separator" 76 | ) 77 | .getBytes(), 78 | StandardOpenOption.APPEND 79 | ); 80 | Files.write( 81 | Paths.get(Main.log_path), System.getProperty( 82 | "line.separator" 83 | ) 84 | .getBytes(), 85 | StandardOpenOption.APPEND 86 | ); 87 | String title = "\n\nNew " 88 | + (i + 2) 89 | + "-way invalid combinations: \n"; 90 | Files.write( 91 | Paths.get(Main.log_path), title.getBytes(), 92 | StandardOpenOption.APPEND 93 | ); 94 | Files.write( 95 | Paths.get(Main.log_path), System.getProperty( 96 | "line.separator" 97 | ) 98 | .getBytes(), 99 | StandardOpenOption.APPEND 100 | ); 101 | Files.write( 102 | Paths.get(Main.log_path), System.getProperty( 103 | "line.separator" 104 | ) 105 | .getBytes(), 106 | StandardOpenOption.APPEND 107 | ); 108 | for (String[][] str : Main.tway_objects[i].get_InvalidComb()) 109 | { 110 | boolean newinvalid = false; 111 | String invalidCombString = ""; 112 | for (int z = 0; z < str.length; z++) 113 | { 114 | String inval = str[z][0] + " = " + str[z][1] + " ; "; 115 | invalidCombString += inval; 116 | } 117 | if (!Main.initial_invalid.containsKey(invalidCombString)) 118 | { 119 | Files.write( 120 | Paths.get(Main.log_path), 121 | invalidCombString.getBytes(), 122 | StandardOpenOption.APPEND 123 | ); 124 | newinvalid = true; 125 | } 126 | if (newinvalid) 127 | { 128 | Files.write( 129 | Paths.get(Main.log_path), System.getProperty( 130 | "line.separator" 131 | ) 132 | .getBytes(), 133 | StandardOpenOption.APPEND 134 | ); 135 | } 136 | 137 | 138 | } 139 | Files.write( 140 | Paths.get(Main.log_path), System.getProperty( 141 | "line.separator" 142 | ) 143 | .getBytes(), 144 | StandardOpenOption.APPEND 145 | ); 146 | Files.write( 147 | Paths.get(Main.log_path), System.getProperty( 148 | "line.separator" 149 | ) 150 | .getBytes(), 151 | StandardOpenOption.APPEND 152 | ); 153 | 154 | 155 | } 156 | catch (IOException e) 157 | { 158 | 159 | } 160 | } 161 | } 162 | 163 | 164 | Files.write( 165 | Paths.get(Main.log_path), System.getProperty("line.separator") 166 | .getBytes(), 167 | StandardOpenOption.APPEND 168 | ); 169 | Files.write( 170 | Paths.get(Main.log_path), System.getProperty("line.separator") 171 | .getBytes(), 172 | StandardOpenOption.APPEND 173 | ); 174 | String title1 = "NEW T-WAY COVERAGE RESULTS:"; 175 | Files.write( 176 | Paths.get(Main.log_path), title1.getBytes(), 177 | StandardOpenOption.APPEND 178 | ); 179 | Files.write( 180 | Paths.get(Main.log_path), System.getProperty("line.separator") 181 | .getBytes(), 182 | StandardOpenOption.APPEND 183 | ); 184 | Files.write( 185 | Paths.get(Main.log_path), System.getProperty("line.separator") 186 | .getBytes(), 187 | StandardOpenOption.APPEND 188 | ); 189 | 190 | for (int i = 0; i < 5; i++) 191 | { 192 | if (Main.tway_objects[i] != null) 193 | { 194 | 195 | String title = ""; 196 | switch (i) 197 | { 198 | 199 | case 0: 200 | title = Main.real_time_cmd_results[0]; 201 | break; 202 | case 1: 203 | title = Main.real_time_cmd_results[1]; 204 | break; 205 | case 2: 206 | title = Main.real_time_cmd_results[2]; 207 | break; 208 | case 3: 209 | title = Main.real_time_cmd_results[3]; 210 | break; 211 | case 4: 212 | title = Main.real_time_cmd_results[4]; 213 | break; 214 | } 215 | Files.write( 216 | Paths.get(Main.log_path), title.getBytes(), 217 | StandardOpenOption.APPEND 218 | ); 219 | Files.write( 220 | Paths.get(Main.log_path), 221 | System.getProperty("line.separator").getBytes(), 222 | StandardOpenOption.APPEND 223 | ); 224 | 225 | } 226 | } 227 | } 228 | catch (IOException | InterruptedException e) 229 | { 230 | // TODO Auto-generated catch block 231 | e.printStackTrace(); 232 | } 233 | 234 | } 235 | } 236 | ); 237 | 238 | 239 | while (true) 240 | { 241 | String input; 242 | try 243 | { 244 | input = buffer.take(); 245 | Main.real_time_buffer_size = buffer.size(); 246 | int position = Main.nrows; 247 | if (Main.nrows < 1) 248 | { 249 | Main.infile = new String[1]; 250 | Main.test = new int[1][]; 251 | Main.max_array_size = 0; 252 | } 253 | if (position == Main.max_array_size) 254 | { 255 | 256 | if (Main.max_array_size < 1000) 257 | { 258 | Main.max_array_size = 1000; 259 | Main.test = new int[Main.max_array_size][]; 260 | Main.infile = new String[Main.max_array_size]; 261 | 262 | } 263 | else 264 | { 265 | Main.test = new int[Main.test.length][]; 266 | Main.infile = new String[Main.infile.length]; 267 | } 268 | position = 0; 269 | System.gc(); 270 | 271 | } 272 | 273 | Main.infile[position] = input; 274 | Main.test[position] = new int[Main.ncols]; 275 | Main.nrows = position + 1; 276 | int status = Main.setupFile(position); 277 | if (status == -1) 278 | { 279 | continue; 280 | } 281 | else if (status != 0) 282 | { 283 | System.out.println("Error: Something went wrong.\nExiting...\n"); 284 | System.exit(status); 285 | } 286 | 287 | while (java.lang.Thread.activeCount() > Main.threadmax) 288 | { 289 | System.out.println("Exceeded maximum threads specified... Waiting..."); 290 | Thread.sleep(1000); 291 | } 292 | 293 | for (int i = 0; i < 5; i++) 294 | { 295 | if (Main.tway_objects[i] != null) 296 | { 297 | switch (i) 298 | { 299 | case 0: 300 | Main.Tway("2way"); 301 | Main.tway_threads[0]++; 302 | break; 303 | case 1: 304 | Main.Tway("3way"); 305 | Main.tway_threads[1]++; 306 | break; 307 | case 2: 308 | Main.Tway("4way"); 309 | Main.tway_threads[2]++; 310 | break; 311 | case 3: 312 | Main.Tway("5way"); 313 | Main.tway_threads[3]++; 314 | break; 315 | case 4: 316 | Main.Tway("6way"); 317 | Main.tway_threads[4]++; 318 | break; 319 | } 320 | } 321 | } 322 | 323 | if (Main.logRT) 324 | { 325 | if (running) 326 | { 327 | try 328 | { 329 | Files.write( 330 | Paths.get(Main.log_path), input.getBytes(), 331 | StandardOpenOption.APPEND 332 | ); 333 | Files.write( 334 | Paths.get(Main.log_path), System.getProperty("line.separator") 335 | .getBytes(), 336 | StandardOpenOption.APPEND 337 | ); 338 | } 339 | catch (IOException e) 340 | { 341 | // TODO Auto-generated catch block 342 | e.printStackTrace(); 343 | } 344 | } 345 | 346 | } 347 | 348 | } 349 | catch (InterruptedException e) 350 | { 351 | // TODO Auto-generated catch block 352 | e.printStackTrace(); 353 | } 354 | } 355 | 356 | } 357 | 358 | } 359 | ); 360 | load_data.start(); 361 | 362 | } 363 | 364 | final protected void produce(String s) 365 | { 366 | buffer.add(s); 367 | } 368 | 369 | public abstract void readData(); 370 | 371 | @Override 372 | public void run() 373 | { 374 | try 375 | { 376 | consume(); 377 | readData(); 378 | running = true; 379 | } 380 | catch (InterruptedException e) 381 | { 382 | // TODO Auto-generated catch block 383 | e.printStackTrace(); 384 | } 385 | 386 | } 387 | 388 | } 389 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ReadProgramOutputOperation.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | 8 | public class ReadProgramOutputOperation extends ReadOperation 9 | { 10 | 11 | 12 | @Override 13 | public void readData() 14 | { 15 | Runtime rt = Runtime.getRuntime(); 16 | String[] commands = null; 17 | if (Main.rtExPath.endsWith(".jar")) 18 | { 19 | commands = new String[Main.rtExArgs.size() + 3]; 20 | commands[0] = "java"; 21 | commands[1] = "-jar"; 22 | commands[2] = Main.rtExPath; 23 | File f = new File(commands[2]); 24 | if (!(f.exists() && !f.isDirectory())) 25 | { 26 | //file doesn't exist 27 | System.out.println("No executable program found at: " + commands[2]); 28 | System.exit(0); 29 | } 30 | for (int i = 3; i < commands.length; i++) 31 | { 32 | commands[i] = Main.rtExArgs.get(i - 3); 33 | } 34 | } 35 | else if (Main.rtExPath.endsWith(".exe")) 36 | { 37 | commands = new String[Main.rtExArgs.size() + 1]; 38 | commands[0] = Main.rtExPath; 39 | File f = new File(commands[0]); 40 | if (!(f.exists() && !f.isDirectory())) 41 | { 42 | //file doesn't exist 43 | System.out.println("No executable program found at: " + commands[0]); 44 | System.exit(0); 45 | } 46 | for (int i = 1; i < commands.length; i++) 47 | { 48 | commands[i] = Main.rtExArgs.get(i - 1); 49 | } 50 | } 51 | 52 | 53 | Process proc; 54 | 55 | try 56 | { 57 | proc = rt.exec(commands); 58 | Runtime.getRuntime().addShutdownHook( 59 | new Thread() 60 | { 61 | @Override 62 | public void run() 63 | { 64 | System.gc(); 65 | proc.destroy(); 66 | } 67 | } 68 | ); 69 | BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); 70 | String s = ""; 71 | while (true) 72 | { 73 | s = stdInput.readLine(); 74 | if (s == null) 75 | { 76 | continue; 77 | } 78 | else 79 | { 80 | if (s.replaceAll("\\s", "").trim().split(",").length != Main.ncols) 81 | { 82 | System.out.println("Incorrect number of parameters..."); 83 | System.out.print(s + " - Expected columns = " + Main.ncols); 84 | continue; 85 | } 86 | produce(s); 87 | } 88 | } 89 | } 90 | catch (IOException e) 91 | { 92 | // TODO Auto-generated catch block 93 | e.printStackTrace(); 94 | } 95 | 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ReadStandardInputOperation.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ReadStandardInputOperation extends ReadOperation 6 | { 7 | 8 | private Scanner input_scanner; 9 | 10 | @Override 11 | public void readData() 12 | { 13 | input_scanner = new Scanner(System.in); 14 | while (true) 15 | { 16 | try 17 | { 18 | String inputLine = input_scanner.nextLine(); 19 | if (inputLine.replaceAll("\\s", "").trim().split(",").length != Main.ncols) 20 | { 21 | System.out.println("Incorrect number of parameters..."); 22 | continue; 23 | } 24 | produce(inputLine); 25 | } 26 | catch (Exception ex) 27 | { 28 | //do nothing for now... 29 | } 30 | 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/ReadTCPInputOperation.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.net.ServerSocket; 7 | import java.net.Socket; 8 | 9 | public class ReadTCPInputOperation extends ReadOperation 10 | { 11 | 12 | private ServerSocket initial; 13 | 14 | @Override 15 | public void readData() 16 | { 17 | try 18 | { 19 | String inputLine = ""; 20 | initial = new ServerSocket(Main.tcp_port); 21 | while (true) 22 | { 23 | Socket connection = initial.accept(); 24 | BufferedReader dataStream = new BufferedReader(new InputStreamReader(connection.getInputStream())); 25 | inputLine = dataStream.readLine(); 26 | System.out.println("Received: " + inputLine); 27 | if (inputLine == null) 28 | { 29 | continue; 30 | } 31 | else 32 | { 33 | if (inputLine.replaceAll("\\s", "").trim().split(",").length != Main.ncols) 34 | { 35 | System.out.println("Incorrect number of parameters..."); 36 | System.out.print(inputLine + " - Expected columns = " + Main.ncols); 37 | continue; 38 | } 39 | produce(inputLine); 40 | } 41 | } 42 | } 43 | catch (IOException e) 44 | { 45 | // TODO Auto-generated catch block 46 | e.printStackTrace(); 47 | } 48 | 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/SimpleCharStream.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ 3 | /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 4 | /** 5 | * An implementation of interface CharStream, where the stream is assumed to 6 | * contain only ASCII characters (without unicode processing). 7 | */ 8 | 9 | public class SimpleCharStream 10 | { 11 | /** Whether parser is static. */ 12 | public static final boolean staticFlag = false; 13 | int bufsize; 14 | int available; 15 | int tokenBegin; 16 | /** Position in buffer. */ 17 | public int bufpos = -1; 18 | protected int bufline[]; 19 | protected int bufcolumn[]; 20 | 21 | protected int column = 0; 22 | protected int line = 1; 23 | 24 | protected boolean prevCharIsCR = false; 25 | protected boolean prevCharIsLF = false; 26 | 27 | protected java.io.Reader inputStream; 28 | 29 | protected char[] buffer; 30 | protected int maxNextCharInd = 0; 31 | protected int inBuf = 0; 32 | protected int tabSize = 8; 33 | 34 | protected void setTabSize(int i) { tabSize = i; } 35 | protected int getTabSize(int i) { return tabSize; } 36 | 37 | 38 | protected void ExpandBuff(boolean wrapAround) 39 | { 40 | char[] newbuffer = new char[bufsize + 2048]; 41 | int newbufline[] = new int[bufsize + 2048]; 42 | int newbufcolumn[] = new int[bufsize + 2048]; 43 | 44 | try 45 | { 46 | if (wrapAround) 47 | { 48 | System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); 49 | System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); 50 | buffer = newbuffer; 51 | 52 | System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); 53 | System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); 54 | bufline = newbufline; 55 | 56 | System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); 57 | System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); 58 | bufcolumn = newbufcolumn; 59 | 60 | maxNextCharInd = (bufpos += (bufsize - tokenBegin)); 61 | } 62 | else 63 | { 64 | System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); 65 | buffer = newbuffer; 66 | 67 | System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); 68 | bufline = newbufline; 69 | 70 | System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); 71 | bufcolumn = newbufcolumn; 72 | 73 | maxNextCharInd = (bufpos -= tokenBegin); 74 | } 75 | } 76 | catch (Throwable t) 77 | { 78 | throw new Error(t.getMessage()); 79 | } 80 | 81 | 82 | bufsize += 2048; 83 | available = bufsize; 84 | tokenBegin = 0; 85 | } 86 | 87 | protected void FillBuff() throws java.io.IOException 88 | { 89 | if (maxNextCharInd == available) 90 | { 91 | if (available == bufsize) 92 | { 93 | if (tokenBegin > 2048) 94 | { 95 | bufpos = maxNextCharInd = 0; 96 | available = tokenBegin; 97 | } 98 | else if (tokenBegin < 0) 99 | bufpos = maxNextCharInd = 0; 100 | else 101 | ExpandBuff(false); 102 | } 103 | else if (available > tokenBegin) 104 | available = bufsize; 105 | else if ((tokenBegin - available) < 2048) 106 | ExpandBuff(true); 107 | else 108 | available = tokenBegin; 109 | } 110 | 111 | int i; 112 | try { 113 | if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) 114 | { 115 | inputStream.close(); 116 | throw new java.io.IOException(); 117 | } 118 | else 119 | maxNextCharInd += i; 120 | return; 121 | } 122 | catch(java.io.IOException e) { 123 | --bufpos; 124 | backup(0); 125 | if (tokenBegin == -1) 126 | tokenBegin = bufpos; 127 | throw e; 128 | } 129 | } 130 | 131 | /** Start. */ 132 | public char BeginToken() throws java.io.IOException 133 | { 134 | tokenBegin = -1; 135 | char c = readChar(); 136 | tokenBegin = bufpos; 137 | 138 | return c; 139 | } 140 | 141 | protected void UpdateLineColumn(char c) 142 | { 143 | column++; 144 | 145 | if (prevCharIsLF) 146 | { 147 | prevCharIsLF = false; 148 | line += (column = 1); 149 | } 150 | else if (prevCharIsCR) 151 | { 152 | prevCharIsCR = false; 153 | if (c == '\n') 154 | { 155 | prevCharIsLF = true; 156 | } 157 | else 158 | line += (column = 1); 159 | } 160 | 161 | switch (c) 162 | { 163 | case '\r' : 164 | prevCharIsCR = true; 165 | break; 166 | case '\n' : 167 | prevCharIsLF = true; 168 | break; 169 | case '\t' : 170 | column--; 171 | column += (tabSize - (column % tabSize)); 172 | break; 173 | default : 174 | break; 175 | } 176 | 177 | bufline[bufpos] = line; 178 | bufcolumn[bufpos] = column; 179 | } 180 | 181 | /** Read a character. */ 182 | public char readChar() throws java.io.IOException 183 | { 184 | if (inBuf > 0) 185 | { 186 | --inBuf; 187 | 188 | if (++bufpos == bufsize) 189 | bufpos = 0; 190 | 191 | return buffer[bufpos]; 192 | } 193 | 194 | if (++bufpos >= maxNextCharInd) 195 | FillBuff(); 196 | 197 | char c = buffer[bufpos]; 198 | 199 | UpdateLineColumn(c); 200 | return c; 201 | } 202 | 203 | @Deprecated 204 | /** 205 | * @deprecated 206 | * @see #getEndColumn 207 | */ 208 | 209 | public int getColumn() { 210 | return bufcolumn[bufpos]; 211 | } 212 | 213 | @Deprecated 214 | /** 215 | * @deprecated 216 | * @see #getEndLine 217 | */ 218 | 219 | public int getLine() { 220 | return bufline[bufpos]; 221 | } 222 | 223 | /** Get token end column number. */ 224 | public int getEndColumn() { 225 | return bufcolumn[bufpos]; 226 | } 227 | 228 | /** Get token end line number. */ 229 | public int getEndLine() { 230 | return bufline[bufpos]; 231 | } 232 | 233 | /** Get token beginning column number. */ 234 | public int getBeginColumn() { 235 | return bufcolumn[tokenBegin]; 236 | } 237 | 238 | /** Get token beginning line number. */ 239 | public int getBeginLine() { 240 | return bufline[tokenBegin]; 241 | } 242 | 243 | /** Backup a number of characters. */ 244 | public void backup(int amount) { 245 | 246 | inBuf += amount; 247 | if ((bufpos -= amount) < 0) 248 | bufpos += bufsize; 249 | } 250 | 251 | /** Constructor. */ 252 | public SimpleCharStream(java.io.Reader dstream, int startline, 253 | int startcolumn, int buffersize) 254 | { 255 | inputStream = dstream; 256 | line = startline; 257 | column = startcolumn - 1; 258 | 259 | available = bufsize = buffersize; 260 | buffer = new char[buffersize]; 261 | bufline = new int[buffersize]; 262 | bufcolumn = new int[buffersize]; 263 | } 264 | 265 | /** Constructor. */ 266 | public SimpleCharStream(java.io.Reader dstream, int startline, 267 | int startcolumn) 268 | { 269 | this(dstream, startline, startcolumn, 4096); 270 | } 271 | 272 | /** Constructor. */ 273 | public SimpleCharStream(java.io.Reader dstream) 274 | { 275 | this(dstream, 1, 1, 4096); 276 | } 277 | 278 | /** Reinitialise. */ 279 | public void ReInit(java.io.Reader dstream, int startline, 280 | int startcolumn, int buffersize) 281 | { 282 | inputStream = dstream; 283 | line = startline; 284 | column = startcolumn - 1; 285 | 286 | if (buffer == null || buffersize != buffer.length) 287 | { 288 | available = bufsize = buffersize; 289 | buffer = new char[buffersize]; 290 | bufline = new int[buffersize]; 291 | bufcolumn = new int[buffersize]; 292 | } 293 | prevCharIsLF = prevCharIsCR = false; 294 | tokenBegin = inBuf = maxNextCharInd = 0; 295 | bufpos = -1; 296 | } 297 | 298 | /** Reinitialise. */ 299 | public void ReInit(java.io.Reader dstream, int startline, 300 | int startcolumn) 301 | { 302 | ReInit(dstream, startline, startcolumn, 4096); 303 | } 304 | 305 | /** Reinitialise. */ 306 | public void ReInit(java.io.Reader dstream) 307 | { 308 | ReInit(dstream, 1, 1, 4096); 309 | } 310 | /** Constructor. */ 311 | public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, 312 | int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException 313 | { 314 | this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); 315 | } 316 | 317 | /** Constructor. */ 318 | public SimpleCharStream(java.io.InputStream dstream, int startline, 319 | int startcolumn, int buffersize) 320 | { 321 | this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); 322 | } 323 | 324 | /** Constructor. */ 325 | public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, 326 | int startcolumn) throws java.io.UnsupportedEncodingException 327 | { 328 | this(dstream, encoding, startline, startcolumn, 4096); 329 | } 330 | 331 | /** Constructor. */ 332 | public SimpleCharStream(java.io.InputStream dstream, int startline, 333 | int startcolumn) 334 | { 335 | this(dstream, startline, startcolumn, 4096); 336 | } 337 | 338 | /** Constructor. */ 339 | public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException 340 | { 341 | this(dstream, encoding, 1, 1, 4096); 342 | } 343 | 344 | /** Constructor. */ 345 | public SimpleCharStream(java.io.InputStream dstream) 346 | { 347 | this(dstream, 1, 1, 4096); 348 | } 349 | 350 | /** Reinitialise. */ 351 | public void ReInit(java.io.InputStream dstream, String encoding, int startline, 352 | int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException 353 | { 354 | ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); 355 | } 356 | 357 | /** Reinitialise. */ 358 | public void ReInit(java.io.InputStream dstream, int startline, 359 | int startcolumn, int buffersize) 360 | { 361 | ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); 362 | } 363 | 364 | /** Reinitialise. */ 365 | public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException 366 | { 367 | ReInit(dstream, encoding, 1, 1, 4096); 368 | } 369 | 370 | /** Reinitialise. */ 371 | public void ReInit(java.io.InputStream dstream) 372 | { 373 | ReInit(dstream, 1, 1, 4096); 374 | } 375 | /** Reinitialise. */ 376 | public void ReInit(java.io.InputStream dstream, String encoding, int startline, 377 | int startcolumn) throws java.io.UnsupportedEncodingException 378 | { 379 | ReInit(dstream, encoding, startline, startcolumn, 4096); 380 | } 381 | /** Reinitialise. */ 382 | public void ReInit(java.io.InputStream dstream, int startline, 383 | int startcolumn) 384 | { 385 | ReInit(dstream, startline, startcolumn, 4096); 386 | } 387 | /** Get token literal value. */ 388 | public String GetImage() 389 | { 390 | if (bufpos >= tokenBegin) 391 | return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); 392 | else 393 | return new String(buffer, tokenBegin, bufsize - tokenBegin) + 394 | new String(buffer, 0, bufpos + 1); 395 | } 396 | 397 | /** Get the suffix. */ 398 | public char[] GetSuffix(int len) 399 | { 400 | char[] ret = new char[len]; 401 | 402 | if ((bufpos + 1) >= len) 403 | System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); 404 | else 405 | { 406 | System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, 407 | len - bufpos - 1); 408 | System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); 409 | } 410 | 411 | return ret; 412 | } 413 | 414 | /** Reset buffer when finished. */ 415 | public void Done() 416 | { 417 | buffer = null; 418 | bufline = null; 419 | bufcolumn = null; 420 | } 421 | 422 | /** 423 | * Method to adjust line and column numbers for the start of a token. 424 | */ 425 | public void adjustBeginLineColumn(int newLine, int newCol) 426 | { 427 | int start = tokenBegin; 428 | int len; 429 | 430 | if (bufpos >= tokenBegin) 431 | { 432 | len = bufpos - tokenBegin + inBuf + 1; 433 | } 434 | else 435 | { 436 | len = bufsize - tokenBegin + bufpos + 1 + inBuf; 437 | } 438 | 439 | int i = 0, j = 0, k = 0; 440 | int nextColDiff = 0, columnDiff = 0; 441 | 442 | while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) 443 | { 444 | bufline[j] = newLine; 445 | nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; 446 | bufcolumn[j] = newCol + columnDiff; 447 | columnDiff = nextColDiff; 448 | i++; 449 | } 450 | 451 | if (i < len) 452 | { 453 | bufline[j] = newLine++; 454 | bufcolumn[j] = newCol + columnDiff; 455 | 456 | while (i++ < len) 457 | { 458 | if (bufline[j = start % bufsize] != bufline[++start % bufsize]) 459 | bufline[j] = newLine++; 460 | else 461 | bufline[j] = newLine; 462 | } 463 | } 464 | 465 | line = bufline[j]; 466 | column = bufcolumn[j]; 467 | } 468 | 469 | } 470 | /* JavaCC - OriginalChecksum=1762155621dcf186e296018042785792 (do not edit this line) */ 471 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/TestData.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class TestData 7 | { 8 | public static volatile String[][] tests; 9 | private volatile static int number_of_rows = 0; 10 | private static int number_of_columns; 11 | private boolean paramNames; 12 | private boolean acts_file_present; 13 | private boolean constraints_file_present; 14 | private List parameters; 15 | private List constraints; 16 | 17 | public TestData() 18 | { 19 | parameters = new ArrayList(); 20 | constraints = new ArrayList(); 21 | } 22 | 23 | public static int get_rows() 24 | { 25 | return number_of_rows; 26 | } 27 | 28 | public static void set_rows(int rows) 29 | { 30 | number_of_rows = rows; 31 | } 32 | 33 | public static int get_columns() 34 | { 35 | return number_of_columns; 36 | } 37 | 38 | public void set_columns(int columns) 39 | { 40 | number_of_columns = columns; 41 | } 42 | 43 | public void set_paramNames(boolean b) 44 | { 45 | paramNames = b; 46 | } 47 | 48 | public void set_acts_file_present(boolean b) 49 | { 50 | acts_file_present = b; 51 | } 52 | 53 | public void set_constraints_file_present(boolean b) 54 | { 55 | constraints_file_present = true; 56 | } 57 | 58 | public boolean isActsFilePresent() 59 | { 60 | return acts_file_present; 61 | } 62 | 63 | public boolean isConstraintsFilePresent() 64 | { 65 | return constraints_file_present; 66 | } 67 | 68 | public boolean hasParamNames() 69 | { 70 | return paramNames; 71 | } 72 | 73 | public void add_parameter(Parameter p) 74 | { 75 | parameters.add(p); 76 | } 77 | 78 | public List get_parameters() 79 | { 80 | return parameters; 81 | } 82 | 83 | 84 | public List get_constraints() 85 | { 86 | return constraints; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/Token.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ 3 | /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 4 | /** 5 | * Describes the input token stream. 6 | */ 7 | 8 | public class Token implements java.io.Serializable { 9 | 10 | /** 11 | * The version identifier for this Serializable class. 12 | * Increment only if the serialized form of the 13 | * class changes. 14 | */ 15 | private static final long serialVersionUID = 1L; 16 | 17 | /** 18 | * An integer that describes the kind of this token. This numbering 19 | * system is determined by JavaCCParser, and a table of these numbers is 20 | * stored in the file ...Constants.java. 21 | */ 22 | public int kind; 23 | 24 | /** The line number of the first character of this Token. */ 25 | public int beginLine; 26 | /** The column number of the first character of this Token. */ 27 | public int beginColumn; 28 | /** The line number of the last character of this Token. */ 29 | public int endLine; 30 | /** The column number of the last character of this Token. */ 31 | public int endColumn; 32 | 33 | /** 34 | * The string image of the token. 35 | */ 36 | public String image; 37 | 38 | /** 39 | * A reference to the next regular (non-special) token from the input 40 | * stream. If this is the last token from the input stream, or if the 41 | * token manager has not read tokens beyond this one, this field is 42 | * set to null. This is true only if this token is also a regular 43 | * token. Otherwise, see below for a description of the contents of 44 | * this field. 45 | */ 46 | public Token next; 47 | 48 | /** 49 | * This field is used to access special tokens that occur prior to this 50 | * token, but after the immediately preceding regular (non-special) token. 51 | * If there are no such special tokens, this field is set to null. 52 | * When there are more than one such special token, this field refers 53 | * to the last of these special tokens, which in turn refers to the next 54 | * previous special token through its specialToken field, and so on 55 | * until the first special token (whose specialToken field is null). 56 | * The next fields of special tokens refer to other special tokens that 57 | * immediately follow it (without an intervening regular token). If there 58 | * is no such token, this field is null. 59 | */ 60 | public Token specialToken; 61 | 62 | /** 63 | * An optional attribute value of the Token. 64 | * Tokens which are not used as syntactic sugar will often contain 65 | * meaningful values that will be used later on by the compiler or 66 | * interpreter. This attribute value is often different from the image. 67 | * Any subclass of Token that actually wants to return a non-null value can 68 | * override this method as appropriate. 69 | */ 70 | public Object getValue() { 71 | return null; 72 | } 73 | 74 | /** 75 | * No-argument constructor 76 | */ 77 | public Token() {} 78 | 79 | /** 80 | * Constructs a new token for the specified Image. 81 | */ 82 | public Token(int kind) 83 | { 84 | this(kind, null); 85 | } 86 | 87 | /** 88 | * Constructs a new token for the specified Image and Kind. 89 | */ 90 | public Token(int kind, String image) 91 | { 92 | this.kind = kind; 93 | this.image = image; 94 | } 95 | 96 | /** 97 | * Returns the image. 98 | */ 99 | @Override 100 | public String toString() 101 | { 102 | return image; 103 | } 104 | 105 | /** 106 | * Returns a new Token object, by default. However, if you want, you 107 | * can create and return subclass objects based on the value of ofKind. 108 | * Simply add the cases to the switch for all those special cases. 109 | * For example, if you have a subclass of Token called IDToken that 110 | * you want to create if ofKind is ID, simply add something like : 111 | * 112 | * case MyParserConstants.ID : return new IDToken(ofKind, image); 113 | * 114 | * to the following switch statement. Then you can cast matchedToken 115 | * variable to the appropriate type and use sit in your lexical actions. 116 | */ 117 | public static Token newToken(int ofKind, String image) 118 | { 119 | switch(ofKind) 120 | { 121 | default : return new Token(ofKind, image); 122 | } 123 | } 124 | 125 | public static Token newToken(int ofKind) 126 | { 127 | return newToken(ofKind, null); 128 | } 129 | 130 | } 131 | /* JavaCC - OriginalChecksum=8d60e82dee1a74a4649ef9bd48c36c1f (do not edit this line) */ 132 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/TokenMgrError.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ 3 | /* JavaCCOptions: */ 4 | /** Token Manager Error. */ 5 | public class TokenMgrError extends Error 6 | { 7 | 8 | /** 9 | * The version identifier for this Serializable class. 10 | * Increment only if the serialized form of the 11 | * class changes. 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | /* 16 | * Ordinals for various reasons why an Error of this type can be thrown. 17 | */ 18 | 19 | /** 20 | * Lexical error occurred. 21 | */ 22 | static final int LEXICAL_ERROR = 0; 23 | 24 | /** 25 | * An attempt was made to create a second instance of a static token manager. 26 | */ 27 | static final int STATIC_LEXER_ERROR = 1; 28 | 29 | /** 30 | * Tried to change to an invalid lexical state. 31 | */ 32 | static final int INVALID_LEXICAL_STATE = 2; 33 | 34 | /** 35 | * Detected (and bailed out of) an infinite loop in the token manager. 36 | */ 37 | static final int LOOP_DETECTED = 3; 38 | 39 | /** 40 | * Indicates the reason why the exception is thrown. It will have 41 | * one of the above 4 values. 42 | */ 43 | int errorCode; 44 | 45 | /** 46 | * Replaces unprintable characters by their escaped (or unicode escaped) 47 | * equivalents in the given string 48 | */ 49 | protected static final String addEscapes(String str) { 50 | StringBuffer retval = new StringBuffer(); 51 | char ch; 52 | for (int i = 0; i < str.length(); i++) { 53 | switch (str.charAt(i)) 54 | { 55 | case 0 : 56 | continue; 57 | case '\b': 58 | retval.append("\\b"); 59 | continue; 60 | case '\t': 61 | retval.append("\\t"); 62 | continue; 63 | case '\n': 64 | retval.append("\\n"); 65 | continue; 66 | case '\f': 67 | retval.append("\\f"); 68 | continue; 69 | case '\r': 70 | retval.append("\\r"); 71 | continue; 72 | case '\"': 73 | retval.append("\\\""); 74 | continue; 75 | case '\'': 76 | retval.append("\\\'"); 77 | continue; 78 | case '\\': 79 | retval.append("\\\\"); 80 | continue; 81 | default: 82 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 83 | String s = "0000" + Integer.toString(ch, 16); 84 | retval.append("\\u" + s.substring(s.length() - 4, s.length())); 85 | } else { 86 | retval.append(ch); 87 | } 88 | continue; 89 | } 90 | } 91 | return retval.toString(); 92 | } 93 | 94 | /** 95 | * Returns a detailed message for the Error when it is thrown by the 96 | * token manager to indicate a lexical error. 97 | * Parameters : 98 | * EOFSeen : indicates if EOF caused the lexical error 99 | * curLexState : lexical state in which this error occurred 100 | * errorLine : line number when the error occurred 101 | * errorColumn : column number when the error occurred 102 | * errorAfter : prefix that was seen before this error occurred 103 | * curchar : the offending character 104 | * Note: You can customize the lexical error message by modifying this method. 105 | */ 106 | protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 107 | return("Lexical error at line " + 108 | errorLine + ", column " + 109 | errorColumn + ". Encountered: " + 110 | (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 111 | "after : \"" + addEscapes(errorAfter) + "\""); 112 | } 113 | 114 | /** 115 | * You can also modify the body of this method to customize your error messages. 116 | * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not 117 | * of end-users concern, so you can return something like : 118 | * 119 | * "Internal Error : Please file a bug report .... " 120 | * 121 | * from this method for such cases in the release version of your parser. 122 | */ 123 | @Override 124 | public String getMessage() { 125 | return super.getMessage(); 126 | } 127 | 128 | /* 129 | * Constructors of various flavors follow. 130 | */ 131 | 132 | /** No arg constructor. */ 133 | public TokenMgrError() { 134 | } 135 | 136 | /** Constructor with message and reason. */ 137 | public TokenMgrError(String message, int reason) { 138 | super(message); 139 | errorCode = reason; 140 | } 141 | 142 | /** Full Constructor. */ 143 | public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 144 | this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 145 | } 146 | } 147 | /* JavaCC - OriginalChecksum=f617b0103aabf7650bc48f1badde308c (do not edit this line) */ 148 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/Tools.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import java.util.Arrays; 4 | 5 | 6 | public class Tools 7 | { 8 | 9 | 10 | //operator for constraints 11 | public static String[] ArithmeticsOperators = {"+", "-", "*", "%", "/"}; 12 | public static String[] RelationalOperators = {"!=", ">=", "<=", ">", "<", "="}; 13 | public static String[] BooleanOperators = {"&&", "||", "=>", "!"}; 14 | public static String[] GroupOperators = {"(", ")"}; 15 | 16 | 17 | //know if the string is numeric 18 | public static Boolean isNumeric(String text) 19 | { 20 | //This checks for negative numbers... 21 | if (text.startsWith("-")) 22 | { 23 | text = text.substring(1, text.length()); 24 | } 25 | 26 | for (char c : text.toCharArray()) 27 | { 28 | if (!Character.isDigit(c)) 29 | { 30 | return false; 31 | } 32 | } 33 | return true; 34 | } 35 | 36 | 37 | //take off all quotations from a string 38 | public static String WithoutQuoations(String text) 39 | { 40 | text = text.replace("\"", ""); 41 | return text; 42 | } 43 | 44 | //remove extra quotations 45 | public static String CleanString(String str) 46 | { 47 | String rvalue = ""; 48 | 49 | if (str.startsWith("\"")) 50 | { 51 | str = str.substring(1); 52 | } 53 | if (str.endsWith("\"")) 54 | { 55 | str.substring(0, str.length() - 1); 56 | } 57 | 58 | Boolean ant = false; 59 | 60 | for (char c : str.toCharArray()) 61 | { 62 | if (c == '"' && ant == false) 63 | { 64 | ant = true; 65 | } 66 | else 67 | { 68 | rvalue = rvalue + c; 69 | ant = false; 70 | } 71 | } 72 | 73 | 74 | return rvalue; 75 | } 76 | 77 | //find out if parameter a is inside b and c 78 | public static Boolean InsideBoundary(Double a, Double b, Double c) 79 | { 80 | if (a <= b && a > c) 81 | { 82 | return true; 83 | } 84 | else 85 | { 86 | return false; 87 | } 88 | } 89 | 90 | //find out if the element[array] is inside the array[array of arrays] 91 | public static Boolean findInArray(Object[][] array, Object[] element) 92 | { 93 | for (int i = 0; i < array.length; i++) 94 | { 95 | if (Arrays.equals(array[i], element)) 96 | { 97 | return true; 98 | } 99 | 100 | } 101 | return false; 102 | 103 | } 104 | 105 | 106 | } 107 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/TypeInfo.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | 4 | import choco.Choco; 5 | import choco.kernel.model.constraints.Constraint; 6 | import choco.kernel.model.variables.Variable; 7 | import choco.kernel.model.variables.integer.IntegerExpressionVariable; 8 | 9 | 10 | /* 11 | * This class is used for type checking in constraint parser. 12 | */ 13 | public class TypeInfo 14 | { 15 | 16 | int type; 17 | private String text; 18 | private Constraint constraint; 19 | private IntegerExpressionVariable variable; 20 | private Object obj; 21 | 22 | public int getType() 23 | { 24 | return type; 25 | } 26 | 27 | public void setType(int type) 28 | { 29 | this.type = type; 30 | } 31 | 32 | public String getText() 33 | { 34 | return text; 35 | } 36 | 37 | public void setText(String text) 38 | { 39 | this.text = text; 40 | } 41 | 42 | public Constraint getConstraint() 43 | { 44 | if (this.constraint == null && variable != null && type == Constants.TYPE_BOOL) 45 | { 46 | this.constraint = Choco.eq(variable, 1);// this is important to promote a boolean variable to a constraint!! 47 | } 48 | return this.constraint; 49 | } 50 | 51 | public void setConstraint(Constraint constraint) 52 | { 53 | this.constraint = constraint; 54 | } 55 | 56 | public IntegerExpressionVariable getVariable() 57 | { 58 | return variable; 59 | } 60 | 61 | public void setVariable(IntegerExpressionVariable variable) 62 | { 63 | this.variable = variable; 64 | } 65 | 66 | public Object getObj() 67 | { 68 | if (this.constraint != null) 69 | { 70 | return this.constraint; 71 | } 72 | return variable; 73 | } 74 | 75 | public void setObj(Object obj) 76 | { 77 | this.obj = obj; 78 | if (obj instanceof Constraint) 79 | { 80 | this.constraint = (Constraint) obj; 81 | } 82 | else if (obj instanceof Variable) 83 | { 84 | variable = (IntegerExpressionVariable) obj; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /CCM Command Line Tool/CCMCL/src/com/nist/ccmcl/meConstraint.java: -------------------------------------------------------------------------------- 1 | package com.nist.ccmcl; 2 | 3 | import choco.kernel.model.constraints.Constraint; 4 | 5 | import java.util.List; 6 | 7 | 8 | //object constraint 9 | public class meConstraint 10 | { 11 | String _cons; 12 | Constraint _chocoConstraint; 13 | List _params; 14 | 15 | //constructor specifying the constraint with a string 16 | public meConstraint(String c, List p) 17 | { 18 | _cons = c; 19 | _params = p; 20 | } 21 | 22 | //get the constraint 23 | public String get_cons() 24 | { 25 | return _cons; 26 | } 27 | 28 | public List get_params() 29 | { 30 | return _params; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /CCM Command Line Tool/Combinatorial Coverage Measurement Command Line Tool - User Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/Combinatorial Coverage Measurement Command Line Tool - User Manual.pdf -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/Example1/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A EXAMPLE1.txt -T 2,3,4,5,6 -p -S -H -B 2 | 3 | 4 | 5 | Notes: 6 | 7 | This example uses an ACTS .xml file input that includes the 8 | test cases in the file. -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/Example2/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A apache.xml -T 2,3,4,5,6 -p -S -B 2 | 3 | 4 | Notes: This file is very large and cpu intensive. The "-p" 5 | option puts the program into parallel mode which 6 | significantly decreases the time to complete the 7 | combinatorial measurement. This program may take a few 8 | minutes to run. -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/Example3/ACTSfile.txt: -------------------------------------------------------------------------------- 1 | [Parameter] 2 | Jake (int): (*,6] 3 | Luke (int): 0,1,2 4 | Sam (int): 0,1,2 5 | Zach (int): {1,55},{88,99} 6 | Chris (boolean): TRUE,FALSE 7 | 8 | [Constraint] 9 | !Chris 10 | 11 | [Test Set] 12 | 1,1,1,1,TRUE 13 | 2,2,0,55,FALSE 14 | 3,0,1,88,TRUE 15 | 6,0,0,99,FALSE 16 | -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/Example3/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A ACTSfile.txt -T 2,3,4,5 -p -S -H -B 2 | 3 | 4 | Notes: This example uses an ACTS input file in the .txt format. -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/Example4/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -I input_test.csv -P -T 2,3,4,5 -p -S -H -B -G -m 100 -o missingCombinations.txt -a 2 | 3 | 4 | Notes: This example uses auto-detect mode on the tool as no ACTS input file is supplied (only test cases 5 | in .csv file). The "-P" option specifies that parameter names are at the top of the .csv file. 6 | 7 | This will take awhile to finish since we are generating missing combinations up to 8 | 100% coverage for all 2,3,4,5 way interactions. Generating the missing 5-way interactions will take 9 | the longest. It is recommended to add the "-p" option to speed things up. -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 1/ACTSfile.txt: -------------------------------------------------------------------------------- 1 | [Parameter] 2 | Jake (int): 0,1 3 | Luke (int): 0,1 4 | Zach (int): 0,1 5 | Sam (int): 0,1 6 | Chris (int): 0,1 7 | Mark (int): 0,1 8 | Cameron (int): 0,1 9 | Josh (int): 0,1 10 | Rick (int): 0,1 11 | 12 | [Constraint] 13 | Jake=0=>Josh=0 14 | 15 | [Test Set] 16 | 0,0,0,1,1,1,0,1,0 17 | 1,1,1,1,1,1,1,1,1 -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 1/command.txt.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A ACTSfile.txt -T 2,3,4,5,6 -S -B -H -p -R -e generate_fast.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 1/generate_fast.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/Examples/RealTime Example 1/generate_fast.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 2/ACTSfile.txt: -------------------------------------------------------------------------------- 1 | [Parameter] 2 | Jake (int): 0,1 3 | Luke (int): 0,1 4 | Zach (int): 0,1 5 | Sam (int): 0,1 6 | Chris (int): 0,1 7 | Mark (int): 0,1 8 | Cameron (int): 0,1 9 | Josh (int): 0,1 10 | Rick (int): 0,1 11 | 12 | [Constraint] 13 | Jake=0=>Josh=0 14 | 15 | [Test Set] 16 | 0,0,0,1,1,1,0,1,0 17 | 1,1,1,1,1,1,1,1,1 -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 2/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A ACTSfile.txt -S -B -H -p -T 2,3,4,5,6 -R -e generate_fastest.jar 2 | 3 | 4 | NOTE: The executed jar file is generating tests VERY fast, so it is best to leave the 5 | update interval and max thread count at the default values by using the command 6 | above. However, if you want to experiment with the update-interval and thread 7 | max, view the help menu. -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 2/generate_fastest.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/Examples/RealTime Example 2/generate_fastest.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 3/apache_simulation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/Examples/RealTime Example 3/apache_simulation.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/Examples/RealTime Example 3/command.txt: -------------------------------------------------------------------------------- 1 | java -jar ccmcl.jar -A apache.txt -T 2 -S -B -p -R -e apache_simulation.jar -d 2 | 3 | 4 | NOTE: This is a much more complicated example, with several parameters and 5 | constraints. You will notice the program takes longer to run, which 6 | is why I included (-d) to display the measurement progress in the 7 | console window. The apache_simulation.jar will generate test cases 8 | and send them to the real time measurement tool at random intervals 9 | between 0 and 5 seconds to simulate an apache server being used. -------------------------------------------------------------------------------- /CCM Command Line Tool/README.md: -------------------------------------------------------------------------------- 1 | # CCMCL - Combinatorial Coverage Measurement Command Line Tool# 2 | A real time combinatorial coverage measurement tool. Based off of [CCM](http://csrc.nist.gov/groups/SNS/acts/download_tools.html#measure), but with enhanced functionality. 3 | 4 | ### Supported Operating Systems: ### 5 | 6 | - Windows 7 | - Mac OS 8 | - Linux 9 | 10 | ### Key Features:### 11 | 12 | - Measure the combinatorial coverage of static test case files 13 | - Generate missing combinations from given test cases 14 | - Generate random tests 15 | - Measure combinatorial coverage in real time via various input modes 16 | - Standard Input 17 | - Output of external programs 18 | - TCP/IP 19 | - Specify robust constraints 20 | - Support for equivalence classes and groups via SET notation definitions 21 | - Read ACTS configuration files via `.txt` or `.xml` 22 | 23 | 24 | ### Preview: ### 25 | ![CCMCL Graphs](/../master/Images/ccmcl_graphs.png) 26 | 27 | ##Classic Mode## 28 | 29 | Classic mode is the command line version of the original CCM tool. It provides all the same functionality as the GUI version, but with some extra functionality added in. By default, classic mode is enabled, and gives the user a lot of power in static analysis of test cases. In this section we will explain the various command line parameter options for classic mode of CCMCL. 30 | 31 | ###Command Line Arguments Pertaining to Classic Mode:### 32 | To see a list of all the possible command line arguments run: 33 | 34 | `java -jar ccmcl.jar --help` 35 | 36 | - `--inputfile (-I)` : [path to test case file (`.txt`, `.csv`)]. 37 | - `--ACTSfile (-A)`: [path to `.txt` or `.xml` ACTS file]. 38 | - `--constraints (-C)`: [path to `.txt` file containing constraints]. 39 | - `--tway (-T)`: [2,3,4,5,6] Any order and any combination of these values. 40 | - `--generate-missing (-G)`: Generates missing combinations not in test file. 41 | - Must include `-m` and `-o` with this option. 42 | - Not available for real time mode (`-R`). 43 | - `--minimum-coverage (-m)`: Minimum coverage for generating missing combinations. 44 | - `--output-missing (-o)`: Output path for the missing combinations. 45 | - `--append-tests (-a)`: Appends original tests to missing combinations file. 46 | - `--parameter-names (-P)`: Parameter names are first line of test case file (`-I`). 47 | - `--parallel (-p)`: Puts the program in parallel processing mode. 48 | - `--generate-random (-r)`: Sets the program to generate a random set of inputs. 49 | - Must include `-n` and `-f` with this option. 50 | - Not available in real time mode (`-R`). 51 | - `--number-random (-n)`: Amount of random inputs to generate. 52 | - `--output-random (-f)`: Path to output the random test cases to. 53 | - `--stepchart (-S)`: Generates a step chart displaying t-way coverage. 54 | - `--barchart (-B)`: Generates a bar chart displaying t-way coverage. 55 | - `--heatmap (-H)`: Generates a 2-way coverage heatmap. 56 | - `--display-progress (-d)`: Displays progress of coverage measurement. 57 | 58 | 59 | ### Example: ### 60 | `java -jar ccmcl.jar -I input_test.csv -A ACTSfile.txt -P -T 2,3,4,5,6 -S -H -B` 61 | 62 | Below is an explanation for each command line argument and what exactly it is doing: 63 | 64 | 1. `java -jar ccmcl.jar` 65 | - This launches the ccmcl.jar program. (Be sure you have Java installed.) 66 | 2. `-I input_test.csv` 67 | - This input parameter specifies that the test cases will come from a comma separated value file. 68 | - ![input_test.csv image](/../master/Images/input_test.csv.png) 69 | 3. `-A ACTSfile.txt` 70 | - This input parameter specifies that an ACTS configuration file will used to define the input domain. ACTS files can be either `.txt` or `.xml` format. 71 | - ![ACTSfile image](/../master/Images/ACTSfile.txt.png) 72 | 4. `-P` 73 | - This option simply specifies that in the test case file (`input_test.csv`), the first row is the parameter names. Include this option if this is the case. 74 | 5. `-T 2,3,4,5,6` 75 | - This option specifies the t-way levels you would like to measure. Notice only the values (2,3,4,5,6) are available. In this case, we selected to measure all of them. 76 | 6. `-S` 77 | - This tells the CCMCL program to display a stepchart of the measured combinatorial coverage. 78 | 7. `-B` 79 | - This tells the CCMCL program to display a barchart of the measured combinatorial coverage. 80 | 8. `-H` 81 | - This tells the CCMCL program to display a heatmap of the 2-way coverage measured. Notice, the heatmap option is only available for 2-way coverage. -------------------------------------------------------------------------------- /CCM Command Line Tool/ccmcl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM Command Line Tool/ccmcl.jar -------------------------------------------------------------------------------- /CCM Command Line Tool/demo.bat: -------------------------------------------------------------------------------- 1 | ECHO OFF 2 | cls 3 | :MENU 4 | ECHO. 5 | ECHO ............................................... 6 | ECHO CCM Command Line Tool Demo Batch 7 | ECHO ............................................... 8 | ECHO. 9 | ECHO 1 - Example 1 10 | ECHO 2 - Example 2 (Warning: Processor Intensive, Long Example) 11 | ECHO 3 - Example 3 12 | ECHO 4 - Example 4 13 | ECHO 5 - Real Time Example 1 14 | ECHO 6 - Real Time Example 2 15 | ECHO 7 - Real Time Example 3 16 | ECHO 8 - Exit 17 | ECHO. 18 | SET /P M=Select an Option: 19 | IF %M%==1 GOTO EXAMPLE1 20 | IF %M%==2 GOTO EXAMPLE2 21 | IF %M%==3 GOTO EXAMPLE3 22 | IF %M%==4 GOTO EXAMPLE4 23 | IF %M%==5 GOTO REALTIMEEXAMPLE1 24 | IF %M%==6 GOTO REALTIMEEXAMPLE2 25 | IF %M%==7 GOTO REALTIMEEXAMPLE3 26 | IF %M%==8 GOTO EXIT 27 | :EXAMPLE1 28 | java -jar ccmcl.jar -A Examples\Example1\EXAMPLE1.txt -T 2,3,4,5,6 -p -S -H -B 29 | GOTO MENU 30 | :EXAMPLE2 31 | java -jar ccmcl.jar -A Examples\Example2\apache.xml -T 2,3,4,5,6 -p -S -B 32 | GOTO MENU 33 | :EXAMPLE3 34 | java -jar ccmcl.jar -A Examples\Example3\ACTSfile.txt -T 2,3,4,5 -p -S -H -B 35 | GOTO MENU 36 | :EXAMPLE4 37 | java -jar ccmcl.jar -I Examples\Example4\input_test.csv -P -T 2,3,4,5 -p -S -H -B -G -m 100 -o Examples\Example4\missingCombinations.txt -a 38 | GOTO MENU 39 | :REALTIMEEXAMPLE1 40 | java -jar ccmcl.jar -A "Examples\RealTime Example 1\ACTSfile.txt" -T 2,3,4,5,6 -S -B -H -p -R -e "Examples\RealTime Example 1\generate_fast.jar" 41 | GOTO MENU 42 | :REALTIMEEXAMPLE2 43 | java -jar ccmcl.jar -A "Examples\RealTime Example 2\ACTSfile.txt" -S -B -H -p -T 2,3,4,5,6 -R -e "Examples\RealTime Example 2\generate_fastest.jar" 44 | GOTO MENU 45 | :REALTIMEEXAMPLE3 46 | java -jar ccmcl.jar -A "Examples\RealTime Example 3\apache.txt" -T 2 -S -B -p -R -e "Examples\RealTime Example 3\apache_simulation.jar" -d 47 | GOTO MENU 48 | :EXIT 49 | echo End Demo -------------------------------------------------------------------------------- /CCM-GUI/CCM-bin.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM-GUI/CCM-bin.tar -------------------------------------------------------------------------------- /CCM-GUI/CCM-src.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM-GUI/CCM-src.tar -------------------------------------------------------------------------------- /CCM-GUI/readme.txt: -------------------------------------------------------------------------------- 1 | THis directory contains the executable, source, and documentation for the GUI version of the CCM combinatorial coverage measurement tool. 2 | A separate command line version can be found in a separate directory. 3 | -------------------------------------------------------------------------------- /CCM-bin.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM-bin.tar -------------------------------------------------------------------------------- /CCM-src.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM-src.tar -------------------------------------------------------------------------------- /CCM17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/CCM17.jar -------------------------------------------------------------------------------- /FaultID User Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/FaultID User Guide.pdf -------------------------------------------------------------------------------- /Faultloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/Faultloc.exe -------------------------------------------------------------------------------- /Images/ACTSfile.txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/Images/ACTSfile.txt.png -------------------------------------------------------------------------------- /Images/ccmcl_graphs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/Images/ccmcl_graphs.png -------------------------------------------------------------------------------- /Images/input_test.csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/Images/input_test.csv.png -------------------------------------------------------------------------------- /Measuring the Combinatorial Coverage of Software in Real Time.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usnistgov/combinatorial-testing-tools/07b9c57e26410ea85903bb577c5d26a1173fb97e/Measuring the Combinatorial Coverage of Software in Real Time.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Combinatorial Testing Tools # 2 | Some of the NIST tools for combinatorial testing are available on this site. 3 | 4 | -> For the covering array generator tool ACTS, please email Rick Kuhn at kuhn@nist.gov. ACTS is distributed separately. 5 | 6 | ### Available on this Github directory 7 | - PEV tool - for testing rule-based expert systems or business rule engine/workflow systems. (runs on Java platforms; GUI and command line versions here) 8 | 9 | - Combinatorial Coverage Measurement - computes a number of coverage measures of an existing test set. Both at GUI and command-line version are included. (runs on Java platforms; GUI and command line versions here) 10 | 11 | - Combinatorial Sequence Test Generator - generates sequence covering arrays, useful for event driven systems including GUIs, protocols, hardware testing. (C source, compile for target platform) 12 | 13 | - Fault Identification tool - helps to narrow down the set of possible fault-triggering combinations in failing tests 14 | Access Control Policy Test (ACPT) - uses combinatorial testing with model checking to produce tests for access control policies 15 | 16 | ### Separately distributed tools 17 | - Advanced Combinatorial Testing System (ACTS) - generates test sets that ensure t-way coverage of input parameter values; includes support for constraints and variable-strength tests. Both at GUI and command-line version are included. (runs on Java platforms) -> contact Rick Kuhn at kuhn@nist.gov 18 | 19 | - Web app Testing Tool - CPUT (Combinatorial-based Prioritization of User-session-based Testsuites) applies combinatorial methods to testing web applications. Test prioritization is used to make web app testing much more manageable. (runs on Java platforms) -> contact Renee Bryce at Univ of North Texas 20 | 21 | - Access Control Policy Test (ACPT) - uses combinatorial testing with model checking to produce tests for access control policies -> contact Vincent Hu at NIST 22 | -------------------------------------------------------------------------------- /SequenceCoveringArrays/newseq3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #define MAXT 10000 6 | #define NTRIALS 1000 7 | int N; // number of events to generate sequences for 8 | int NSEQ; // number of sequences = N(N-1)(N-2) 9 | int reversal; // toggle for whether to generate new tests by reversing just created one 10 | 11 | int ***chk; //int chk[N][N][N]; 12 | int **test; // int test[MAXT][N]; 13 | int **seq; // int seq[NSEQ][3] 14 | int **tmptest; // int test[MAXT][N]; 15 | 16 | int i,j,k,m,n,q; 17 | int nt=0, cnt=0; 18 | int fnd; 19 | int tp; 20 | int all_covered=0; 21 | int bestidx, bestcov; 22 | int i1, j1, k1; 23 | 24 | main(int argc, char *argv[]) 25 | { 26 | void analyze(); 27 | int used(); 28 | void prtest(); 29 | 30 | //=========================================================================== 31 | // set up using input args 32 | if (argc < 2) { 33 | fprintf(stderr,"Usage: \n"); 34 | return 1; 35 | } 36 | N = atoi(argv[1]); 37 | NSEQ = N*(N-1)*(N-2); 38 | 39 | // allocate space for check array 40 | chk = (int ***)malloc(sizeof(int **) * N); 41 | for (i=0; i 5? 1 : 0); 54 | 55 | 56 | tmptest = (int **)malloc(sizeof(int *) * MAXT ); 57 | for (i=0; i=0; i--) { 67 | for (j=N-1; j>=0; j--) { 68 | for (k=N-1; k>=0; k--) { 69 | if (i != j && i != k && j != k) {seq[m][0]=i; seq[m][1]=j; seq[m][2]=k; m++; chk[i][j][k] = 0;} 70 | }}} 71 | } 72 | 73 | //============================================== 74 | // init tests with all 2-seq 75 | for (i=0; i bestcov) {bestcov=cnt; bestidx=m; } 100 | } // printf(" best %d bidx %d \n", bestcov,bestidx); 101 | for (i=0; i 2 | #include 3 | #include 4 | #include 5 | #define MAXT 10000 6 | #define NTRIALS 1000 7 | int N; // number of events to generate sequences for 8 | int NSEQ; // number of sequences = N(N-1)(N-2) 9 | int reversal; // toggle for whether to generate new tests by reversing just created one 10 | 11 | int ****chk; //int chk[N][N][N]; 12 | int **test; // int test[MAXT][N]; 13 | int **seq; // int seq[NSEQ][3] 14 | int **tmptest; // int test[MAXT][N]; 15 | 16 | int i,j,k,m,n,q,r; 17 | int nt=0, cnt=0; 18 | int fnd; 19 | int tp; 20 | int all_covered=0; 21 | int bestidx, bestcov; 22 | int i1, j1, k1, r1; 23 | 24 | main(int argc, char *argv[]) 25 | { 26 | void analyze(); 27 | int used(); 28 | void prtest(); 29 | 30 | //=========================================================================== 31 | // set up using input args 32 | if (argc < 1) { 33 | fprintf(stderr,"Usage: \n"); 34 | return 1; 35 | } 36 | N = atoi(argv[1]); 37 | NSEQ = N*(N-1)*(N-2)*(N-3); 38 | 39 | // allocate space for check array 40 | chk = (int ****)malloc(sizeof(int ***) * N); 41 | for (i=0; i 5? 1 : 0); 56 | 57 | 58 | tmptest = (int **)malloc(sizeof(int *) * MAXT ); 59 | for (i=0; i=0; i--) { 69 | for (j=N-1; j>=0; j--) { 70 | for (k=N-1; k>=0; k--) { 71 | for (r=N-1; r>=0; r--) { 72 | if (i != j && i != k && j != k && i != r && j != r && k != r ) 73 | {seq[m][0]=i; seq[m][1]=j; seq[m][2]=k; seq[m][3]=r; m++; chk[i][j][k][r] = 0;} 74 | }}}} 75 | } 76 | 77 | //============================================== 78 | // init tests with all 2-seq 79 | for (i=0; i bestcov) {bestcov=cnt; bestidx=m; } 105 | } // printf(" best %d bidx %d \n", bestcov,bestidx); 106 | for (i=0; i