Skip to content

Commit

Permalink
Forgot to check these files in.
Browse files Browse the repository at this point in the history
git-svn-id: https://piraha-peg.googlecode.com/svn/trunk@40 1a70d7c6-ffe7-ef14-4583-3269c1a2e543
  • Loading branch information
[email protected] committed Aug 1, 2011
1 parent e803552 commit 9e5d903
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/edu/lsu/cct/piraha/Break.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package edu.lsu.cct.piraha;

public class Break extends Pattern {

@Override
public boolean match(Matcher m) {
throw new BreakException();
}

@Override
public String decompile() {
return "{!}";
}

@Override
public boolean eq(Object obj) {
return obj instanceof Break;
}

}
5 changes: 5 additions & 0 deletions src/edu/lsu/cct/piraha/BreakException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.lsu.cct.piraha;

public class BreakException extends RuntimeException {

}
51 changes: 51 additions & 0 deletions src/edu/lsu/cct/piraha/examples/Value.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package edu.lsu.cct.piraha.examples;

import edu.lsu.cct.piraha.Group;

public class Value {
Object o;
Group g;
public Value(Group g) {
o = null;
this.g = g;
}
public Value(Boolean b,Group g) {
o = b;
this.g = g;
}
public Value(Number n,Group g) {
o = n;
this.g = g;
}
boolean getBool() {
/*if(o == null || !(o instanceof Boolean)) {
g.dumpMatches();
}*/
if(o == null) return false;
if(o instanceof Long) {
return ((Long)o).longValue() != 0;
}
return ((Boolean)o).booleanValue();
}
double getDouble() {
if(o == null) return 0;
return ((Number)o).doubleValue();
}
long getLong() {
if(o == null) return 0;
return ((Number)o).longValue();
}
public boolean isInt() {
return o == null || o instanceof Long;
}
public String toString() {
if(o == null)
return "Void";
else if(o instanceof Boolean)
return "Boolean "+o;
else if(o instanceof Long)
return "Long "+o;
else
return "Double "+o;
}
}

0 comments on commit 9e5d903

Please sign in to comment.