[e-cvs] cvs commit: e/src/jsrc/org/quasiliteral/term Term.updoc
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Sat, 1 Dec 2001 02:52:14 -0500
markm 01/12/01 02:52:14
Modified: src/jsrc/net/captp/jcomm SturdyRef.java
src/jsrc/org/erights/e/elang/evm Evaluator.java
src/jsrc/org/erights/e/elang/interp LazyEvalSlot.java
LoaderScope.java ScopeSetup.java
src/jsrc/org/erights/e/elang/syntax EBuilder.java
ELexer.java EParser.java
src/jsrc/org/erights/e/elang/visitors ETreeVisitor.java
src/jsrc/org/erights/e/elib/ref Ref.java SlotRef.java
src/jsrc/org/erights/e/elib/slot RuinedSlot.java Slot.java
src/jsrc/org/erights/e/elib/tables ConstList.java
ConstMap.java ConstSet.java Twine.java
src/jsrc/org/erights/e/ui/elmer EInterpAdapter.java
src/jsrc/org/quasiliteral/astro Astro.java AstroSchema.java
AstroTag.java AstroToken.java BaseSchema.java
src/jsrc/org/quasiliteral/term Term.updoc
Added: src/jsrc/org/erights/e/elang/syntax URIKit.java
Removed: src/jsrc/org/erights/e/elang/syntax URI.java
src/jsrc/org/erights/e/elib/base EComparable.java
Log:
compiles again, except for the term and quasi packages
Revision Changes Path
1.16 +5 -6 e/src/jsrc/net/captp/jcomm/SturdyRef.java
Index: SturdyRef.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/SturdyRef.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SturdyRef.java 2001/11/19 19:15:35 1.15
+++ SturdyRef.java 2001/12/01 07:52:11 1.16
@@ -23,7 +23,7 @@
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.serial.Persistent;
import org.erights.e.elib.tables.ConstList;
-import org.erights.e.elib.base.EComparable;
+import org.erights.e.elib.base.Ejector;
import org.erights.e.elib.prim.E;
import java.io.IOException;
@@ -33,7 +33,7 @@
* An object reference that be checkpointed and/or externalized and which can
* survive network partitions.
*/
-public final class SturdyRef implements EComparable, Persistent {
+public final class SturdyRef implements Persistent {
/** The LocatorUnum that links us to the outside world. */
private LocatorUnum myLocatorUnum;
@@ -78,10 +78,9 @@
* @return 0.0 iff this and other designate the same object. Otherwise
* NaN.
*/
- public double compareTo(EComparable other) {
- SturdyRef sturdy = (SturdyRef)E.as(other, SturdyRef.class);
- if (myHostID.equals(sturdy.myHostID) &&
- mySwissNum.equals(sturdy.mySwissNum))
+ public double compareTo(SturdyRef other) {
+ if (myHostID.equals(other.myHostID) &&
+ mySwissNum.equals(other.mySwissNum))
{
return 0.0;
} else {
1.11 +2 -2 e/src/jsrc/org/erights/e/elang/evm/Evaluator.java
Index: Evaluator.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/evm/Evaluator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Evaluator.java 2001/11/09 01:17:20 1.10
+++ Evaluator.java 2001/12/01 07:52:12 1.11
@@ -86,7 +86,7 @@
* for example, the variable "foo" into corresponding final variable
* "foo__Slot", bound to an explicit Slot object holding the value of
* the "foo" variable. Use of "foo" as a rValue then becomes
- * "foo__Slot getValue" and assignment becomes "foo__Slot
+ * "foo__Slot getData" and assignment becomes "foo__Slot
* setValue(newValue)". All non-final variables and assignment
* statements could have been transformed away this way, but for
* compilation purposes we chose not to. However, when transforming
@@ -115,7 +115,7 @@
* def y :final := 7
* ... x__Slot ... (x__Slot setValue(4)) ... y ...
* def [pow, pow__Resolver] := PromiseMaker pair
- * ... visualizingEvaluator eval(e`x__Slot getValue ** y =~ pow :final`,
+ * ... visualizingEvaluator eval(e`x__Slot getData ** y =~ pow :final`,
* ["x__Slot" => x__Slot, "y" => y],
* true,
* ["pow" => pow_Resolver]) ...
1.9 +7 -7 e/src/jsrc/org/erights/e/elang/interp/LazyEvalSlot.java
Index: LazyEvalSlot.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/LazyEvalSlot.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LazyEvalSlot.java 2001/11/17 18:25:54 1.8
+++ LazyEvalSlot.java 2001/12/01 07:52:12 1.9
@@ -57,13 +57,13 @@
private Object myOptValue;
/**
- * @param scope The scope in which to evaluate the source text. It's
- * declared as an Object rather than Scope so that it can be a promise
- * for a Scope. This promise must become fulfilled before the first
- * getValue() happens.
- * @param source The source text to be evaluated in the promised scope at
- * the time of the first getValue().
- */
+ * @param scope The scope in which to evaluate the source text. It's
+ * declared as an Object rather than Scope so that it can be a promise
+ * for a Scope. This promise must become fulfilled before the first
+ * getData() happens.
+ * @param source The source text to be evaluated in the promised scope at
+ * the time of the first getData().
+ */
/*package*/ LazyEvalSlot(Object scope, Twine source) {
myOptScope = scope;
myOptSource = source;
1.41 +1 -1 e/src/jsrc/org/erights/e/elang/interp/LoaderScope.java
Index: LoaderScope.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/LoaderScope.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- LoaderScope.java 2001/11/13 02:13:54 1.40
+++ LoaderScope.java 2001/12/01 07:52:12 1.41
@@ -180,7 +180,7 @@
result = FinalSlotMaker.THE_ONE.makeSlot(ref, null);
myAlreadyImported.put(fqName, result, true);
Object value;
- //start with it set to false, so we'll also remove fqName if getValue
+ //start with it set to false, so we'll also remove fqName if getData
//throws
boolean[] keep = { false };
try {
1.76 +5 -4 e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java
Index: ScopeSetup.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/ScopeSetup.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- ScopeSetup.java 2001/11/19 19:15:35 1.75
+++ ScopeSetup.java 2001/12/01 07:52:12 1.76
@@ -48,14 +48,13 @@
import org.erights.e.elib.slot.SlotDefiner;
import org.erights.e.elib.slot.VoidMaker;
import org.erights.e.elib.tables.ConstMap;
+import org.erights.e.elib.tables.ESet;
import org.erights.e.elib.tables.Equalizer;
-import org.erights.e.elib.tables.Twine;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.FlexMap;
-import org.erights.e.elib.tables.ESet;
+import org.erights.e.elib.tables.Twine;
import org.erights.e.elib.util.ClassCache;
import org.erights.e.meta.java.io.FileGetter;
-import org.quasiliteral.quasiterm.QuasiTermBuilder;
/**
* The initial namespace as seen by the E language programmer.
@@ -185,7 +184,9 @@
um.comp("epatt__quasiParser", univ,
"<import:org.erights.e.elang.syntax.epatt__quasiParser>");
um.comp("sml__quasiParser", XMLQuasiParser.XMLQuasiParserMaker);
- um.comp("term__quasiParser", QuasiTermBuilder.THE_ONE);
+ um.comp("term__quasiParser", univ,
+ "<import:org.quasiliteral.quasiterm.QuasiTermBuilder>" +
+ " THE_ONE()");
um.init("universalScope", univ); // not uconstant
OuterScope realUniv = um.scope();
1.86 +24 -18 e/src/jsrc/org/erights/e/elang/syntax/EBuilder.java
Index: EBuilder.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/EBuilder.java,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- EBuilder.java 2001/11/17 18:25:55 1.85
+++ EBuilder.java 2001/12/01 07:52:12 1.86
@@ -62,6 +62,8 @@
import org.erights.e.elib.tables.EList;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.FlexMap;
+import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.prim.E;
import org.quasiliteral.astro.AstroToken;
/**
@@ -252,7 +254,7 @@
String verbName;
if (verb instanceof AstroToken) {
- verbName = (String)((AstroToken)verb).getValue();
+ verbName = (String)((AstroToken)verb).getData();
} else {
verbName = (String)verb;
}
@@ -615,7 +617,7 @@
* When an at-hole is '@<ident>' or '@_'
*/
/*package*/ Pattern atNoun(Object token) {
- String str = (String)((AstroToken)token).getValue();
+ String str = (String)((AstroToken)token).getData();
str = hilbert(str);
if ("_".equals(str)) {
return ignore();
@@ -667,7 +669,7 @@
* When a dollar-hole is '$<ident>'
*/
/*package*/ EExpr dollarNoun(Object token) {
- String str = (String)((AstroToken)token).getValue();
+ String str = (String)((AstroToken)token).getData();
str = hilbert(str);
return noun(str);
}
@@ -964,7 +966,7 @@
*/
/*package*/ LiteralExpr literal(Object token) {
AstroToken tokn = (AstroToken)token;
- return new LiteralExpr(tokn.getValue());
+ return new LiteralExpr(tokn.getData());
}
/**
@@ -1136,7 +1138,7 @@
eScript);
} else if (isLiteralToken(optOName)) {
return object(docComment,
- ((AstroToken)optOName).getValue(),
+ ((AstroToken)optOName).getData(),
auditors,
eScript);
@@ -1198,7 +1200,7 @@
for (int i = 0; i < qList.length; i++) {
if (isQuasiPart(qList[i])) {
- buf.append(((AstroToken)qList[i]).getValue());
+ buf.append(((AstroToken)qList[i]).getData());
} else {
EExpr eExpr = (EExpr)qList[i];
@@ -1224,7 +1226,7 @@
*/
/*package*/ QuasiLiteralExpr quasiLiteralExpr(Object litIndex) {
AstroToken lit = (AstroToken)litIndex;
- int index = ((Number)lit.getValue()).intValue();
+ int index = ((Number)lit.getData()).intValue();
return new QuasiLiteralExpr(index);
}
@@ -1233,7 +1235,7 @@
*/
/*package*/ QuasiLiteralPatt quasiLiteralPatt(Object litIndex) {
AstroToken lit = (AstroToken)litIndex;
- int index = ((Number)lit.getValue()).intValue();
+ int index = ((Number)lit.getData()).intValue();
return new QuasiLiteralPatt(index);
}
@@ -1253,7 +1255,7 @@
for (int i = 0; i < qList.length; i++) {
if (isQuasiPart(qList[i])) {
- buf.append(((AstroToken)qList[i]).getValue());
+ buf.append(((AstroToken)qList[i]).getData());
} else if (qList[i] instanceof EExpr) {
EExpr eExpr = (EExpr)qList[i];
@@ -1282,7 +1284,7 @@
*/
/*package*/ QuasiPatternExpr quasiPatternExpr(Object litIndex) {
AstroToken lit = (AstroToken)litIndex;
- int index = ((Number)lit.getValue()).intValue();
+ int index = ((Number)lit.getData()).intValue();
return new QuasiPatternExpr(index);
}
@@ -1291,7 +1293,7 @@
*/
/*package*/ QuasiPatternPatt quasiPatternPatt(Object litIndex) {
AstroToken lit = (AstroToken)litIndex;
- int index = ((Number)lit.getValue()).intValue();
+ int index = ((Number)lit.getData()).intValue();
return new QuasiPatternPatt(index);
}
@@ -1474,14 +1476,15 @@
}
/**
- * uriToken must be a URI, and optBody() must not be null.
+ * uriToken must be a URI, and have both protocol and body.
+ * <p>
* <http:foo> expands to http__uriGetter["foo"].
* <x:foo> expands to file__uriGetter["x:foo"].
*/
/*package*/ EExpr uriExpr(Object uriToken) {
- URI uri = (URI)uriToken;
- String protocol = uri.protocol();
- String body = uri.optBody();
+ Twine uriText = (Twine)((AstroToken)uriToken).getOptData();
+ String protocol = URIKit.getProtcol(uriText).bare();
+ String body = URIKit.getBody(uriText).bare();
if (protocol.length() == 1) {
char c = Character.toLowerCase(protocol.charAt(0));
if ('a' <= c && c <= 'z') {
@@ -1495,12 +1498,15 @@
}
/**
- * uriStartToken must be a URIStart, and optBody() must be null.
+ * uriStartToken must be a URIStart, and must have a protocol, but no
+ * body.
+ * <p>
* <http: expr> expands to http__uriGetter[expr]
* <x: expr> expands to file__uriGetter["x:" + expr]
*/
/*package*/ EExpr uriExpr(Object uriStartToken, Object uriBodyExpr) {
- String protocol = ((URI)uriStartToken).protocol();
+ Twine uriText = (Twine)((AstroToken)uriStartToken).getOptData();
+ String protocol = URIKit.getProtcol(uriText).bare();
if (protocol.length() == 1) {
char c = Character.toLowerCase(protocol.charAt(0));
if ('a' <= c && c <= 'z') {
@@ -1743,7 +1749,7 @@
} else if (isLiteralToken(optOName)) {
return oType(docComment,
- ((AstroToken)optOName).getValue(),
+ ((AstroToken)optOName).getData(),
auditors,
mTypes);
1.67 +136 -89 e/src/jsrc/org/erights/e/elang/syntax/ELexer.java
Index: ELexer.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/ELexer.java,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- ELexer.java 2001/11/27 07:27:54 1.66
+++ ELexer.java 2001/12/01 07:52:12 1.67
@@ -23,7 +23,9 @@
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.tables.EmptyTwine;
import org.erights.e.elib.tables.Twine;
+import org.quasiliteral.astro.AstroSchema;
import org.quasiliteral.astro.AstroToken;
+import org.quasiliteral.astro.BaseSchema;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -48,6 +50,12 @@
*/
static private final String QUASI_ENDER = "$@`";
+ /**
+ *
+ */
+ static public final AstroSchema DEFAULT_SCHEMA =
+ new BaseSchema(EParser.getTokenNames());
+
/** contains all lines after the current line */
private LineFeeder myInput;
@@ -105,9 +113,27 @@
/**
*
+ */
+ private AstroSchema mySchema;
+
+ /**
+ *
*/
- public ELexer(LineFeeder input, boolean partialFlag, boolean noTabsFlag)
+ public ELexer(LineFeeder input,
+ boolean partialFlag,
+ boolean noTabsFlag)
throws IOException {
+ this(input, partialFlag, noTabsFlag, DEFAULT_SCHEMA);
+ }
+
+ /**
+ *
+ */
+ public ELexer(LineFeeder input,
+ boolean partialFlag,
+ boolean noTabsFlag,
+ AstroSchema schema)
+ throws IOException {
myInput = input;
myPos = -1;
@@ -122,6 +148,7 @@
myNoTabsFlag = noTabsFlag;
myIndenter = new Indenter();
myContinueFlag = false;
+ mySchema = schema;
}
/**
@@ -369,7 +396,6 @@
return;
}
}
-
}
}
@@ -389,6 +415,27 @@
/**
*
*/
+ private AstroToken leafTag(int typeCode, Twine source) {
+ return (AstroToken)mySchema.leafTag(typeCode, source);
+ }
+
+ /**
+ *
+ */
+ private AstroToken leafData(Object data, Twine source) {
+ return (AstroToken)mySchema.leafData(data, source);
+ }
+
+ /**
+ *
+ */
+ private AstroToken composite(int typeCode, Object data, Twine source) {
+ return (AstroToken)mySchema.composite(typeCode, data, source);
+ }
+
+ /**
+ *
+ */
private AstroToken getNextToken() throws IOException, SyntaxException {
if (myDelayedNextChar) {
nextChar();
@@ -411,16 +458,16 @@
{
char c = (char)myChar;
nextChar();
- return new AstroToken(c, endToken());
+ return leafTag(c, endToken());
}
case EOFCHAR:
{
- return new AstroToken(EParser.EOFTOK, EmptyTwine.THE_ONE);
+ return leafTag(EParser.EOFTOK, EmptyTwine.THE_ONE);
}
case '\n':
{
myDelayedNextChar = true;
- return new AstroToken(EParser.EOL, endToken());
+ return leafTag(EParser.EOL, endToken());
}
case '(':
{
@@ -469,9 +516,9 @@
syntaxError(key + " is a keyword");
}
myIndenter.pop('$', name);
- return new AstroToken(EParser.DollarIdent, name, key);
+ return composite(EParser.DollarIdent, key, name);
}
- return new AstroToken('$', endToken());
+ return leafTag('$', endToken());
}
case '@':
{
@@ -488,7 +535,7 @@
nextChar();
Twine name = endToken();
myIndenter.pop('@', name);
- return new AstroToken(EParser.AtIdent, name, "_");
+ return composite(EParser.AtIdent, "_", name);
} else if (myChar != EOFCHAR &&
isIdentifierStart((char)myChar)) {
//A '@<ident>' closes a '@'
@@ -503,9 +550,9 @@
syntaxError(key + " is a keyword");
}
myIndenter.pop('@', name);
- return new AstroToken(EParser.AtIdent, name, key);
+ return composite(EParser.AtIdent, key, name);
}
- return new AstroToken('@', endToken());
+ return leafTag('@', endToken());
}
case '.':
{
@@ -514,61 +561,61 @@
nextChar();
if (myChar == '!') {
nextChar();
- return new AstroToken(EParser.OpTill, endToken());
+ return leafTag(EParser.OpTill, endToken());
}
- return new AstroToken(EParser.OpThru, endToken());
+ return leafTag(EParser.OpThru, endToken());
}
- return new AstroToken('.', endToken());
+ return leafTag('.', endToken());
}
case '^':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssXor, endToken());
+ return leafTag(EParser.OpAssXor, endToken());
}
- return new AstroToken('^', endToken());
+ return leafTag('^', endToken());
}
case '+':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssAdd, endToken());
+ return leafTag(EParser.OpAssAdd, endToken());
} else if (myChar == '+') {
nextChar();
syntaxError("token \"++\" is reserved");
return null; //keep compiler happy
}
- return new AstroToken('+', endToken());
+ return leafTag('+', endToken());
}
case '-':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssSub, endToken());
+ return leafTag(EParser.OpAssSub, endToken());
} else if (myChar == '>') {
nextChar();
- return new AstroToken(EParser.OpWhen, endToken());
+ return leafTag(EParser.OpWhen, endToken());
} else if (myChar == '-') {
nextChar();
syntaxError("token \"--\" is reserved");
return null; //keep compiler happy
}
- return new AstroToken('-', endToken());
+ return leafTag('-', endToken());
}
case ':':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAss, endToken());
+ return leafTag(EParser.OpAss, endToken());
} else if (myChar == ':') {
nextChar();
- return new AstroToken(EParser.Audit, endToken());
+ return leafTag(EParser.Audit, endToken());
}
- return new AstroToken(':', endToken());
+ return leafTag(':', endToken());
}
case '<':
{
@@ -580,45 +627,45 @@
syntaxError("token \"<-*\" is reserved");
return null; //keep compiler happy
}
- return new AstroToken(EParser.Send, endToken());
+ return leafTag(EParser.Send, endToken());
} else if (myChar == '=') {
nextChar();
if (myChar == '>') {
nextChar();
- return new AstroToken(EParser.OpABA, endToken());
+ return leafTag(EParser.OpABA, endToken());
}
- return new AstroToken(EParser.OpLeq, endToken());
+ return leafTag(EParser.OpLeq, endToken());
} else if (myChar == '<') {
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssAsl, endToken());
+ return leafTag(EParser.OpAssAsl, endToken());
}
- return new AstroToken(EParser.OpAsl, endToken());
+ return leafTag(EParser.OpAsl, endToken());
} else if (isIdentifierStart((char)myChar)) {
AstroToken optResult = optUri();
if (null != optResult) {
return optResult;
}
}
- return new AstroToken('<', endToken());
+ return leafTag('<', endToken());
}
case '>':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpGeq, endToken());
+ return leafTag(EParser.OpGeq, endToken());
} else if (myChar == '>') {
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssAsr, endToken());
+ return leafTag(EParser.OpAssAsr, endToken());
}
- return new AstroToken(EParser.OpAsr, endToken());
+ return leafTag(EParser.OpAsr, endToken());
}
Twine closer = endToken();
- AstroToken result = new AstroToken('>', closer);
+ AstroToken result = leafTag('>', closer);
if (myIndenter.getCloser() == '>') {
myIndenter.pop('>', closer);
return result;
@@ -633,12 +680,12 @@
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssPow, endToken());
+ return leafTag(EParser.OpAssPow, endToken());
}
- return new AstroToken(EParser.OpPow, endToken());
+ return leafTag(EParser.OpPow, endToken());
} else if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssMul, endToken());
+ return leafTag(EParser.OpAssMul, endToken());
} else if (myChar == '-' && peekChar('>')) {
nextChar();
nextChar();
@@ -649,30 +696,30 @@
syntaxError("'/*..*/' comments are reserved. " +
"Use '#' or '//' on each line instead");
}
- return new AstroToken('*', endToken());
+ return leafTag('*', endToken());
}
case '/':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssAprxDiv, endToken());
+ return leafTag(EParser.OpAssAprxDiv, endToken());
} else if (myChar == '/') {
// Skip comment to end of line
skipLine();
- return new AstroToken(EParser.EOL, endToken());
+ return leafTag(EParser.EOL, endToken());
} else if (myChar == '*') {
nextChar();
syntaxError("'/*..*/' comments are reserved. " +
"Use '#' or '//' on each line instead");
}
- return new AstroToken('/', endToken());
+ return leafTag('/', endToken());
}
case '#':
{
// Skip comment to end of line (as in "//" case above).
skipLine();
- return new AstroToken(EParser.EOL, endToken());
+ return leafTag(EParser.EOL, endToken());
}
case '\\':
{
@@ -707,40 +754,40 @@
if (myChar == '=') {
// check for "%%="
nextChar();
- return new AstroToken(EParser.OpAssMod, endToken());
+ return leafTag(EParser.OpAssMod, endToken());
}
- return new AstroToken(EParser.OpMod, endToken());
+ return leafTag(EParser.OpMod, endToken());
} else if (myChar == '=') {
// check for "%="
nextChar();
- return new AstroToken(EParser.OpAssRemdr, endToken());
+ return leafTag(EParser.OpAssRemdr, endToken());
}
- return new AstroToken('%', endToken());
+ return leafTag('%', endToken());
}
case '!':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpNSame, endToken());
+ return leafTag(EParser.OpNSame, endToken());
} else if (myChar == '~') {
nextChar();
- return new AstroToken(EParser.MisMatch, endToken());
+ return leafTag(EParser.MisMatch, endToken());
}
- return new AstroToken('!', endToken());
+ return leafTag('!', endToken());
}
case '=':
{
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpSame, endToken());
+ return leafTag(EParser.OpSame, endToken());
} else if (myChar == '>') {
nextChar();
- return new AstroToken(EParser.MapsTo, endToken());
+ return leafTag(EParser.MapsTo, endToken());
} else if (myChar == '~') {
nextChar();
- return new AstroToken(EParser.MatchBind, endToken());
+ return leafTag(EParser.MatchBind, endToken());
}
syntaxError("use ':=' for assignment, or '==' for equality");
return null; //keep compiler happy
@@ -750,27 +797,27 @@
nextChar();
if (myChar == '&') {
nextChar();
- return new AstroToken(EParser.OpLAnd, endToken());
+ return leafTag(EParser.OpLAnd, endToken());
} else if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssAnd, endToken());
+ return leafTag(EParser.OpAssAnd, endToken());
} else if (myChar == '!') {
nextChar();
- return new AstroToken(EParser.OpButNot, endToken());
+ return leafTag(EParser.OpButNot, endToken());
}
- return new AstroToken('&', endToken());
+ return leafTag('&', endToken());
}
case '|':
{
nextChar();
if (myChar == '|') {
nextChar();
- return new AstroToken(EParser.OpLOr, endToken());
+ return leafTag(EParser.OpLOr, endToken());
} else if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssOr, endToken());
+ return leafTag(EParser.OpAssOr, endToken());
}
- return new AstroToken('|', endToken());
+ return leafTag('|', endToken());
}
case '\'':
{
@@ -814,11 +861,11 @@
nextChar();
if (myChar == '=') {
nextChar();
- return new AstroToken(EParser.OpAssFlrDiv, endToken());
+ return leafTag(EParser.OpAssFlrDiv, endToken());
}
- return new AstroToken(EParser.OpFlrDiv, endToken());
+ return leafTag(EParser.OpFlrDiv, endToken());
}
- return new AstroToken(EParser._, endToken());
+ return leafTag(EParser._, endToken());
}
default:
@@ -855,7 +902,7 @@
//Indent the next line to right after the open.
myIndenter.push(openner, closer, myPos);
}
- return new AstroToken(tokenType, openner);
+ return leafTag(tokenType, openner);
}
/**
@@ -868,7 +915,7 @@
//on mismatched close, throws SyntaxError at openner
//on unmatched close, throws Syntax error at closer
myIndenter.pop(closerChar, closer);
- return new AstroToken(closerChar, closer);
+ return leafTag(closerChar, closer);
}
/**
@@ -939,9 +986,7 @@
syntaxError("char constant must end in \"'\"");
}
nextChar();
- return new AstroToken(EParser.LiteralChar,
- endToken(),
- new Character(value));
+ return leafData(new Character(value), endToken());
}
/**
@@ -964,16 +1009,16 @@
if (tt != -1) {
syntaxError(name + " is a keyword");
}
- return new AstroToken(EParser.VerbAssign, source, name);
+ return composite(EParser.VerbAssign, name, source);
}
}
Twine source = endToken();
int ttype = EParser.optKeywordType(source.bare());
if (-1 == ttype) {
- return new AstroToken(EParser.ID, source, source.bare());
+ return composite(EParser.ID, source.bare(), source);
} else {
//keyword
- return new AstroToken(ttype, source);
+ return leafTag(ttype, source);
}
}
@@ -1071,17 +1116,13 @@
Twine tok = endToken();
String str = tok.replaceAll("_", "").bare();
if (floating) {
- return new AstroToken(EParser.LiteralFloat64,
- tok,
- Double.valueOf(str));
+ return leafData(Double.valueOf(str), tok);
} else {
if (radix == 16) {
//remove the leading "0x" to make BigInteger happy
str = str.substring(2);
}
- return new AstroToken(EParser.LiteralInteger,
- tok,
- new BigInteger(str, radix));
+ return leafData(new BigInteger(str, radix), tok);
}
}
@@ -1152,9 +1193,9 @@
nextChar();
Twine closer = endToken();
myIndenter.pop('`', closer);
- return new AstroToken(EParser.QuasiClose,
- closer,
- buf.toString());
+ return composite(EParser.QuasiClose,
+ buf.toString(), closer
+ );
} else if (peekChar('`')) {
//terminal '$' or '@' before a '`' is eaten and added to the
@@ -1177,9 +1218,9 @@
myIndenter.nest(openner, (char)myChar);
//interpolated '$' or '@' is neither eaten nor added to the
//value of the resulting QuasiOpen token.
- return new AstroToken(EParser.QuasiOpen,
- openner,
- buf.toString());
+ return composite(EParser.QuasiOpen,
+ buf.toString(), openner
+ );
}
}
}
@@ -1258,9 +1299,7 @@
nextChar();
Twine closer = endToken();
myIndenter.pop('"', closer);
- return new AstroToken(EParser.LiteralString,
- closer,
- value.toString());
+ return leafData(value.toString(), closer);
}
/**
@@ -1282,13 +1321,16 @@
//it is a colon. Commit.
myPos = pos;
nextChar();
- if (!URI.isURICStart((char)myChar)) {
+ if (!URIKit.isURICStart((char)myChar)) {
if (Character.isWhitespace((char)myChar)) {
Twine openner = endToken();
//Indent the next line to right after the open, even if
//there remains only whitespace on this line
myIndenter.push(openner, '>', myPos);
- return URI.make(EParser.URIStart, openner);
+ //the leading '<' isn't part of the URIStart data
+ Twine uriText = (Twine)openner.run(1, openner.size());
+ uriText = URIKit.normalize(uriText);
+ return composite(EParser.URIStart, uriText, openner);
} else {
syntaxError("Can't use \"" + (char)myChar +
"\" to start a URI body");
@@ -1296,13 +1338,17 @@
}
do {
nextChar();
- } while (myChar != EOFCHAR && URI.isURICPart((char)myChar));
+ } while (myChar != EOFCHAR && URIKit.isURICPart((char)myChar));
if (myChar != '>') {
syntaxError("Can't use \"" + (char)myChar +
"\" in a URI body");
}
nextChar();
- return URI.make(EParser.URI, endToken());
+ Twine source = endToken();
+ //the surrounding '<' and '>' aren't part of the URI data
+ Twine uriText = (Twine)source.run(1, source.size() -1);
+ uriText = URIKit.normalize(uriText);
+ return composite(EParser.URI, uriText, source);
}
/**
@@ -1332,7 +1378,8 @@
AstroToken t;
do {
t = lex.nextToken();
- stdout.println(t.asFunctor(EParser.getTokenNames()));
+ //XXX should print t as a Functor.
+ stdout.println(t);
if (t.getType() == EParser.EOL) {
stdout.print("stack: ",
lex.myIndenter.toString(),
1.103 +9 -9 e/src/jsrc/org/erights/e/elang/syntax/EParser.java
Index: EParser.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/EParser.java,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- EParser.java 2001/11/20 12:32:05 1.102
+++ EParser.java 2001/12/01 07:52:12 1.103
@@ -1142,7 +1142,7 @@
static public final StaticMaker EParserMaker =
StaticMaker.make(EParser.class);
-/**
+/**
* caches previous simple parses (as is used for quasi-parsing)
*/
static private IdentityCacheTable OurCache =
@@ -1151,7 +1151,7 @@
/**
*
*/
-static private final ConstMap DefaultProps =
+static private final ConstMap DefaultProps =
ConstMap.fromProperties(System.getProperties());
@@ -1159,7 +1159,7 @@
/** contains all the tokens after yylval */
private ELexer myLexer;
-/**
+/**
* Do we escape after parsing only one expression, or do we parse the
* entire input?
*/
@@ -1261,7 +1261,7 @@
/**
* If the input is empty, returns the null expression e`null`, rather
- * than null.
+ * than null.
*/
public ENode parse() {
ENode result = optParse();
@@ -1623,7 +1623,7 @@
* If 'name' is a keyword, return it's token type code, else -1.
* <p>
* Note that E keywords are case insensitive, so 'name' is first
- * toLowerCase()d.
+ * toLowerCase()d.
*/
static public int optKeywordType(String name) {
name = name.toLowerCase();
@@ -1640,7 +1640,7 @@
/**
* These are the tokens that may appear at the end of a line, in which
* case the next line is a (to be indented) continuation of the
- * expression.
+ * expression.
* <p>
* Note that > isn't on the list because of its role in closing a
* calculated URI expression.
@@ -1738,7 +1738,7 @@
//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
-int yyparse()
+int yyparse()
{
int yyn; //next next thing to do
int yym; //
@@ -1754,7 +1754,7 @@
while (true) //until parsing is done, either correctly, or w/error
{
doaction=true;
- if (yydebug) debug("loop");
+ if (yydebug) debug("loop");
//#### NEXT ACTION (from reduction table)
for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
{
@@ -2695,7 +2695,7 @@
break;
case 260:
//#line 973 "e.y"
-{ yyval = ((AstroToken)val_peek(0)).getValue(); }
+{ yyval = ((AstroToken)val_peek(0)).getData(); }
break;
case 261:
//#line 974 "e.y"
1.1 e/src/jsrc/org/erights/e/elang/syntax/URIKit.java
Index: URIKit.java
===================================================================
package org.erights.e.elang.syntax;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import org.erights.e.elib.tables.Twine;
import org.erights.e.elib.prim.E;
import org.quasiliteral.astro.AstroToken;
/**
* This class provides some conveniences for manipulating E URI-tokens.
* <p>
* A URI-token is an E token with a type-code of either URI or URIStart.<pre>
* URI ::= '<' identifier ':' URICStart URICPart* '>'
* URIStart ::= '<' identifier ':'
* </pre>
*
* @see org.erights.e.elang.syntax.URI#isURICStart
* @see org.erights.e.elang.syntax.URI#isURICPart
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public class URIKit {
static private boolean URICs[] = new boolean[128];
static {
for (int i = 0; i < 128; i++) {
//XXX this intitialization may be unnecessary, as the
//language probably guarantees initialization to false.
URICs[i] = false;
}
for (char c = 'a'; c <= 'z'; c++) {
URICs[c] = true;
}
for (char c = 'A'; c <= 'Z'; c++) {
URICs[c] = true;
}
for (char c = '0'; c <= '9'; c++) {
URICs[c] = true;
}
String allowed = ";/?:@&=+$,-_.!~*'()%\\|#";
for (int i = 0; i < allowed.length(); i++) {
URICs[allowed.charAt(i)] = true;
}
}
/**
*
*/
static public Twine normalize(Twine uriText) {
return uriText.replaceAll("\\", "/").replaceAll("|", ":");
}
/**
* All text up to but not including the first colon.
*/
static public Twine getProtcol(Twine uriText) {
int colon = uriText.indexOf(":");
E.require(colon >= 0, "':' not found: ", uriText);
return (Twine)uriText.run(0, colon);
}
/**
* All text after the first colon
*/
static public Twine getBody(Twine uriText) {
int colon = uriText.indexOf(":");
E.require(colon >= 0, "':' not found: ", uriText);
return (Twine)uriText.run(colon + 1, uriText.size());
}
/**
* According to <a href=
* "http://www.ics.uci.edu/pub/ietf/uri/rfc2396.txt"
* >BNF of opaque URIs (see Appendix A)</a> these are characters
* that can occur within a URI body: <p>
* <pre>
* a-z, A-Z, 0-9, any of ;/?:@&=+$,-_.!~*'()%
* </pre><p>
* In addition, by special dispensation, we allow '\\', which we
* normalize to '/', and '|', which we normalize to ':', and '#'
* which is the fragment indicator. <p>
*
* org.erights.e.elang.evm.FileGetter also does these
* normalizations dynamically.
*/
static public boolean isURICPart(char c) {
return c < 128 && URICs[c];
}
/**
* E's syntax for URI token expressions does not recognize URIs whose
* body begins with a '=' or a ':', since E's recognition of ":="
* as assignment takes priority, and E reserves "::" for future
* definition.
*/
static public boolean isURICStart(char c) {
return c < 128 && URICs[c] && c != '=' && c != ':';
}
}
1.19 +1 -1 e/src/jsrc/org/erights/e/elang/visitors/ETreeVisitor.java
Index: ETreeVisitor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/visitors/ETreeVisitor.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ETreeVisitor.java 2001/11/10 19:40:43 1.18
+++ ETreeVisitor.java 2001/12/01 07:52:13 1.19
@@ -129,7 +129,7 @@
/**
* varName. <p>
*
- * The result of a getValue on the slot named by this varName.
+ * The result of a getData on the slot named by this varName.
*
* @see <a href="{@docroot}/../elang/kernel/NounExpr.html">The
* Kernel-E Noun Expression</a>
1.32 +1 -1 e/src/jsrc/org/erights/e/elib/ref/Ref.java
Index: Ref.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/Ref.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Ref.java 2001/11/10 19:40:46 1.31
+++ Ref.java 2001/12/01 07:52:13 1.32
@@ -101,7 +101,7 @@
/**
* Makes a promise that should be resolved to a Slot, and which responds
- * to synchronous getValue() calls optimistically. Just like
+ * to synchronous getData() calls optimistically. Just like
* Ref.promise(), except it uses a SlotRef as the SwitchableRef.
*/
static public Object[] slotPromise() {
1.8 +15 -15 e/src/jsrc/org/erights/e/elib/ref/SlotRef.java
Index: SlotRef.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/SlotRef.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SlotRef.java 2001/11/11 00:15:31 1.7
+++ SlotRef.java 2001/12/01 07:52:13 1.8
@@ -23,11 +23,11 @@
/**
* A Ref that's expected to resolve to a Slot. It's special behavior is
- * that, even when EVENTUAL, it will respond to immediate getValue() calls
- * by handling out the Ref of a promise for the Slot's getValue(). When a
+ * that, even when EVENTUAL, it will respond to immediate getData() calls
+ * by handling out the Ref of a promise for the Slot's getData(). When a
* SlotRef gets committed, it must be directly committed to an object
- * that immediately responds to getValue(), as this will be called on the
- * resolution and used to resolve the promises made by previous getValue()s
+ * that immediately responds to getData(), as this will be called on the
+ * resolution and used to resolve the promises made by previous getData()s
* on this SlotPromise.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
@@ -49,13 +49,13 @@
/**
* In order to J-implement the Slot interface. Return a promise for the
- * getValue() of my future Slot.
+ * getData() of my future Slot.
*/
public Object getValue() {
if (null != myValueResolver) {
return myValueRef;
} else {
- return super.callAll("getValue", NO_ARGS);
+ return super.callAll("getData", NO_ARGS);
}
}
@@ -67,11 +67,11 @@
}
/**
- * Intercept immediate getValue() calls and return a promise for the
- * getValue() of my future Slot.
+ * Intercept immediate getData() calls and return a promise for the
+ * getData() of my future Slot.
*/
public Object callAll(String verb, Object[] args) {
- if (args.length == 0 && verb.equals("getValue")) {
+ if (args.length == 0 && verb.equals("getData")) {
return getValue();
} else {
return super.callAll(verb, args);
@@ -79,18 +79,18 @@
}
/**
- * If this SlotRef becomes committed to a presumed slot, immediately
- * resolve the result of previously synchronous getValue() calls (not
- * sends) to the result of calling getValue() on this . Otherwise, break
- * the promise returned by these getValue() calls.
- */
+ * If this SlotRef becomes committed to a presumed slot, immediately
+ * resolve the result of previously synchronous getData() calls (not
+ * sends) to the result of calling getData() on this . Otherwise, break
+ * the promise returned by these getData() calls.
+ */
/*package*/ void commit() {
super.commit();
Resolver valueResolver = myValueResolver;
myValueRef = null;
myValueResolver = null;
try {
- valueResolver.resolve(super.callAll("getValue", NO_ARGS));
+ valueResolver.resolve(super.callAll("getData", NO_ARGS));
} catch (Throwable problem) {
valueResolver.smash(problem);
}
1.16 +1 -1 e/src/jsrc/org/erights/e/elib/slot/RuinedSlot.java
Index: RuinedSlot.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/slot/RuinedSlot.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- RuinedSlot.java 2001/11/10 19:40:48 1.15
+++ RuinedSlot.java 2001/12/01 07:52:13 1.16
@@ -27,7 +27,7 @@
import java.io.IOException;
/**
- * A ruined slot responds to both getValue and setValue by throwing the
+ * A ruined slot responds to both getData and setValue by throwing the
* problem that explains why it's ruined.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
1.7 +1 -1 e/src/jsrc/org/erights/e/elib/slot/Slot.java
Index: Slot.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/slot/Slot.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Slot.java 2001/09/06 09:55:51 1.6
+++ Slot.java 2001/12/01 07:52:13 1.7
@@ -41,7 +41,7 @@
/**
* Sets the current value of the variable to be a coercion of specimen to
* a value that meets the constraints represented by this slot.
- * getValue() will then return this value. If the variable is final
+ * getData() will then return this value. If the variable is final
* (immutable), then throw an informative exception instead.
*/
void setValue(Object specimen);
1.19 +3 -5 e/src/jsrc/org/erights/e/elib/tables/ConstList.java
Index: ConstList.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstList.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ConstList.java 2001/11/19 19:15:35 1.18
+++ ConstList.java 2001/12/01 07:52:13 1.19
@@ -23,7 +23,6 @@
import org.erights.e.elib.prim.StaticMaker;
import org.erights.e.elib.prim.E;
import org.erights.e.elib.serial.PassByConstruction;
-import org.erights.e.elib.base.EComparable;
import java.io.IOException;
import java.lang.reflect.Array;
@@ -36,7 +35,7 @@
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public abstract class ConstList
- extends EList implements EComparable, PassByConstruction, Selfless {
+ extends EList implements PassByConstruction, Selfless {
static private final long serialVersionUID = -4704670888158933364L;
@@ -83,9 +82,8 @@
* comparison, in left-to-right order. If all compare equal but one list
* is shorter, the shorter list is less than the longer list.
*/
- public double compareTo(EComparable other) {
- return compareTo((ConstList)E.as(other, ConstList.class),
- SimpleCompFunc.THE_ONE);
+ public double compareTo(ConstList other) {
+ return compareTo(other, SimpleCompFunc.THE_ONE);
}
/**
1.31 +6 -8 e/src/jsrc/org/erights/e/elib/tables/ConstMap.java
Index: ConstMap.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstMap.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ConstMap.java 2001/11/20 12:32:06 1.30
+++ ConstMap.java 2001/12/01 07:52:13 1.31
@@ -24,7 +24,6 @@
import org.erights.e.elib.prim.E;
import org.erights.e.elib.serial.PassByConstruction;
import org.erights.e.elib.util.ArityMismatchException;
-import org.erights.e.elib.base.EComparable;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -46,7 +45,7 @@
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public abstract class ConstMap
- extends EMap implements EComparable, Selfless, PassByConstruction {
+ extends EMap implements Selfless, PassByConstruction {
static private final long serialVersionUID = -6424210992869387563L;
@@ -127,18 +126,17 @@
* alternate implementations of ConstMaps must also treat this as
* the base case. XXX security implications?
*/
- public double compareTo(EComparable other) {
- ConstMap omap = (ConstMap)E.as(other, ConstMap.class);
+ public double compareTo(ConstMap other) {
int sz = size();
- int otherSz = omap.size();
+ int otherSz = other.size();
if (sz < otherSz) {
- return -omap.compareTo(this);
+ return -other.compareTo(this);
}
//at this point, this ConstMap is at least as big as other, so this
//ConstMap's domain is either a superset (strict or not) or
//incomparable.
- ConstMap union = or(omap);
- ConstMap isect = and(omap);
+ ConstMap union = or(other);
+ ConstMap isect = and(other);
int unionSz = union.size();
int isectSz = isect.size();
if (unionSz == isectSz) {
1.4 +3 -5 e/src/jsrc/org/erights/e/elib/tables/ConstSet.java
Index: ConstSet.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/ConstSet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConstSet.java 2001/11/20 12:32:06 1.3
+++ ConstSet.java 2001/12/01 07:52:13 1.4
@@ -4,7 +4,6 @@
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.prim.StaticMaker;
import org.erights.e.elib.prim.E;
-import org.erights.e.elib.base.EComparable;
import java.io.IOException;
@@ -13,7 +12,7 @@
* @author <a href="mailto:markm@caplet.com">Mark S Miller</a>
*/
public class ConstSet
- extends ESet implements EComparable, PassByConstruction, Selfless {
+ extends ESet implements PassByConstruction, Selfless {
/**
*
@@ -81,8 +80,7 @@
* If this set is a strict superset of other, return 1.0.
* Otherwise return NaN.
*/
- public double compareTo(EComparable other) {
- ConstSet oset = (ConstSet)E.as(other, ConstSet.class);
- return getMap().compareTo(oset.getMap());
+ public double compareTo(ConstSet other) {
+ return getMap().compareTo(other.getMap());
}
}
1.24 +1 -2 e/src/jsrc/org/erights/e/elib/tables/Twine.java
Index: Twine.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tables/Twine.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Twine.java 2001/11/19 19:15:35 1.23
+++ Twine.java 2001/12/01 07:52:13 1.24
@@ -20,7 +20,6 @@
*/
import org.erights.e.elib.base.SourceSpan;
-import org.erights.e.elib.base.EComparable;
import org.erights.e.elib.prim.E;
import org.erights.e.elib.prim.StaticMaker;
@@ -437,7 +436,7 @@
* Optimized for the case where both are Twine. Otherwise should be
* identical.
*/
- public double compareTo(EComparable other) {
+ public double compareTo(ConstList other) {
if (other instanceof Twine) {
return (double)bare().compareTo(((Twine)other).bare());
} else {
1.42 +1 -0 e/src/jsrc/org/erights/e/ui/elmer/EInterpAdapter.java
Index: EInterpAdapter.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/ui/elmer/EInterpAdapter.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- EInterpAdapter.java 2001/11/27 07:27:54 1.41
+++ EInterpAdapter.java 2001/12/01 07:52:13 1.42
@@ -31,6 +31,7 @@
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.ConstMap;
import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.tables.EmptyTwine;
import org.erights.e.elib.util.AlreadyDefinedException;
import org.erights.e.ui.jed.JedMain;
1.4 +0 -1 e/src/jsrc/org/quasiliteral/astro/Astro.java
Index: Astro.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/astro/Astro.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Astro.java 2001/11/27 07:27:54 1.3
+++ Astro.java 2001/12/01 07:52:14 1.4
@@ -164,5 +164,4 @@
myOptToken.setType(type);
}
}
-
}
1.2 +74 -27 e/src/jsrc/org/quasiliteral/astro/AstroSchema.java
Index: AstroSchema.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/astro/AstroSchema.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AstroSchema.java 2001/11/27 07:27:54 1.1
+++ AstroSchema.java 2001/12/01 07:52:14 1.2
@@ -1,19 +1,31 @@
package org.quasiliteral.astro;
+import antlr.Token;
import org.erights.e.elib.serial.PassByConstruction;
import org.erights.e.elib.serial.Persistent;
import org.erights.e.elib.tables.Twine;
-import org.quasiliteral.term.Functor;
-import org.quasiliteral.term.Term;
-import antlr.Token;
-import antlr.collections.AST;
//This file is hereby placed in the public domain
/**
- * Used to describe an Antlr grammar, and provide the means for conversion
- * between the {@link AST} representation and the {@link Term} tree
- * represetation.
+ * Used to describe an Antlr grammar, and to build a tree that could represent
+ * the results of parsing such a grammar.
+ * <p>
+ * Several arguments and return types are 'Object' below because the actual
+ * types are to be determined by the implementors of AstroSchem. However,
+ * these choices need to be consistent. We express the required consistency
+ * using pretend parameterized types encoded in the javadoc comments.
+ * Concrete subclasses of AstroSchema should say what concrete types they use
+ * for these parameterized types.
+ * <p>
+ * The pretend parameterized types are: <pre>
+ * Leaf -- Leaves of the tree, representing tokens of the grammar.
+ * Node -- Lnternal nodes of the tree, looks like application of a Leaf
+ * as an functor to Args.
+ * Arg -- An individual argument in a list of arguments. Typically the
+ * same as Node, but not always. See QuasiTermSchema.
+ * Args -- Represents a list of Arg.
+ * </pre>
*
* @author <a href="mailto:markm@caplet.com">Mark Miller</a>
*/
@@ -63,7 +75,7 @@
* Gets the tag for literally representing the provided data, or null if
* data is the wrong kind.
*/
- AstroTag getOptLiteralDataTag(Object data);
+ AstroTag getOptDataTag(Object data);
/**
* Gets the tag for literally representing the provided data, or throws
@@ -71,43 +83,78 @@
*/
AstroTag getLiteralDataTag(Object data);
- /**
- * Converts a leaf from Functor to Token representation.
- */
- Token tokenFromFunctor(Functor functor);
-
/**
- * Converts a leaf from Token to Functor representation.
+ * Makes a Leaf (eg, a Token or Functor) not representing literal data,
+ * but just a type code
+ *
+ * @return :Leaf
*/
- Functor functorFromToken(Token token);
+ Object leafTag(int typeCode, Twine source);
/**
- * Converts an inner node from Term to AST representation.
+ * Makes a leaf (eg, a Token or Functor) representing literal data
+ *
+ * @return :Leaf
*/
- AST astFromTerm(Term term);
+ Object leafData(Object data, Twine source);
/**
- * Converts an inner node from AST to Term representation.
+ * Makes a Leaf or Node representing the given type code as parameterized
+ * by the given data.
+ * <p>
+ * Exists to support legacy usage of Antlr Tokens, and in order to allow
+ * lexers, which wish to emit composites, to still emit only leaves if
+ * allowed by the Schema.
+ * <p>
+ * Schema that don't allow composite leaves (like TermSchema) should
+ * instead emit the equivalent of <pre>
+ * node(leafTag(typeCode, src),
+ * argList(node(leafData(data, src), argList())))
+ * </pre>
+ *
+ * @return :(Leaf | Node)
*/
- Term termFromAst(AST ast);
+ Object composite(int typeCode, Object data, Twine source);
/**
- * Makes a token not representing literal data
+ * Names an internal node (eg, an AST or Term), for which 'func' is the
+ * "label" and 'args' are the arguments.
+ * <p>
+ * May be destructive of 'args'
+ *
+ * @param func :Leaf
+ * @param args :Args
+ * @return :Node
*/
- Token newToken(int typeCode, Twine source);
+ Object node(Object func, Object args);
/**
- * Makes a functor not representing literal data
+ * The empty args list
+ *
+ * @return :Args
*/
- Functor newFunctor(int typeCode, Twine source);
+ Object argList();
/**
- * Makes a token representing literal data
+ * The args list of one element.
+ * <p>
+ * May be destructive of that element, as when it's an AST.
+ * <p>
+ * Should be equivalent to 'argList(argList(), first)'
+ *
+ * @param first :Arg
+ * @return :Args
*/
- Token literalToken(Twine source, Object data);
+ Object argList(Object first);
/**
- * Makes a functor representing literal data
+ * Extend args list with an additional term, like a backwards cons.
+ * <p>
+ * May be destructive of 'list' and 'next'
+ *
+ * @param list :Args
+ * @param next :Arg
+ * @return :Args
*/
- Functor literalFunctor(Twine source, Object data);
+ Object argList(Object list, Object next);
}
1.2 +34 -15 e/src/jsrc/org/quasiliteral/astro/AstroTag.java
Index: AstroTag.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/astro/AstroTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AstroTag.java 2001/11/27 07:27:54 1.1
+++ AstroTag.java 2001/12/01 07:52:14 1.2
@@ -1,9 +1,9 @@
package org.quasiliteral.astro;
-import org.erights.e.elib.tables.Selfless;
-import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.serial.PassByConstruction;
import org.erights.e.elib.serial.Persistent;
+import org.erights.e.elib.tables.Twine;
//This file is hereby placed in the public domain
@@ -24,9 +24,9 @@
public class AstroTag implements PassByConstruction, Persistent {
/**
- * The enumerated type code
+ * The enumerated type code, or Token.INVALID_TYPE.
*/
- private final int myTypeCode;
+ private final int myOptTypeCode;
/**
* The name of the enumerated type code.
@@ -34,37 +34,56 @@
private final Twine myTypeName;
/**
- * The schema of which this tag is a member
+ * The schema of which this tag is a member, or null.
*/
- private final AstroSchema mySchema;
+ private final AstroSchema myOptSchema;
/**
*
+ * @param optTypeCode The enumerated type code, or Token.INVALID_TYPE.
+ * @param typeName The name of the enumerated type code.
+ * @param optSchema The schema of which this tag is a member, or null.
*/
- public AstroTag(int typeCode, Twine typeName, AstroSchema schema) {
- myTypeCode = typeCode;
+ public AstroTag(int optTypeCode, Twine typeName, AstroSchema optSchema) {
+ myOptTypeCode = optTypeCode;
myTypeName = typeName;
- mySchema = schema;
+ myOptSchema = optSchema;
}
/**
- *
+ * The enumerated type code, or Token.INVALID_TYPE.
*/
- public int getTypeCode() {
- return myTypeCode;
+ public int getOptTypeCode() {
+ return myOptTypeCode;
}
/**
- *
+ * The name of the enumerated type code.
*/
public Twine getTypeName() {
return myTypeName;
}
/**
+ * The schema of which this tag is a member, or null.
+ */
+ public AstroSchema getOptSchema() {
+ return myOptSchema;
+ }
+
+ /**
*
*/
- public AstroSchema getSchema() {
- return mySchema;
+ public double compareTo(AstroTag other) {
+ if (Ref.same(myOptSchema, other.myOptSchema) ||
+ null == myOptSchema ||
+ null == other.myOptSchema) {
+ //if they have the same schema, or if either of both has no,
+ //schema, then they are compared based on their typeNames.
+ return myTypeName.compareTo(other.myTypeName);
+ } else {
+ //otherwise, they are incomparable.
+ return Double.NaN;
+ }
}
}
1.7 +87 -80 e/src/jsrc/org/quasiliteral/astro/AstroToken.java
Index: AstroToken.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/astro/AstroToken.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AstroToken.java 2001/11/27 07:27:54 1.6
+++ AstroToken.java 2001/12/01 07:52:14 1.7
@@ -1,13 +1,10 @@
package org.quasiliteral.astro;
-import antlr.CommonToken;
+import antlr.Token;
import org.erights.e.elib.base.SourceSpan;
-import org.erights.e.elib.tables.ConstList;
-import org.erights.e.elib.tables.Twine;
-import org.erights.e.elib.tables.EmptyTwine;
import org.erights.e.elib.prim.E;
import org.erights.e.elib.ref.Ref;
-import org.quasiliteral.term.Functor;
+import org.erights.e.elib.tables.Twine;
/**
* A Kind of Antlr {@link Token} that preserves all the information in a
@@ -20,7 +17,7 @@
* @author <a href="mailto:markm@caplet.com">Mark S Miller</a>
* @author Based on ValueExtentToken by Danfuzz Bornstein
*/
-public class AstroToken extends CommonToken {
+public class AstroToken extends Token {
/**
*
@@ -28,18 +25,18 @@
private AstroTag myOptTag;
/**
- *
- */
- private Twine mySource;
-
- /**
* Must be a null, {@link Character}, {@link BigInteger}, {@link Double},
* {@link String}, or {@link Twine}. If not null, then the type must
* correspond to the tag.
*/
- private Object myOptValue;
+ private Object myOptData;
/**
+ *
+ */
+ private Twine myOptSource;
+
+ /**
* Construct an instance.
* <p>
* The instance will be of type {@link #INVALID_TYPE}, and have empty
@@ -49,51 +46,37 @@
super();
}
- /**
- * Makes a token without literal data.
- */
- public AstroToken(AstroTag tag, Twine source) {
- super(tag.getTypeCode(), source.bare());
- myOptTag = tag;
- setSource(source);
- myOptValue = null;
- }
-
/**
- * Makes a token representing 'value' as literal data.
+ * Makes a Token that represents a token in some grammar.
*
* @param tag Identifies a token type in a particular grammar or set
- * of related grammars.
+ * of related grammars.
+ * @param optData {@link Character},
+ * {@link BigInteger}, {@link Double},
+ * {@link String}, or {@link Twine} presumably calculated
+ * from lexing this token
* @param source The source text this token was extracted from. To
* provide no info, use "" rather than null.
- * @param value {@link Character},
- * {@link BigInteger}, {@link Double},
- * {@link String}, or {@link Twine} calculated from
- * lexing this token
*/
- public AstroToken(AstroTag tag, Twine source, Object value) {
- super(tag.getTypeCode(), source.bare());
+ public AstroToken(AstroTag tag, Object optData, Twine source) {
+ super(tag.getOptTypeCode());
myOptTag = tag;
+ myOptData = optData;
setSource(source);
- myOptValue = value;
- E.require(Ref.same(tag.getSchema().getOptLiteralDataTag(value),
- tag),
- "tag mismatch");
}
/**
*
*/
- public AstroTag getTag() {
- E.require(null != myOptTag, "No tag");
+ public AstroTag getOptTag() {
return myOptTag;
}
/**
*
*/
- public AstroSchema getSchema() {
- return myOptTag.getSchema();
+ public AstroSchema getOptSchema() {
+ return myOptTag.getOptSchema();
}
/**
@@ -108,14 +91,39 @@
E.require(INVALID_TYPE != getType(), "Type-code not yet set");
myOptTag = schema.getTagForCode(getType());
}
+
+ /**
+ * Override to make set-once
+ */
+ public void setType(int t) {
+ E.require(INVALID_TYPE == getType(), "Type-code already set");
+ super.setType(t);
+ }
+
+ /**
+ * If this token represents literal data, return that data,
+ * else null.
+ */
+ public Object getOptData() {
+ return myOptData;
+ }
+
/**
*
*/
- public Twine getSource() {
- return mySource;
+ public Object getData() {
+ E.require(null != myOptData, "No data");
+ return myOptData;
}
/**
+ *
+ */
+ public Twine getOptSource() {
+ return myOptSource;
+ }
+
+ /**
* If 'source' has source-span info, then setSource also sets line and
* column.
* <p>
@@ -126,73 +134,72 @@
* thrown.
*/
public void setSource(Twine source) {
- E.require(null == mySource, "Source already set");
- //XXX should we be setting text here? How should we think about text?
- setText(source.bare());
- SourceSpan optSpan = source.optSourceSpan();
- if (null != optSpan) {
- setLine(optSpan.getStartLine());
- setColumn(optSpan.getStartCol());
- }
- //do this last to avoid tests in setLine and setColumn
- mySource = source;
+ E.require(null == myOptSource, "Source already set");
+ myOptSource = source;
}
/**
- * If this token represents a value as literal data, return that value,
- * else null.
- */
- public Object getOptValue() {
- return myOptValue;
- }
-
- /**
- * If this token represents a value as literal data, return that value,
- * else throw an exception.
+ *
*/
- public Object getValue() {
- E.require(null != myOptValue, "No value: ", this);
- return myOptValue;
+ public String getText() {
+ if (null == myOptSource) {
+ return null;
+ } else {
+ return myOptSource.bare();
+ }
}
/**
*
*/
- public Functor asFunctor() {
- return myOptTag.getSchema().functorFromToken(this);
+ public int getLine() {
+ if (null == myOptSource) {
+ return 0;
+ }
+ SourceSpan optSpan = myOptSource.optSourceSpan();
+ if (null == optSpan) {
+ return 0;
+ }
+ return optSpan.getStartLine();
}
/**
- * Override to make set-once
+ * Override to make set-once, and so set the source-span info of
+ * myOptSource
*/
- public void setType(int t) {
- E.require(INVALID_TYPE == getType(), "Type-code already set");
- super.setType(t);
+ public void setLine(int l) {
+ E.require(getLine() == 0, "Line already set");
+ throw new RuntimeException("XXX setLine not yet implemented");
}
/**
- * Override to make set-once
+ *
*/
- public void setLine(int l) {
- E.require(getLine() == 0, "Line already set");
- E.require(null == mySource, "Source already set");
- super.setLine(l);
+ public int getColumn() {
+ if (null == myOptSource) {
+ return 0;
+ }
+ SourceSpan optSpan = myOptSource.optSourceSpan();
+ if (null == optSpan) {
+ return 0;
+ }
+ return optSpan.getStartCol();
}
/**
- * Override to make set-once
+ * Override to make set-once, and so set the source-span info of
+ * myOptSource
*/
public void setColumn(int c) {
E.require(getColumn() == 0, "Column already set");
- E.require(null == mySource, "Source already set");
- super.setColumn(c);
+ throw new RuntimeException("XXX setColumn not yet implemented");
}
/**
- * Override to make set-once
+ * Override to make set-once, and to set myOptSource
*/
public void setText(String s) {
- E.require(null == text, "Text already set");
- super.setText(s);
+ E.require(null == myOptSource, "Source already set");
+ setSource(Twine.fromString(s));
}
}
1.2 +79 -64 e/src/jsrc/org/quasiliteral/astro/BaseSchema.java
Index: BaseSchema.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/astro/BaseSchema.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseSchema.java 2001/11/27 07:27:54 1.1
+++ BaseSchema.java 2001/12/01 07:52:14 1.2
@@ -1,25 +1,28 @@
package org.quasiliteral.astro;
-import org.erights.e.elib.tables.Selfless;
+import antlr.Token;
+import org.erights.e.elib.prim.E;
import org.erights.e.elib.tables.ConstMap;
-import org.erights.e.elib.tables.Twine;
import org.erights.e.elib.tables.FlexList;
import org.erights.e.elib.tables.FlexMap;
-import org.erights.e.elib.serial.PassByConstruction;
-import org.erights.e.elib.serial.Persistent;
-import org.erights.e.elib.prim.E;
-import org.erights.e.elib.base.SourceSpan;
-import org.quasiliteral.term.Functor;
-import org.quasiliteral.term.Term;
-import antlr.Token;
-import antlr.collections.AST;
+import org.erights.e.elib.tables.Twine;
+import org.erights.e.elib.tables.ConstList;
import java.math.BigInteger;
//This file is hereby placed in the public domain
/**
- *
+ * The default implementation (and default superclass) for implementing
+ * AstroSchema simply, starting with an array of type names, and building
+ * Astro-trees with AstroToken leaves.
+ * <p>
+ * The type parameterization of AstroSchema is: <pre>
+ * Leaf is AstroToken
+ * Node is Astro
+ * Arg is Astro
+ * Args is null (for empty list) or Astro (for it and its siblings).
+ * </pre>
*
* @author <a href="mailto:markm@caplet.com">Mark Miller</a>
*/
@@ -58,16 +61,17 @@
/**
*
*/
- public BaseSchema(Twine[] typeNames) {
+ public BaseSchema(ConstList typeNames) {
FlexList byCodes = FlexList.fromType(AstroTag.class,
- typeNames.length);
+ typeNames.size());
FlexMap byNames = FlexMap.fromTypes(String.class,
AstroTag.class,
- typeNames.length);
- for (int code = 0; code < typeNames.length; code++) {
- Twine optTypeName = typeNames[code];
+ typeNames.size());
+ for (int code = 0; code < typeNames.size(); code++) {
+ Twine optTypeName = (Twine)E.as(typeNames.get(code), Twine.class);
if (null != optTypeName) {
AstroTag tag = new AstroTag(code, optTypeName, this);
+ byCodes.ensureSize(code);
byCodes.put(code, tag);
byNames.put(optTypeName.bare(), tag, true);
}
@@ -149,7 +153,7 @@
/**
*
*/
- public AstroTag getOptLiteralDataTag(Object data) {
+ public AstroTag getOptDataTag(Object data) {
if (data instanceof Character) {
return getLiteralCharTag();
@@ -158,8 +162,7 @@
data instanceof Short ||
data instanceof Integer ||
data instanceof Long ||
- data instanceof BigInteger)
- {
+ data instanceof BigInteger) {
return getLiteralIntegerTag();
} else if (data instanceof Float || data instanceof Double) {
return getLiteralFloat64Tag();
@@ -176,82 +179,94 @@
*
*/
public AstroTag getLiteralDataTag(Object data) {
- AstroTag result = getOptLiteralDataTag(data);
+ AstroTag result = getOptDataTag(data);
E.require(null != result, "Not a literal type: ", data.getClass());
return result;
}
/**
- *
+ * @return :AstroToken
*/
- public Token tokenFromFunctor(Functor functor) {
- return new AstroToken(functor.getTag(),
- functor.getSource(),
- functor.getValue());
+ public Object leafTag(int typeCode, Twine source) {
+ return new AstroToken(getTagForCode(typeCode), null, source);
}
/**
- *
+ * @param data Must not be null
+ * @param source
+ * @return :AstroToken
*/
- public Functor functorFromToken(Token token) {
- if (token instanceof AstroToken) {
- AstroToken at = (AstroToken)token;
- return new Functor(at.getTag(),
- at.getSource(),
- at.getOptValue());
- } else {
- AstroTag tag = getTagForCode(token.getType());
- SourceSpan span = new SourceSpan("unknown",
- false,
- token.getLine(),
- token.getColumn(),
- token.getLine(),
- token.getColumn());
- return new Functor(tag,
- Twine.fromString(token.getText(), span),
- null);
- }
+ public Object leafData(Object data, Twine source) {
+ return new AstroToken(getLiteralDataTag(data), data, source);
}
/**
+ * Returns a complex token rather than a AST.
*
+ * @param data Nust not be null
+ * @return :AstroToken
*/
- public AST astFromTerm(Term term) {
- throw new RuntimeException("XXX not yet implemented");
+ public Object composite(int typeCode, Object data, Twine source) {
+ return new AstroToken(getTagForCode(typeCode), data, source);
}
/**
- *
+ * @param func :AstroToken
+ * @param args :(Astro | null)
+ * @return :Astro
*/
- public Term termFromAst(AST ast) {
- throw new RuntimeException("XXX not yet implemented");
- }
-
- /**
- *
- */
- public Token newToken(int typeCode, Twine source) {
- return new AstroToken(getTagForCode(typeCode), source);
+ public Object node(Object func, Object args) {
+ AstroToken funcToken = (AstroToken)func;
+ Astro optArgs = (Astro)args;
+ Astro result = new Astro(funcToken);
+ for (; null != optArgs; optArgs = (Astro)optArgs.getNextSibling()) {
+ result.addChild(optArgs);
+ }
+ return result;
}
/**
- *
+ * @return null
*/
- public Functor newFunctor(int typeCode, Twine source) {
- return new Functor(getTagForCode(typeCode), source);
+ public Object argList() {
+ return null;
}
/**
+ * Returns 'first' after severing its nest sibling pointer
*
+ * @param first :Astro
+ * @return :Astro
*/
- public Token literalToken(Twine source, Object data) {
- return new AstroToken(getLiteralDataTag(data), source, data)
+ public Object argList(Object first) {
+ Astro result = (Astro)first;
+ result.setNextSibling(null);
+ return result;
}
/**
+ * Modifies the last sibling in 'list' to be 'next', which is modified to
+ * not have any further siblings.
*
- */
- public Functor literalFunctor(Twine source, Object data) {
- return new Functor(getLiteralDataTag(data), source, data)
+ * @param list :(Astro | null)
+ * @param next :Astro
+ * @return :Astro
+ */
+ public Object argList(Object list, Object next) {
+ Astro optList = (Astro)list;
+ Astro nextNode = (Astro)next;
+ nextNode.setNextSibling(null);
+ if (null == optList) {
+ return next;
+ }
+ Astro sib = optList;
+ while (true) {
+ Astro optNextSib = (Astro)sib.getNextSibling();
+ if (null == optNextSib) {
+ sib.setNextSibling(nextNode);
+ return optList;
+ }
+ sib = optNextSib;
+ }
}
}
1.11 +5 -0 e/src/jsrc/org/quasiliteral/term/Term.updoc
Index: Term.updoc
===================================================================
RCS file: /cvs/e/src/jsrc/org/quasiliteral/term/Term.updoc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Term.updoc 2001/11/21 14:21:32 1.10
+++ Term.updoc 2001/12/01 07:52:14 1.11
@@ -1,3 +1,8 @@
+ ? 2 + 3
+ # value: 5
+
+ ?
+
? def t1 := term`"foo"`
# value: term`"foo"`