-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://piraha-peg.googlecode.com/svn/trunk@40 1a70d7c6-ffe7-ef14-4583-3269c1a2e543
- Loading branch information
1 parent
e803552
commit 9e5d903
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package edu.lsu.cct.piraha; | ||
|
||
public class BreakException extends RuntimeException { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |