wheat-cvs Mailing List for Wheat (Page 3)
Status: Pre-Alpha
Brought to you by:
mark_lentczner
You can subscribe to this list here.
2005 |
Jan
(152) |
Feb
(248) |
Mar
(69) |
Apr
(27) |
May
(3) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Mark L. <mar...@us...> - 2005-03-24 22:16:31
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29353/wheat Modified Files: compiler-test.cpp Log Message: support for mode declarations in dynamic objects Index: compiler-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/compiler-test.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- compiler-test.cpp 24 Mar 2005 19:17:54 -0000 1.37 +++ compiler-test.cpp 24 Mar 2005 22:16:22 -0000 1.38 @@ -356,6 +356,15 @@ " a: 80; b: \"deb\"; }; }\n" "o3(): { return {:self: a: 99; b: \"sue\"; }; }\n" "o4(): { return {:self: c: 99 } }\n" + "t(): { return {\n" + " -- instance --\n" + " i: ???\n" + " -- public --\n" + " p: ???\n" + " -- private --\n" + " x: ???\n" + "} }\n" + "tf(m): { return #t().member-access-flags(m) }\n" ); CHECK_SAME("/library/base/object", @@ -380,6 +389,10 @@ //CHECK(c.target().send("o4").error()); // we'd like this to be some sort of error, but we're not sure what + + CHECK_SAME("rwrwrwc-", c.target().send("tf", String("i")).asString()); + CHECK_SAME("rwrwrw--", c.target().send("tf", String("p")).asString()); + CHECK_SAME("rw------", c.target().send("tf", String("x")).asString()); } TEST(compiler, arrays) |
From: Mark L. <mar...@us...> - 2005-03-24 22:16:31
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29353/grammar Modified Files: ScriptCompiler.cpp ScriptCompiler.g Log Message: support for mode declarations in dynamic objects Index: ScriptCompiler.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- ScriptCompiler.cpp 24 Mar 2005 19:18:26 -0000 1.35 +++ ScriptCompiler.cpp 24 Mar 2005 22:16:21 -0000 1.36 @@ -1789,6 +1789,7 @@ Wheat::MethodBuilder::Register r; antlr::RefSpanAST buildObject_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; antlr::RefSpanAST i = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST key = antlr::RefSpanAST(antlr::nullAST); antlr::RefSpanAST x = antlr::RefSpanAST(antlr::nullAST); try { // for error handling @@ -1798,6 +1799,7 @@ match(antlr::RefAST(_t),BUILD_OBJECT); _t = _t->getFirstChild(); MethodBuilder::Register p; + ObjectAccess af = AccessDefault; p=buildProto(_t,mb); _t = _retTree; r = mb.genNewObject(p); @@ -1826,15 +1828,32 @@ c.addPosArg(mb.genLiteral(op)); op.storeString(astString(i)); c.addPosArg(v); + if (af != AccessDefault) { + c.addKeyArg("flags", + mb.genLiteral(op)); + op.storeInt(af); + } mb.genCall(c); } + else if ((_t->getType() == MODE)) { + antlr::RefSpanAST __t115 = _t; + antlr::RefSpanAST tmp56_AST_in = _t; + match(antlr::RefAST(_t),MODE); + _t = _t->getFirstChild(); + key = _t; + match(antlr::RefAST(_t),ID); + _t = _t->getNextSibling(); + _t = __t115; + _t = _t->getNextSibling(); + af = decodeMode(key); + } else { - goto _loop115; + goto _loop116; } } - _loop115:; + _loop116:; } // ( ... )* { // ( ... )* for (;;) { @@ -1848,11 +1867,11 @@ "unrecognized element when building object", x); } else { - goto _loop117; + goto _loop118; } } - _loop117:; + _loop118:; } // ( ... )* _t = __t112; _t = _t->getNextSibling(); @@ -1874,8 +1893,8 @@ try { // for error handling SOURCE(buildInstance_AST_in); - antlr::RefSpanAST __t119 = _t; - antlr::RefSpanAST tmp56_AST_in = _t; + antlr::RefSpanAST __t120 = _t; + antlr::RefSpanAST tmp57_AST_in = _t; match(antlr::RefAST(_t),BUILD_INSTANCE); _t = _t->getFirstChild(); MethodBuilder::Register p; @@ -1888,8 +1907,8 @@ _t = ASTNULL; if ((_t->getType() == MEMBER)) { MethodBuilder::Register v; - antlr::RefSpanAST __t121 = _t; - antlr::RefSpanAST tmp57_AST_in = _t; + antlr::RefSpanAST __t122 = _t; + antlr::RefSpanAST tmp58_AST_in = _t; match(antlr::RefAST(_t),MEMBER); _t = _t->getFirstChild(); i = _t; @@ -1897,7 +1916,7 @@ _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; - _t = __t121; + _t = __t122; _t = _t->getNextSibling(); MethodBuilder::Call c; @@ -1912,11 +1931,11 @@ } else { - goto _loop122; + goto _loop123; } } - _loop122:; + _loop123:; } // ( ... )* { // ( ... )* for (;;) { @@ -1930,13 +1949,13 @@ "unrecognized element when building instance", x); } else { - goto _loop124; + goto _loop125; } } - _loop124:; + _loop125:; } // ( ... )* - _t = __t119; + _t = __t120; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1954,8 +1973,8 @@ try { // for error handling SOURCE(buildArray_AST_in); - antlr::RefSpanAST __t126 = _t; - antlr::RefSpanAST tmp58_AST_in = _t; + antlr::RefSpanAST __t127 = _t; + antlr::RefSpanAST tmp59_AST_in = _t; match(antlr::RefAST(_t),BUILD_ARRAY); _t = _t->getFirstChild(); MethodBuilder::Register p; @@ -1979,13 +1998,13 @@ } else { - goto _loop128; + goto _loop129; } } - _loop128:; + _loop129:; } // ( ... )* - _t = __t126; + _t = __t127; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -2003,8 +2022,8 @@ try { // for error handling SOURCE(buildError_AST_in); - antlr::RefSpanAST __t131 = _t; - antlr::RefSpanAST tmp59_AST_in = _t; + antlr::RefSpanAST __t132 = _t; + antlr::RefSpanAST tmp60_AST_in = _t; match(antlr::RefAST(_t),BUILD_ERROR); _t = _t->getFirstChild(); @@ -2033,13 +2052,13 @@ } else { - goto _loop133; + goto _loop134; } } - _loop133:; + _loop134:; } // ( ... )* - _t = __t131; + _t = __t132; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -2088,7 +2107,7 @@ } case ABSENT: { - antlr::RefSpanAST tmp60_AST_in = _t; + antlr::RefSpanAST tmp61_AST_in = _t; match(antlr::RefAST(_t),ABSENT); _t = _t->getNextSibling(); Index: ScriptCompiler.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.g,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- ScriptCompiler.g 24 Mar 2005 19:17:52 -0000 1.27 +++ ScriptCompiler.g 24 Mar 2005 22:16:21 -0000 1.28 @@ -522,6 +522,7 @@ returns [Wheat::MethodBuilder::Register r]: { SOURCE(#buildObject); } #(BUILD_OBJECT { MethodBuilder::Register p; } + { ObjectAccess af = AccessDefault; } p=buildProto[mb] { r = mb.genNewObject(p); } ( options{greedy=true;}: { MethodBuilder::Register v; } #(MEMBER i:ID v=reference[mb]) @@ -533,8 +534,14 @@ c.addPosArg(mb.genLiteral(op)); op.storeString(astString(i)); c.addPosArg(v); + if (af != AccessDefault) { + c.addKeyArg("flags", + mb.genLiteral(op)); + op.storeInt(af); + } mb.genCall(c); } + | #(MODE key:ID) { af = decodeMode(key); } )* ( x:. { throw buildException( "unrecognized element when building object", #x); } |
From: Mark L. <mar...@us...> - 2005-03-24 21:54:48
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15242/wheat Modified Files: baselibrary.cpp Log Message: added flags: argument to object.add-member for specifying the access flags -- takes either a number or string added object.member-access-flags() for querying the access flags of a member -- always returns a string Note: this interface is primarily for the compiler - however, I don't think the design is that elegant - when we refactor the object introspection stuff, this should change Index: baselibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/baselibrary.cpp,v retrieving revision 1.105 retrieving revision 1.106 diff -u -d -r1.105 -r1.106 --- baselibrary.cpp 12 Mar 2005 01:02:27 -0000 1.105 +++ baselibrary.cpp 24 Mar 2005 21:54:39 -0000 1.106 @@ -17,6 +17,7 @@ #include "lowleveldebug.hpp" #include "bytearray.hpp" #include "instruction.hpp" +#include "xmlutil.hpp" #include "tinytemplate.h" #include "utils.h" @@ -127,19 +128,32 @@ Self self(f); Argument name(f); Argument value(f); + Argument flags(f, "flags"); pt::string nameStr = name.asString(); if (pt::isempty(nameStr)) { - throw Wheat::Exception("system/baselibrary/exception/bad-member-name") + throw Wheat::Exception( + "system/baselibrary/exception/bad-member-name") << nameStr; } + ObjectAccess af = AccessNone; + if (flags.isUnknown()) { af = AccessDefault; } + else if (flags.isInt()) { af = (ObjectAccess)flags.asInt(); } + else if (flags.isString()) + { af = XMLUtil::accessFromString(flags.asString()); } + if (af == AccessNone) { + throw Wheat::Exception( + "system/baselibrary/exception/bad-access-flags"); + } + { ObjectPointer selfOp = PrimitiveAccess::targetObject(self); ObjectPointer valueOp = PrimitiveAccess::targetObject(value); ObjectPointer memberOp = selfOp.member(nameStr, true); memberOp.copy(valueOp); + memberOp.accessFlags(af); } return value; @@ -334,6 +348,20 @@ } Return + objectMemberAccessFlags(Frame& f, int code) + { + Self self(f); + Argument part(f); + + ObjectPointer memberOp = extractMember(self, part); + checkValid(memberOp); + + pt::string afStr = + XMLUtil::accessToString(memberOp.accessFlags(), true); + return Return(f, String(afStr)); + } + + Return objectInvoke(Frame& f, int code) { Self self(f); @@ -1099,6 +1127,7 @@ { "object/array-add", arrayAdd, 0 }, { "object/[]", objectMember, 0 }, { "object/is-copydown", objectIsCopydown, 0 }, + { "object/member-access-flags", objectMemberAccessFlags,0 }, { "object/methods", objectMembers, Members_Methods }, { "object/invoke", objectInvoke, 0 }, |
From: Mark L. <mar...@us...> - 2005-03-24 21:54:47
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15242/root/library Modified Files: base.ws Log Message: added flags: argument to object.add-member for specifying the access flags -- takes either a number or string added object.member-access-flags() for querying the access flags of a member -- always returns a string Note: this interface is primarily for the compiler - however, I don't think the design is that elegant - when we refactor the object introspection stuff, this should change Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- base.ws 24 Mar 2005 19:17:53 -0000 1.54 +++ base.ws 24 Mar 2005 21:54:39 -0000 1.55 @@ -41,6 +41,7 @@ has-member: {:'/library/base/primitive':} remove-member: {:'/library/base/primitive':} is-copydown: {:'/library/base/primitive':} + member-access-flags: {:'/library/base/primitive':} array-size: {:'/library/base/primitive':} array-add: {:'/library/base/primitive':} '[]': {:'/library/base/primitive':} @@ -575,6 +576,34 @@ thing.is-copydown("banana")); } + test-member-access-flags(): { + thing := \#thing-with-access-flags + #assert-equals("rwrwrw--", + thing.member-access-flags("public-member")) + #assert-equals("rwrwrwc-", + thing.member-access-flags("instance-member")) + #assert-equals("rw------", + thing.member-access-flags("private-member")) + #assert-equals("r-r-r---", + thing.member-access-flags("read-only-member")) + #assert-equals("rwrwrw-x", + thing.member-access-flags("method-member")) + } + + -- private -- + thing-with-access-flags: { + -- instance -- + instance-member: ??? + -- public -- + public-member: ??? + method-member(): { } + -- private -- + private-member: ??? + -- 'r-r-r---' -- + read-only-member: ??? + } + + -- public -- test-member(): { t := $/library/base/tests/simple-thing.new(); t.x := 43; @@ -599,6 +628,23 @@ #assert("doesn't have non-copied instance", ~t.has-member("y")); } + test-member-add(): { + t := $/library/base/tests/simple-thing.new() + #assert("z mising", ~t.has-member("z")) + + t.add-member("z", 42) + #assert("z added", t.has-member("z")) + #assert-equals(42, t.z) + #assert-equals("rwrwrw--", t.member-access-flags("z")) + + t.add-member("as", 42, flags: "rwr-r---") + #assert-equals("rwr-r---", t.member-access-flags("as")) + + t.add-member("an", 42, flags: 232) + #assert-equals("rwr-r---", t.member-access-flags("an")) + } + + test-member-remove(): { t := $/library/base/tests/simple-thing.new(); t.x := 3; @@ -619,7 +665,7 @@ t.remove-member("name"); #assert("still understands name", t.understands("name")); } - + -- private -- simple-thing: { |
From: Mark L. <mar...@us...> - 2005-03-24 19:18:45
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16542/grammar Modified Files: ScriptCompiler.cpp ScriptCompiler.hpp ScriptCompilerTokenTypes.hpp ScriptCompilerTokenTypes.txt ScriptLexer.cpp ScriptLexer.hpp ScriptLexerTokenTypes.hpp ScriptLexerTokenTypes.txt ScriptParser.cpp ScriptParser.hpp ScriptParserTokenTypes.hpp ScriptParserTokenTypes.txt Log Message: check in of Antlr built sources for last change Index: ScriptCompiler.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- ScriptCompiler.cpp 19 Mar 2005 01:43:34 -0000 1.34 +++ ScriptCompiler.cpp 24 Mar 2005 19:18:26 -0000 1.35 @@ -809,6 +809,7 @@ case LOCAL: case GLOBAL: case BUILD_OBJECT: + case BUILD_INSTANCE: case BUILD_ARRAY: case BUILD_ERROR: { @@ -1095,6 +1096,7 @@ case LOCAL: case GLOBAL: case BUILD_OBJECT: + case BUILD_INSTANCE: case BUILD_ARRAY: case BUILD_ERROR: { @@ -1504,6 +1506,12 @@ _t = _retTree; break; } + case BUILD_INSTANCE: + { + r=buildInstance(_t,mb); + _t = _retTree; + break; + } case BUILD_ARRAY: { r=buildArray(_t,mb); @@ -1789,8 +1797,8 @@ antlr::RefSpanAST tmp54_AST_in = _t; match(antlr::RefAST(_t),BUILD_OBJECT); _t = _t->getFirstChild(); - MethodBuilder::Register p; bool nop; - p=buildProto(_t,mb, nop); + MethodBuilder::Register p; + p=buildProto(_t,mb); _t = _retTree; r = mb.genNewObject(p); { // ( ... )* @@ -1813,21 +1821,11 @@ MethodBuilder::Call c; c.setReceiver(r); - if (nop) { ObjectPointer op; c.setMessage("add-member"); c.addPosArg(mb.genLiteral(op)); op.storeString(astString(i)); c.addPosArg(v); - } - else { - c.setMessage(astString(i)); - ObjectPointer trueOp; - c.addKeyArg("assign", - mb.genLiteral(trueOp)); - trueOp.storeBool(true); - c.addKeyArg("value", v); - } mb.genCall(c); } @@ -1866,6 +1864,88 @@ return r; } +Wheat::MethodBuilder::Register ScriptCompiler::buildInstance(antlr::RefSpanAST _t, + Wheat::MethodBuilder& mb +) { + Wheat::MethodBuilder::Register r; + antlr::RefSpanAST buildInstance_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; + antlr::RefSpanAST i = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST x = antlr::RefSpanAST(antlr::nullAST); + + try { // for error handling + SOURCE(buildInstance_AST_in); + antlr::RefSpanAST __t119 = _t; + antlr::RefSpanAST tmp56_AST_in = _t; + match(antlr::RefAST(_t),BUILD_INSTANCE); + _t = _t->getFirstChild(); + MethodBuilder::Register p; + p=buildProto(_t,mb); + _t = _retTree; + r = mb.genNewObject(p); + { // ( ... )* + for (;;) { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + if ((_t->getType() == MEMBER)) { + MethodBuilder::Register v; + antlr::RefSpanAST __t121 = _t; + antlr::RefSpanAST tmp57_AST_in = _t; + match(antlr::RefAST(_t),MEMBER); + _t = _t->getFirstChild(); + i = _t; + match(antlr::RefAST(_t),ID); + _t = _t->getNextSibling(); + v=reference(_t,mb); + _t = _retTree; + _t = __t121; + _t = _t->getNextSibling(); + + MethodBuilder::Call c; + c.setReceiver(r); + c.setMessage(astString(i)); + ObjectPointer trueOp; + c.addKeyArg("assign", + mb.genLiteral(trueOp)); + trueOp.storeBool(true); + c.addKeyArg("value", v); + mb.genCall(c); + + } + else { + goto _loop122; + } + + } + _loop122:; + } // ( ... )* + { // ( ... )* + for (;;) { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + if (((_t->getType() >= NEWLINE && _t->getType() <= GLOBAL_ID))) { + x = _t; + if ( _t == antlr::RefSpanAST(antlr::nullAST) ) throw antlr::MismatchedTokenException(); + _t = _t->getNextSibling(); + throw buildException( + "unrecognized element when building instance", x); + } + else { + goto _loop124; + } + + } + _loop124:; + } // ( ... )* + _t = __t119; + _t = _t->getNextSibling(); + } + catch (const Wheat::Exception& e) { + throw buildException(e, buildInstance_AST_in); + } + _retTree = _t; + return r; +} + Wheat::MethodBuilder::Register ScriptCompiler::buildArray(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ) { @@ -1874,12 +1954,12 @@ try { // for error handling SOURCE(buildArray_AST_in); - antlr::RefSpanAST __t119 = _t; - antlr::RefSpanAST tmp56_AST_in = _t; + antlr::RefSpanAST __t126 = _t; + antlr::RefSpanAST tmp58_AST_in = _t; match(antlr::RefAST(_t),BUILD_ARRAY); _t = _t->getFirstChild(); - MethodBuilder::Register p; bool nop; - p=buildProto(_t,mb, nop); + MethodBuilder::Register p; + p=buildProto(_t,mb); _t = _retTree; r = mb.genNewArray(p); { // ( ... )* @@ -1899,13 +1979,13 @@ } else { - goto _loop121; + goto _loop128; } } - _loop121:; + _loop128:; } // ( ... )* - _t = __t119; + _t = __t126; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1923,8 +2003,8 @@ try { // for error handling SOURCE(buildError_AST_in); - antlr::RefSpanAST __t124 = _t; - antlr::RefSpanAST tmp57_AST_in = _t; + antlr::RefSpanAST __t131 = _t; + antlr::RefSpanAST tmp59_AST_in = _t; match(antlr::RefAST(_t),BUILD_ERROR); _t = _t->getFirstChild(); @@ -1953,13 +2033,13 @@ } else { - goto _loop126; + goto _loop133; } } - _loop126:; + _loop133:; } // ( ... )* - _t = __t124; + _t = __t131; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1970,7 +2050,7 @@ } Wheat::MethodBuilder::Register ScriptCompiler::buildProto(antlr::RefSpanAST _t, - Wheat::MethodBuilder& mb, bool& nop + Wheat::MethodBuilder& mb ) { Wheat::MethodBuilder::Register r; antlr::RefSpanAST buildProto_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; @@ -1991,7 +2071,6 @@ c.setReceiver(r); c.setMessage("absolute-path"); r = mb.genCall(c); - nop = false; break; } @@ -2004,20 +2083,18 @@ ObjectPointer op; r = mb.genLiteral(op); op.storePath(Path(astString(i))); - nop = false; break; } case ABSENT: { - antlr::RefSpanAST tmp58_AST_in = _t; + antlr::RefSpanAST tmp60_AST_in = _t; match(antlr::RefAST(_t),ABSENT); _t = _t->getNextSibling(); ObjectPointer op; r = mb.genLiteral(op); op.storePath(Path(Path::Empty)); - nop = true; break; } @@ -2055,6 +2132,8 @@ "\":\"", "\"--\"", "\"->\"", + "\"<\"", + "\">\"", "\"?\"", "\"??\"", "\"???\"", @@ -2102,6 +2181,7 @@ "LOCAL", "GLOBAL", "BUILD_OBJECT", + "BUILD_INSTANCE", "BUILD_ARRAY", "BUILD_ERROR", "ABSENT", @@ -2132,12 +2212,12 @@ 0 }; -const unsigned long ScriptCompiler::_tokenSet_0_data_[] = { 235470848UL, 560UL, 288UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptCompiler::_tokenSet_0_data_[] = { 941686784UL, 2240UL, 2304UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // "->" "???" "null" "true" "false" ARRAY OBJECT METHOD NUMBER STRING const antlr::BitSet ScriptCompiler::_tokenSet_0(_tokenSet_0_data_,8); -const unsigned long ScriptCompiler::_tokenSet_1_data_[] = { 1179648UL, 4260511744UL, 3UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptCompiler::_tokenSet_1_data_[] = { 4718592UL, 4157145088UL, 31UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // "?" "!" CONDITIONAL LOOP ASSIGN SHORT UNARY BINARY CALL LITERAL SELF -// THIS LOCAL GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR +// THIS LOCAL GLOBAL BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR const antlr::BitSet ScriptCompiler::_tokenSet_1(_tokenSet_1_data_,8); Index: ScriptCompiler.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.hpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptCompiler.hpp 19 Mar 2005 01:43:34 -0000 1.24 +++ ScriptCompiler.hpp 24 Mar 2005 19:18:27 -0000 1.25 @@ -156,6 +156,9 @@ public: Wheat::MethodBuilder::Register buildObject(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ); + public: Wheat::MethodBuilder::Register buildInstance(antlr::RefSpanAST _t, + Wheat::MethodBuilder& mb + ); public: Wheat::MethodBuilder::Register buildArray(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ); @@ -163,7 +166,7 @@ Wheat::MethodBuilder& mb ); public: Wheat::MethodBuilder::Register buildProto(antlr::RefSpanAST _t, - Wheat::MethodBuilder& mb, bool& nop + Wheat::MethodBuilder& mb ); public: antlr::RefAST getAST() @@ -177,10 +180,10 @@ private: static const char* tokenNames[]; #ifndef NO_STATIC_CONSTS - static const int NUM_TOKENS = 91; + static const int NUM_TOKENS = 94; #else enum { - NUM_TOKENS = 91 + NUM_TOKENS = 94 }; #endif Index: ScriptCompilerTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompilerTokenTypes.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ScriptCompilerTokenTypes.txt 18 Mar 2005 07:18:49 -0000 1.18 +++ ScriptCompilerTokenTypes.txt 24 Mar 2005 19:18:27 -0000 1.19 @@ -13,77 +13,80 @@ COLON=":"=14 DASHDASH="--"=15 LINK="->"=16 -IS_DEFINED="?"=17 -SHORT_DEFINED="??"=18 -V_UNKNOWN="???"=19 -IS_ERROR="!"=20 -SHORT_ERROR="!!"=21 -V_ERROR="!!!"=22 -AS_LINK="\\"=23 -AS_IS="\\\\"=24 -V_NULL="null"=25 -V_TRUE="true"=26 -V_FALSE="false"=27 -SHORT_AND="&&"=28 -SHORT_OR="||"=29 -ASSIGN_OP=":="=30 -ASSIGN_SUFFIX="="=31 -SCRIPT=32 -DECLS=33 -USE=34 -PATH=35 -ARRAY=36 -OBJECT=37 -MODE=38 -MEMBER=39 -INCLUDE=40 -METHOD=41 -ARGS=42 -ARG_POS=43 -ARG_KEY=44 -BLOCK=45 -CONDITIONAL=46 -IF=47 -ELSE=48 -LOOP=49 -BREAK=50 -RETURN=51 -ASSIGN=52 -SHORT=53 -UNARY=54 -BINARY=55 -CALL=56 -AS_COPY=57 -LITERAL=58 -SELF=59 -THIS=60 -LOCAL=61 -GLOBAL=62 -BUILD_OBJECT=63 -BUILD_ARRAY=64 -BUILD_ERROR=65 -ABSENT=66 -LITERAL_wheat="wheat"=67 -LITERAL_version="version"=68 -NUMBER=69 -LITERAL_charset="charset"=70 -LITERAL_use="use"=71 -STRING=72 -LITERAL_as="as"=73 -ID=74 -LITERAL_include="include"=75 -LITERAL_if="if"=76 -LITERAL_else="else"=77 -LITERAL_while="while"=78 -LITERAL_break="break"=79 -LITERAL_return="return"=80 -LITERAL_do="do"=81 -LITERAL_self="self"=82 -LITERAL_this="this"=83 -OP_1=84 -OP_2=85 -OP_3=86 -OP_4=87 -OP_5=88 -INSTANCE_ID=89 -GLOBAL_ID=90 +OP_2_LT="<"=17 +OP_2_GT=">"=18 +IS_DEFINED="?"=19 +SHORT_DEFINED="??"=20 +V_UNKNOWN="???"=21 +IS_ERROR="!"=22 +SHORT_ERROR="!!"=23 +V_ERROR="!!!"=24 +AS_LINK="\\"=25 +AS_IS="\\\\"=26 +V_NULL="null"=27 +V_TRUE="true"=28 +V_FALSE="false"=29 +SHORT_AND="&&"=30 +SHORT_OR="||"=31 +ASSIGN_OP=":="=32 +ASSIGN_SUFFIX="="=33 +SCRIPT=34 +DECLS=35 +USE=36 +PATH=37 +ARRAY=38 +OBJECT=39 +MODE=40 +MEMBER=41 +INCLUDE=42 +METHOD=43 +ARGS=44 +ARG_POS=45 +ARG_KEY=46 +BLOCK=47 +CONDITIONAL=48 +IF=49 +ELSE=50 +LOOP=51 +BREAK=52 +RETURN=53 +ASSIGN=54 +SHORT=55 +UNARY=56 +BINARY=57 +CALL=58 +AS_COPY=59 +LITERAL=60 +SELF=61 +THIS=62 +LOCAL=63 +GLOBAL=64 +BUILD_OBJECT=65 +BUILD_INSTANCE=66 +BUILD_ARRAY=67 +BUILD_ERROR=68 +ABSENT=69 +LITERAL_wheat="wheat"=70 +LITERAL_version="version"=71 +NUMBER=72 +LITERAL_charset="charset"=73 +LITERAL_use="use"=74 +STRING=75 +LITERAL_as="as"=76 +ID=77 +LITERAL_include="include"=78 +LITERAL_if="if"=79 +LITERAL_else="else"=80 +LITERAL_while="while"=81 +LITERAL_break="break"=82 +LITERAL_return="return"=83 +LITERAL_do="do"=84 +LITERAL_self="self"=85 +LITERAL_this="this"=86 +OP_1=87 +OP_2=88 +OP_3=89 +OP_4=90 +OP_5=91 +INSTANCE_ID=92 +GLOBAL_ID=93 Index: ScriptCompilerTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompilerTokenTypes.hpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ScriptCompilerTokenTypes.hpp 18 Mar 2005 07:18:49 -0000 1.18 +++ ScriptCompilerTokenTypes.hpp 24 Mar 2005 19:18:27 -0000 1.19 @@ -25,80 +25,83 @@ COLON = 14, DASHDASH = 15, LINK = 16, - IS_DEFINED = 17, - SHORT_DEFINED = 18, - V_UNKNOWN = 19, - IS_ERROR = 20, - SHORT_ERROR = 21, - V_ERROR = 22, - AS_LINK = 23, - AS_IS = 24, - V_NULL = 25, - V_TRUE = 26, - V_FALSE = 27, - SHORT_AND = 28, - SHORT_OR = 29, - ASSIGN_OP = 30, - ASSIGN_SUFFIX = 31, - SCRIPT = 32, - DECLS = 33, - USE = 34, - PATH = 35, - ARRAY = 36, - OBJECT = 37, - MODE = 38, - MEMBER = 39, - INCLUDE = 40, - METHOD = 41, - ARGS = 42, - ARG_POS = 43, - ARG_KEY = 44, - BLOCK = 45, - CONDITIONAL = 46, - IF = 47, - ELSE = 48, - LOOP = 49, - BREAK = 50, - RETURN = 51, - ASSIGN = 52, - SHORT = 53, - UNARY = 54, - BINARY = 55, - CALL = 56, - AS_COPY = 57, - LITERAL = 58, - SELF = 59, - THIS = 60, - LOCAL = 61, - GLOBAL = 62, - BUILD_OBJECT = 63, - BUILD_ARRAY = 64, - BUILD_ERROR = 65, - ABSENT = 66, - LITERAL_wheat = 67, - LITERAL_version = 68, - NUMBER = 69, - LITERAL_charset = 70, - LITERAL_use = 71, - STRING = 72, - LITERAL_as = 73, - ID = 74, - LITERAL_include = 75, - LITERAL_if = 76, - LITERAL_else = 77, - LITERAL_while = 78, - LITERAL_break = 79, - LITERAL_return = 80, - LITERAL_do = 81, - LITERAL_self = 82, - LITERAL_this = 83, - OP_1 = 84, - OP_2 = 85, - OP_3 = 86, - OP_4 = 87, - OP_5 = 88, - INSTANCE_ID = 89, - GLOBAL_ID = 90, + OP_2_LT = 17, + OP_2_GT = 18, + IS_DEFINED = 19, + SHORT_DEFINED = 20, + V_UNKNOWN = 21, + IS_ERROR = 22, + SHORT_ERROR = 23, + V_ERROR = 24, + AS_LINK = 25, + AS_IS = 26, + V_NULL = 27, + V_TRUE = 28, + V_FALSE = 29, + SHORT_AND = 30, + SHORT_OR = 31, + ASSIGN_OP = 32, + ASSIGN_SUFFIX = 33, + SCRIPT = 34, + DECLS = 35, + USE = 36, + PATH = 37, + ARRAY = 38, + OBJECT = 39, + MODE = 40, + MEMBER = 41, + INCLUDE = 42, + METHOD = 43, + ARGS = 44, + ARG_POS = 45, + ARG_KEY = 46, + BLOCK = 47, + CONDITIONAL = 48, + IF = 49, + ELSE = 50, + LOOP = 51, + BREAK = 52, + RETURN = 53, + ASSIGN = 54, + SHORT = 55, + UNARY = 56, + BINARY = 57, + CALL = 58, + AS_COPY = 59, + LITERAL = 60, + SELF = 61, + THIS = 62, + LOCAL = 63, + GLOBAL = 64, + BUILD_OBJECT = 65, + BUILD_INSTANCE = 66, + BUILD_ARRAY = 67, + BUILD_ERROR = 68, + ABSENT = 69, + LITERAL_wheat = 70, + LITERAL_version = 71, + NUMBER = 72, + LITERAL_charset = 73, + LITERAL_use = 74, + STRING = 75, + LITERAL_as = 76, + ID = 77, + LITERAL_include = 78, + LITERAL_if = 79, + LITERAL_else = 80, + LITERAL_while = 81, + LITERAL_break = 82, + LITERAL_return = 83, + LITERAL_do = 84, + LITERAL_self = 85, + LITERAL_this = 86, + OP_1 = 87, + OP_2 = 88, + OP_3 = 89, + OP_4 = 90, + OP_5 = 91, + INSTANCE_ID = 92, + GLOBAL_ID = 93, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptLexer.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- ScriptLexer.cpp 18 Mar 2005 07:18:49 -0000 1.30 +++ ScriptLexer.cpp 24 Mar 2005 19:18:27 -0000 1.31 @@ -30,47 +30,49 @@ void ScriptLexer::initLiterals() { - literals["!!!"] = 22; + literals["!!!"] = 24; literals[","] = 11; literals["]"] = 8; - literals["break"] = 79; - literals["while"] = 78; - literals["??"] = 18; - literals["||"] = 29; + literals["break"] = 82; + literals["while"] = 81; + literals["??"] = 20; + literals["||"] = 31; literals["["] = 7; - literals["return"] = 80; + literals["return"] = 83; literals[")"] = 6; - literals["null"] = 25; + literals["null"] = 27; literals["->"] = 16; - literals["charset"] = 70; + literals["charset"] = 73; literals["("] = 5; - literals["do"] = 81; - literals["\\\\"] = 24; - literals["include"] = 75; + literals["do"] = 84; + literals["\\\\"] = 26; + literals["include"] = 78; literals["}"] = 10; - literals["version"] = 68; - literals["?"] = 17; - literals["if"] = 76; - literals["as"] = 73; - literals["wheat"] = 67; + literals["version"] = 71; + literals["?"] = 19; + literals["if"] = 79; + literals[">"] = 18; + literals["as"] = 76; + literals["wheat"] = 70; literals["{"] = 9; - literals["="] = 31; + literals["="] = 33; literals["--"] = 15; - literals["false"] = 27; - literals["this"] = 83; - literals["???"] = 19; - literals["!!"] = 21; - literals[":="] = 30; + literals["<"] = 17; + literals["false"] = 29; + literals["this"] = 86; + literals["???"] = 21; + literals["!!"] = 23; + literals[":="] = 32; literals[";"] = 13; - literals["&&"] = 28; + literals["&&"] = 30; literals["."] = 12; - literals["else"] = 77; + literals["else"] = 80; literals[":"] = 14; - literals["self"] = 82; - literals["!"] = 20; - literals["true"] = 26; - literals["use"] = 71; - literals["\\"] = 23; + literals["self"] = 85; + literals["!"] = 22; + literals["true"] = 28; + literals["use"] = 74; + literals["\\"] = 25; } antlr::RefToken ScriptLexer::nextToken() @@ -284,12 +286,16 @@ mCOMMENT(true); theRetToken=_returnToken; } + else if ((LA(1) == 0x3c /* '<' */ || LA(1) == 0x3e /* '>' */ ) && (_tokenSet_0.member(LA(2)))) { + mOP_2(true); + theRetToken=_returnToken; + } else if ((LA(1) == 0x3c /* '<' */ ) && (LA(2) == 0x3d /* '=' */ ) && (true)) { - mOP_2_LT(true); + mOP_2_LE(true); theRetToken=_returnToken; } else if ((LA(1) == 0x3e /* '>' */ ) && (LA(2) == 0x3d /* '=' */ )) { - mOP_2_GT(true); + mOP_2_GE(true); theRetToken=_returnToken; } else if ((LA(1) == 0x21 /* '!' */ ) && (LA(2) == 0x3d /* '=' */ )) { @@ -312,8 +318,12 @@ mSHORT_ERROR(true); theRetToken=_returnToken; } - else if ((LA(1) == 0x3c /* '<' */ || LA(1) == 0x3e /* '>' */ ) && (true)) { - mOP_2(true); + else if ((LA(1) == 0x3c /* '<' */ ) && (true)) { + mOP_2_LT(true); + theRetToken=_returnToken; + } + else if ((LA(1) == 0x3e /* '>' */ ) && (true)) { + mOP_2_GT(true); theRetToken=_returnToken; } else if ((LA(1) == 0x28 /* '(' */ ) && (true)) { @@ -460,7 +470,7 @@ if ( inputState->guessing==0 ) { #line 43 "ScriptLexer.g" newline(); -#line 464 "ScriptLexer.cpp" +#line 474 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -478,9 +488,9 @@ match("``"); { // ( ... )* for (;;) { - if ((_tokenSet_0.member(LA(1)))) { + if ((_tokenSet_1.member(LA(1)))) { { - match(_tokenSet_0); + match(_tokenSet_1); } } else { @@ -569,17 +579,17 @@ inputState->guessing++; try { { - if ((LA(1) == 0x60 /* '`' */ ) && (_tokenSet_1.member(LA(2)))) { + if ((LA(1) == 0x60 /* '`' */ ) && (_tokenSet_2.member(LA(2)))) { match('`'); matchNot('`'); } else if ((LA(1) == 0x60 /* '`' */ ) && (LA(2) == 0x60 /* '`' */ )) { match("``"); { - match(_tokenSet_2); + match(_tokenSet_3); } } - else if ((_tokenSet_1.member(LA(1)))) { + else if ((_tokenSet_2.member(LA(1)))) { matchNot('`'); } else { @@ -682,7 +692,7 @@ if ( inputState->guessing==0 ) { #line 66 "ScriptLexer.g" _ttype = antlr::Token::SKIP; -#line 686 "ScriptLexer.cpp" +#line 696 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -701,7 +711,7 @@ if ( inputState->guessing==0 ) { #line 70 "ScriptLexer.g" _ttype = antlr::Token::SKIP; -#line 705 "ScriptLexer.cpp" +#line 715 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -760,7 +770,7 @@ if ( inputState->guessing==0 ) { #line 77 "ScriptLexer.g" _ttype = antlr::Token::SKIP; -#line 764 "ScriptLexer.cpp" +#line 774 "ScriptLexer.cpp" } } else { @@ -786,7 +796,7 @@ if ( inputState->guessing==0 ) { #line 76 "ScriptLexer.g" _ttype = antlr::Token::SKIP; -#line 790 "ScriptLexer.cpp" +#line 800 "ScriptLexer.cpp" } } else { @@ -991,7 +1001,7 @@ if ( inputState->guessing==0 ) { #line 90 "ScriptLexer.g" _ttype = testLiteralsTable(ID); -#line 995 "ScriptLexer.cpp" +#line 1005 "ScriptLexer.cpp" } break; } @@ -1263,7 +1273,7 @@ else if ((LA(1) == 0x2e /* '.' */ ) && (true)) { match("."); } - else if ((_tokenSet_3.member(LA(1)))) { + else if ((_tokenSet_4.member(LA(1)))) { { // ( ... )+ int _cnt53=0; for (;;) { @@ -1389,7 +1399,7 @@ if ( synPredMatched56 ) { mMULTI_LINE_STRING(false); } - else if ((LA(1) == 0x22 /* '"' */ ) && (_tokenSet_0.member(LA(2))) && (true)) { + else if ((LA(1) == 0x22 /* '"' */ ) && (_tokenSet_1.member(LA(2))) && (true)) { mSIMPLE_STRING(false); } else { @@ -1456,9 +1466,9 @@ break; } default: - if ((_tokenSet_4.member(LA(1)))) { + if ((_tokenSet_5.member(LA(1)))) { { - match(_tokenSet_4); + match(_tokenSet_5); } } else { @@ -1474,7 +1484,7 @@ if ( inputState->guessing==0 ) { #line 118 "ScriptLexer.g" append('\n'); -#line 1478 "ScriptLexer.cpp" +#line 1488 "ScriptLexer.cpp" } } else { @@ -1508,9 +1518,9 @@ if ((LA(1) == 0x5c /* '\\' */ )) { mESCAPE(false); } - else if ((_tokenSet_4.member(LA(1)))) { + else if ((_tokenSet_5.member(LA(1)))) { { - match(_tokenSet_4); + match(_tokenSet_5); } } else { @@ -1549,7 +1559,7 @@ if ( inputState->guessing==0 ) { #line 124 "ScriptLexer.g" append('\n'); -#line 1553 "ScriptLexer.cpp" +#line 1563 "ScriptLexer.cpp" } break; } @@ -1561,7 +1571,7 @@ if ( inputState->guessing==0 ) { #line 125 "ScriptLexer.g" append('\r'); -#line 1565 "ScriptLexer.cpp" +#line 1575 "ScriptLexer.cpp" } break; } @@ -1628,15 +1638,15 @@ { // ( ... )* for (;;) { - if ((_tokenSet_5.member(LA(1)))) { + if ((_tokenSet_0.member(LA(1)))) { mOP_CHAR(false); } else { - goto _loop93; + goto _loop95; } } - _loop93:; + _loop95:; } // ( ... )* if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1689,7 +1699,7 @@ if ( inputState->guessing==0 ) { #line 134 "ScriptLexer.g" _ttype = testLiteralsTable(OP_4); -#line 1693 "ScriptLexer.cpp" +#line 1703 "ScriptLexer.cpp" } break; } @@ -1746,7 +1756,7 @@ if ( inputState->guessing==0 ) { #line 140 "ScriptLexer.g" _ttype = NUMBER; -#line 1750 "ScriptLexer.cpp" +#line 1760 "ScriptLexer.cpp" } } else { @@ -1754,7 +1764,7 @@ if ( inputState->guessing==0 ) { #line 139 "ScriptLexer.g" _ttype = testLiteralsTable(OP_3); -#line 1758 "ScriptLexer.cpp" +#line 1768 "ScriptLexer.cpp" } } @@ -1798,6 +1808,7 @@ } } } + mOP_CHAR(false); mOP_CHARS(false); if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1807,16 +1818,138 @@ _saveIndex=0; } +void ScriptLexer::mOP_CHAR(bool _createToken) { + int _ttype; antlr::RefToken _token; int _begin=text.length(); + _ttype = OP_CHAR; + int _saveIndex; + + switch ( LA(1)) { + case 0x21 /* '!' */ : + { + match('!'); + break; + } + case 0x25 /* '%' */ : + { + match('%'); + break; + } + case 0x26 /* '&' */ : + { + match('&'); + break; + } + case 0x2a /* '*' */ : + { + match('*'); + break; + } + case 0x2b /* '+' */ : + { + match('+'); + break; + } + case 0x2d /* '-' */ : + { + match('-'); + break; + } + case 0x2f /* '/' */ : + { + match('/'); + break; + } + case 0x3c /* '<' */ : + { + match('<'); + break; + } + case 0x3e /* '>' */ : + { + match('>'); + break; + } + case 0x3f /* '?' */ : + { + match('?'); + break; + } + case 0x40 /* '@' */ : + { + match('@'); + break; + } + case 0x5c /* '\\' */ : + { + match('\\'); + break; + } + case 0x5e /* '^' */ : + { + match('^'); + break; + } + case 0x7c /* '|' */ : + { + match('|'); + break; + } + case 0x7e /* '~' */ : + { + match('~'); + break; + } + default: + { + throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn()); + } + } + if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { + _token = makeToken(_ttype); + _token->setText(text.substr(_begin, text.length()-_begin)); + } + _returnToken = _token; + _saveIndex=0; +} + void ScriptLexer::mOP_2_LT(bool _createToken) { int _ttype; antlr::RefToken _token; int _begin=text.length(); _ttype = OP_2_LT; int _saveIndex; + match("<"); + if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { + _token = makeToken(_ttype); + _token->setText(text.substr(_begin, text.length()-_begin)); + } + _returnToken = _token; + _saveIndex=0; +} + +void ScriptLexer::mOP_2_GT(bool _createToken) { + int _ttype; antlr::RefToken _token; int _begin=text.length(); + _ttype = OP_2_GT; + int _saveIndex; + + match(">"); + if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { + _token = makeToken(_ttype); + _token->setText(text.substr(_begin, text.length()-_begin)); + } + _returnToken = _token; + _saveIndex=0; +} + +void ScriptLexer::mOP_2_LE(bool _createToken) { + int _ttype; antlr::RefToken _token; int _begin=text.length(); + _ttype = OP_2_LE; + int _saveIndex; + match("<="); if ( inputState->guessing==0 ) { -#line 144 "ScriptLexer.g" +#line 146 "ScriptLexer.g" _ttype = OP_2; -#line 1820 "ScriptLexer.cpp" +#line 1953 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1826,16 +1959,16 @@ _saveIndex=0; } -void ScriptLexer::mOP_2_GT(bool _createToken) { +void ScriptLexer::mOP_2_GE(bool _createToken) { int _ttype; antlr::RefToken _token; int _begin=text.length(); - _ttype = OP_2_GT; + _ttype = OP_2_GE; int _saveIndex; match(">="); if ( inputState->guessing==0 ) { -#line 145 "ScriptLexer.g" +#line 147 "ScriptLexer.g" _ttype = OP_2; -#line 1839 "ScriptLexer.cpp" +#line 1972 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1852,9 +1985,9 @@ match("!="); if ( inputState->guessing==0 ) { -#line 146 "ScriptLexer.g" +#line 148 "ScriptLexer.g" _ttype = OP_2; -#line 1858 "ScriptLexer.cpp" +#line 1991 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1871,9 +2004,9 @@ match("=="); if ( inputState->guessing==0 ) { -#line 147 "ScriptLexer.g" +#line 149 "ScriptLexer.g" _ttype = OP_2; -#line 1877 "ScriptLexer.cpp" +#line 2010 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1890,9 +2023,9 @@ match("<=>"); if ( inputState->guessing==0 ) { -#line 148 "ScriptLexer.g" +#line 150 "ScriptLexer.g" _ttype = OP_2; -#line 1896 "ScriptLexer.cpp" +#line 2029 "ScriptLexer.cpp" } if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { _token = makeToken(_ttype); @@ -1935,100 +2068,6 @@ _saveIndex=0; } -void ScriptLexer::mOP_CHAR(bool _createToken) { - int _ttype; antlr::RefToken _token; int _begin=text.length(); - _ttype = OP_CHAR; - int _saveIndex; - - switch ( LA(1)) { - case 0x21 /* '!' */ : - { - match('!'); - break; - } - case 0x25 /* '%' */ : - { - match('%'); - break; - } - case 0x26 /* '&' */ : - { - match('&'); - break; - } - case 0x2a /* '*' */ : - { - match('*'); - break; - } - case 0x2b /* '+' */ : - { - match('+'); - break; - } - case 0x2d /* '-' */ : - { - match('-'); - break; - } - case 0x2f /* '/' */ : - { - match('/'); - break; - } - case 0x3c /* '<' */ : - { - match('<'); - break; - } - case 0x3e /* '>' */ : - { - match('>'); - break; - } - case 0x3f /* '?' */ : - { - match('?'); - break; - } - case 0x40 /* '@' */ : - { - match('@'); - break; - } - case 0x5c /* '\\' */ : - { - match('\\'); - break; - } - case 0x5e /* '^' */ : - { - match('^'); - break; - } - case 0x7c /* '|' */ : - { - match('|'); - break; - } - case 0x7e /* '~' */ : - { - match('~'); - break; - } - default: - { - throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn()); - } - } - if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) { - _token = makeToken(_ttype); - _token->setText(text.substr(_begin, text.length()-_begin)); - } - _returnToken = _token; - _saveIndex=0; -} - void ScriptLexer::mLPAREN(bool _createToken) { int _ttype; antlr::RefToken _token; int _begin=text.length(); _ttype = LPAREN; @@ -2282,68 +2321,69 @@ } -const unsigned long ScriptLexer::_tokenSet_0_data_[] = { 4294958079UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptLexer::_tokenSet_0_data_[] = { 0UL, 3489705058UL, 1342177281UL, 1342177280UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +// "=" PATH ARRAY INCLUDE METHOD ARG_POS BLOCK LITERAL THIS LOCAL GLOBAL +// INSTANCE_ID WSCHAR +const antlr::BitSet ScriptLexer::_tokenSet_0(_tokenSet_0_data_,10); +const unsigned long ScriptLexer::_tokenSet_1_data_[] = { 4294958079UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "," "." -// ":" "--" "->" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" "true" -// "false" "&&" "||" ":=" "=" SCRIPT DECLS USE PATH ARRAY OBJECT MODE MEMBER -// INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF ELSE LOOP BREAK -// RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL SELF THIS LOCAL -// GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR ABSENT "wheat" "version" -// NUMBER "charset" "use" STRING "as" ID "include" "if" "else" "while" -// "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID -// GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT COMMENT WHITESPACE -// SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE -// OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA -const antlr::BitSet ScriptLexer::_tokenSet_0(_tokenSet_0_data_,16); -const unsigned long ScriptLexer::_tokenSet_1_data_[] = { 4294967295UL, 4294967295UL, 4294967295UL, 4294967294UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; -// null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "}" "," -// "." ";" ":" "--" "->" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" +// ":" "--" "->" "<" ">" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" // "true" "false" "&&" "||" ":=" "=" SCRIPT DECLS USE PATH ARRAY OBJECT // MODE MEMBER INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF // ELSE LOOP BREAK RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL -// SELF THIS LOCAL GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR ABSENT "wheat" -// "version" NUMBER "charset" "use" STRING "as" ID "include" "if" "else" -// "while" "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 -// INSTANCE_ID GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT WHITESPACE -// SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE -// OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA +// SELF THIS LOCAL GLOBAL BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR +// ABSENT "wheat" "version" NUMBER "charset" "use" STRING "as" ID "include" +// "if" "else" "while" "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 +// OP_4 OP_5 INSTANCE_ID GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT +// COMMENT WHITESPACE SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LE +// OP_2_GE OP_2_NE OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA const antlr::BitSet ScriptLexer::_tokenSet_1(_tokenSet_1_data_,16); -const unsigned long ScriptLexer::_tokenSet_2_data_[] = { 4294967295UL, 4294966783UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptLexer::_tokenSet_2_data_[] = { 4294967295UL, 4294967295UL, 4294967295UL, 4294967294UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "}" "," -// "." ";" ":" "--" "->" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" -// "true" "false" "&&" "||" ":=" "=" SCRIPT DECLS USE PATH ARRAY OBJECT -// MODE MEMBER INCLUDE ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF ELSE LOOP -// BREAK RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL SELF THIS -// LOCAL GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR ABSENT "wheat" "version" -// NUMBER "charset" "use" STRING "as" ID "include" "if" "else" "while" -// "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID -// GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT COMMENT WHITESPACE -// SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE -// OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA +// "." ";" ":" "--" "->" "<" ">" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" +// "null" "true" "false" "&&" "||" ":=" "=" SCRIPT DECLS USE PATH ARRAY +// OBJECT MODE MEMBER INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL +// IF ELSE LOOP BREAK RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL +// SELF THIS LOCAL GLOBAL BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR +// ABSENT "wheat" "version" NUMBER "charset" "use" STRING "as" ID "include" +// "if" "else" "while" "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 +// OP_4 OP_5 INSTANCE_ID GLOBAL_ID WSCHAR WS LINE_COMMENT NEST_COMMENT +// COMMENT WHITESPACE SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LE +// OP_2_GE OP_2_NE OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA const antlr::BitSet ScriptLexer::_tokenSet_2(_tokenSet_2_data_,16); -const unsigned long ScriptLexer::_tokenSet_3_data_[] = { 0UL, 67051520UL, 134217726UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; -// BLOCK ELSE LOOP BREAK RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY -// BUILD_ERROR ABSENT "wheat" "version" NUMBER "charset" "use" STRING "as" -// ID "include" "if" "else" "while" "break" "return" "do" "self" "this" -// OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID GLOBAL_ID WHITESPACE SEGMENT SIMPLE_STRING -// MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE OP_2_EQ OP_2_CMP OP_CHARS -// OP_CHAR DIGIT ALPHA -const antlr::BitSet ScriptLexer::_tokenSet_3(_tokenSet_3_data_,10); -const unsigned long ScriptLexer::_tokenSet_4_data_[] = { 4294958079UL, 4294967291UL, 4026531839UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptLexer::_tokenSet_3_data_[] = { 4294967295UL, 4294966783UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +// null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "}" "," +// "." ";" ":" "--" "->" "<" ">" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" +// "null" "true" "false" "&&" "||" ":=" "=" SCRIPT DECLS USE PATH ARRAY +// OBJECT MODE INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF +// ELSE LOOP BREAK RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL +// SELF THIS LOCAL GLOBAL BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR +// ABSENT "wheat" "version" NUMBER "charset" "use" STRING "as" ID "include" +// "if" "else" "while" "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 +// OP_4 OP_5 INSTANCE_ID GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT +// COMMENT WHITESPACE SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LE +// OP_2_GE OP_2_NE OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA +const antlr::BitSet ScriptLexer::_tokenSet_3(_tokenSet_3_data_,16); +const unsigned long ScriptLexer::_tokenSet_4_data_[] = { 0UL, 67051520UL, 134217726UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +// ARG_POS CONDITIONAL IF ELSE LOOP BREAK RETURN ASSIGN SHORT UNARY BINARY +// BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR ABSENT "wheat" "version" +// NUMBER "charset" "use" STRING "as" ID "include" "if" "else" "while" +// "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 LINE_COMMENT +// NEST_COMMENT COMMENT WHITESPACE SEGMENT SIMPLE_STRING MULTI_LINE_STRING +// ESCAPE OP_2_LE OP_2_GE OP_2_NE OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT +// ALPHA +const antlr::BitSet ScriptLexer::_tokenSet_4(_tokenSet_4_data_,10); +const unsigned long ScriptLexer::_tokenSet_5_data_[] = { 4294958079UL, 4294967291UL, 4026531839UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "," "." -// ":" "--" "->" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" "true" -// "false" "&&" "||" ":=" "=" SCRIPT DECLS PATH ARRAY OBJECT MODE MEMBER +// ":" "--" "->" "<" ">" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" +// "true" "false" "&&" "||" ":=" "=" DECLS USE PATH ARRAY OBJECT MODE MEMBER // INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF ELSE LOOP BREAK // RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL SELF THIS LOCAL -// GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR ABSENT "wheat" "version" -// NUMBER "charset" "use" STRING "as" ID "include" "if" "else" "while" -// "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID -// GLOBAL_ID WSCHAR NL LINE_COMMENT NEST_COMMENT COMMENT WHITESPACE SEGMENT -// SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE OP_2_EQ -// OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA -const antlr::BitSet ScriptLexer::_tokenSet_4(_tokenSet_4_data_,16); -const unsigned long ScriptLexer::_tokenSet_5_data_[] = { 0UL, 3489705058UL, 1342177281UL, 1342177280UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; -// DECLS OBJECT MODE ARGS ARG_POS BLOCK IF THIS GLOBAL BUILD_OBJECT BUILD_ARRAY -// WS LINE_COMMENT -const antlr::BitSet ScriptLexer::_tokenSet_5(_tokenSet_5_data_,10); +// GLOBAL BUILD_OBJECT BUILD_INSTANCE BUILD_ARRAY BUILD_ERROR ABSENT "wheat" +// "version" NUMBER "charset" "use" STRING "as" ID "include" "if" "else" +// "while" "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 +// GLOBAL_ID WSCHAR WS NL LINE_COMMENT NEST_COMMENT COMMENT WHITESPACE +// SEGMENT SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LE OP_2_GE OP_2_NE +// OP_2_EQ OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA +const antlr::BitSet ScriptLexer::_tokenSet_5(_tokenSet_5_data_,16); Index: ScriptLexerTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexerTokenTypes.hpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptLexerTokenTypes.hpp 18 Mar 2005 07:18:49 -0000 1.24 +++ ScriptLexerTokenTypes.hpp 24 Mar 2005 19:18:27 -0000 1.25 @@ -25,100 +25,103 @@ COLON = 14, DASHDASH = 15, LINK = 16, - IS_DEFINED = 17, - SHORT_DEFINED = 18, - V_UNKNOWN = 19, - IS_ERROR = 20, - SHORT_ERROR = 21, - V_ERROR = 22, - AS_LINK = 23, - AS_IS = 24, - V_NULL = 25, - V_TRUE = 26, - V_FALSE = 27, - SHORT_AND = 28, - SHORT_OR = 29, - ASSIGN_OP = 30, - ASSIGN_SUFFIX = 31, - SCRIPT = 32, - DECLS = 33, - USE = 34, - PATH = 35, - ARRAY = 36, - OBJECT = 37, - MODE = 38, - MEMBER = 39, - INCLUDE = 40, - METHOD = 41, - ARGS = 42, - ARG_POS = 43, - ARG_KEY = 44, - BLOCK = 45, - CONDITIONAL = 46, - IF = 47, - ELSE = 48, - LOOP = 49, - BREAK = 50, - RETURN = 51, - ASSIGN = 52, - SHORT = 53, - UNARY = 54, - BINARY = 55, - CALL = 56, - AS_COPY = 57, - LITERAL = 58, - SELF = 59, - THIS = 60, - LOCAL = 61, - GLOBAL = 62, - BUILD_OBJECT = 63, - BUILD_ARRAY = 64, - BUILD_ERROR = 65, - ABSENT = 66, - LITERAL_wheat = 67, - LITERAL_version = 68, - NUMBER = 69, - LITERAL_charset = 70, - LITERAL_use = 71, - STRING = 72, - LITERAL_as = 73, - ID = 74, - LITERAL_include = 75, - LITERAL_if = 76, - LITERAL_else = 77, - LITERAL_while = 78, - LITERAL_break = 79, - LITERAL_return = 80, - LITERAL_do = 81, - LITERAL_self = 82, - LITERAL_this = 83, - OP_1 = 84, - OP_2 = 85, - OP_3 = 86, - OP_4 = 87, - OP_5 = 88, - INSTANCE_ID = 89, - GLOBAL_ID = 90, - WSCHAR = 91, - WS = 92, - NL = 93, - LINE_COMMENT = 94, - NEST_COMMENT = 95, - COMMENT = 96, - WHITESPACE = 97, - SEGMENT = 98, - SIMPLE_STRING = 99, - MULTI_LINE_STRING = 100, - ESCAPE = 101, - OP_2_LT = 102, - OP_2_GT = 103, - OP_2_NE = 104, - OP_2_EQ = 105, - OP_2_CMP = 106, - OP_CHARS = 107, - OP_CHAR = 108, - DIGIT = 109, - ALPHA = 110, + OP_2_LT = 17, + OP_2_GT = 18, + IS_DEFINED = 19, + SHORT_DEFINED = 20, + V_UNKNOWN = 21, + IS_ERROR = 22, + SHORT_ERROR = 23, + V_ERROR = 24, + AS_LINK = 25, + AS_IS = 26, + V_NULL = 27, + V_TRUE = 28, + V_FALSE = 29, + SHORT_AND = 30, + SHORT_OR = 31, + ASSIGN_OP = 32, + ASSIGN_SUFFIX = 33, + SCRIPT = 34, + DECLS = 35, + USE = 36, + PATH = 37, + ARRAY = 38, + OBJECT = 39, + MODE = 40, + MEMBER = 41, + INCLUDE = 42, + METHOD = 43, + ARGS = 44, + ARG_POS = 45, + ARG_KEY = 46, + BLOCK = 47, + CONDITIONAL = 48, + IF = 49, + ELSE = 50, + LOOP = 51, + BREAK = 52, + RETURN = 53, + ASSIGN = 54, + SHORT = 55, + UNARY = 56, + BINARY = 57, + CALL = 58, + AS_COPY = 59, + LITERAL = 60, + SELF = 61, + THIS = 62, + LOCAL = 63, + GLOBAL = 64, + BUILD_OBJECT = 65, + BUILD_INSTANCE = 66, + BUILD_ARRAY = 67, + BUILD_ERROR = 68, + ABSENT = 69, + LITERAL_wheat = 70, + LITERAL_version = 71, + NUMBER = 72, + LITERAL_charset = 73, + LITERAL_use = 74, + STRING = 75, + LITERAL_as = 76, + ID = 77, + LITERAL_include = 78, + LITERAL_if = 79, + LITERAL_else = 80, + LITERAL_while = 81, + LITERAL_break = 82, + LITERAL_return = 83, + LITERAL_do = 84, + LITERAL_self = 85, + LITERAL_this = 86, + OP_1 = 87, + OP_2 = 88, + OP_3 = 89, + OP_4 = 90, + OP_5 = 91, + INSTANCE_ID = 92, + GLOBAL_ID = 93, + WSCHAR = 94, + WS = 95, + NL = 96, + LINE_COMMENT = 97, + NEST_COMMENT = 98, + COMMENT = 99, + WHITESPACE = 100, + SEGMENT = 101, + SIMPLE_STRING = 102, + MULTI_LINE_STRING = 103, + ESCAPE = 104, + OP_2_LE = 105, + OP_2_GE = 106, + OP_2_NE = 107, + OP_2_EQ = 108, + OP_2_CMP = 109, + OP_CHARS = 110, + OP_CHAR = 111, + DIGIT = 112, + ALPHA = 113, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptParserTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParserTokenTypes.hpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ScriptParserTokenTypes.hpp 18 Mar 2005 07:18:50 -0000 1.18 +++ ScriptParserTokenTypes.hpp 24 Mar 2005 19:18:28 -0000 1.19 @@ -25,80 +25,83 @@ COLON = 14, DASHDASH = 15, LINK = 16, - IS_DEFINED = 17, - SHORT_DEFINED = 18, - V_UNKNOWN = 19, - IS_ERROR = 20, - SHORT_ERROR = 21, - V_ERROR = 22, - AS_LINK = 23, - AS_IS = 24, - V_NULL = 25, - V_TRUE = 26, - V_FALSE = 27, - SHORT_AND = 28, - SHORT_OR = 29, - ASSIGN_OP = 30, - ASSIGN_SUFFIX = 31, - SCRIPT = 32, - DECLS = 33, - USE = 34, - PATH = 35, - ARRAY = 36, - OBJECT = 37, - MODE = 38, - MEMBER = 39, - INCLUDE = 40, - METHOD = 41, - ARGS = 42, - ARG_POS = 43, - ARG_KEY = 44, - BLOCK = 45, - CONDITIONAL = 46, - IF = 47, - ELSE = 48, - LOOP = 49, - BREAK = 50, - RETURN = 51, - ASSIGN = 52, - SHORT = 53, - UNARY = 54, - BINARY = 55, - CALL = 56, - AS_COPY = 57, - LITERAL = 58, - SELF = 59, - THIS = 60, - LOCAL = 61, - GLOBAL = 62, - BUILD_OBJECT = 63, - BUILD_ARRAY = 64, - BUILD_ERROR = 65, - ABSENT = 66, - LITERAL_wheat = 67, - LITERAL_version = 68, - NUMBER = 69, - LITERAL_charset = 70, - LITERAL_use = 71, - STRING = 72, - LITERAL_as = 73, - ID = 74, - LITERAL_include = 75, - LITERAL_if = 76, - LITERAL_else = 77, - LITERAL_while = 78, - LITERAL_break = 79, - LITERAL_return = 80, - LITERAL_do = 81, - LITERAL_self = 82, - LITERAL_this = 83, - OP_1 = 84, - OP_2 = 85, - OP_3 = 86, - OP_4 = 87, - OP_5 = 88, - INSTANCE_ID = 89, - GLOBAL_ID = 90, + OP_2_LT = 17, + OP_2_GT = 18, + IS_DEFINED = 19, + SHORT_DEFINED = 20, + V_UNKNOWN = 21, + IS_ERROR = 22, + SHORT_ERROR = 23, + V_ERROR = 24, + AS_LINK = 25, + AS_IS = 26, + V_NULL = 27, + V_TRUE = 28, + V_FALSE = 29, + SHORT_AND = 30, + SHORT_OR = 31, + ASSIGN_OP = 32, + ASSIGN_SUFFIX = 33, + SCRIPT = 34, + DECLS = 35, + USE = 36, + PATH = 37, + ARRAY = 38, + OBJECT = 39, + MODE = 40, + MEMBER = 41, + INCLUDE = 42, + METHOD = 43, + ARGS = 44, + ARG_POS = 45, + ARG_KEY = 46, + BLOCK = 47, + CONDITIONAL = 48, + IF = 49, + ELSE = 50, + LOOP = 51, + BREAK = 52, + RETURN = 53, + ASSIGN = 54, + SHORT = 55, + UNARY = 56, + BINARY = 57, + CALL = 58, + AS_COPY = 59, + LITERAL = 60, + SELF = 61, + THIS = 62, + LOCAL = 63, + GLOBAL = 64, + BUILD_OBJECT = 65, + BUILD_INSTANCE = 66, + BUILD_ARRAY = 67, + BUILD_ERROR = 68, + ABSENT = 69, + LITERAL_wheat = 70, + LITERAL_version = 71, + NUMBER = 72, + LITERAL_charset = 73, + LITERAL_use = 74, + STRING = 75, + LITERAL_as = 76, + ID = 77, + LITERAL_include = 78, + LITERAL_if = 79, + LITERAL_else = 80, + LITERAL_while = 81, + LITERAL_break = 82, + LITERAL_return = 83, + LITERAL_do = 84, + LITERAL_self = 85, + LITERAL_this = 86, + OP_1 = 87, + OP_2 = 88, + OP_3 = 89, + OP_4 = 90, + OP_5 = 91, + INSTANCE_ID = 92, + GLOBAL_ID = 93, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptParser.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.hpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ScriptParser.hpp 19 Mar 2005 01:43:34 -0000 1.21 +++ ScriptParser.hpp 24 Mar 2005 19:18:28 -0000 1.22 @@ -128,9 +128,10 @@ public: void buildError(); public: void buildProto(); public: void buildObjectContent(); + public: void buildInstanceContent(); public: void buildObjectMember(); - public: void objectMode(); public: void objectMember(); + public: void objectMode(); public: void objectMethod(); public: void buildArrayContent(); public: @@ -144,10 +145,10 @@ private: static const char* tokenNames[]; #ifndef NO_STATIC_CONSTS - static const int NUM_TOKENS = 91; + static const int NUM_TOKENS = 94; #else enum { - NUM_TOKENS = 91 + NUM_TOKENS = 94 }; #endif Index: ScriptLexer.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.hpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- ScriptLexer.hpp 18 Mar 2005 07:18:49 -0000 1.15 +++ ScriptLexer.hpp 24 Mar 2005 19:18:27 -0000 1.16 @@ -63,13 +63,15 @@ public: void mOP_4(bool _createToken); public: void mOP_3(bool _createToken); public: void mOP_2(bool _createToken); + protected: void mOP_CHAR(bool _createToken); public: void mOP_2_LT(bool _createToken); public: void mOP_2_GT(bool _createToken); + public: void mOP_2_LE(bool _createToken); + public: void mOP_2_GE(bool _createToken); public: void mOP_2_NE(bool _createToken); public: void mOP_2_EQ(bool _createToken); public: void mOP_2_CMP(bool _createToken); public: void mOP_1(bool _createToken); - protected: void mOP_CHAR(bool _createToken); public: void mLPAREN(bool _createToken); public: void mRPAREN(bool _createToken); public: void mLBRACK(bool _createToken); Index: ScriptLexerTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexerTokenTypes.txt,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptLexerTokenTypes.txt 18 Mar 2005 07:18:49 -0000 1.24 +++ ScriptLexerTokenTypes.txt 24 Mar 2005 19:18:27 -0000 1.25 @@ -13,97 +13,100 @@ COLON=":"=14 DASHDASH="--"=15 LINK="->"=16 -IS_DEFINED="?"=17 -SHORT_DEFINED="??"=18 -V_UNKNOWN="???"=19 -IS_ERROR="!"=20 -SHORT_ERROR="!!"=21 -V_ERROR="!!!"=22 -AS_LINK="\\"=23 -AS_IS="\\\\"=24 -V_NULL="null"=25 -V_TRUE="true"=26 -V_FALSE="false"=27 -SHORT_AND="&&"=28 -SHORT_OR="||"=29 -ASSIGN_OP=":="=30 -ASSIGN_SUFFIX="="=31 -SCRIPT=32 -DECLS=33 -USE=34 -PATH=35 -ARRAY=36 -OBJECT=37 -MODE=38 -MEMBER=39 -INCLUDE=40 -METHOD=41 -ARGS=42 -ARG_POS=43 -ARG_KEY=44 -BLOCK=45 -CONDITIONAL=46 -IF=47 -ELSE=48 -LOOP=49 -BREAK=50 -RETURN=51 -ASSIGN=52 -SHORT=53 -UNARY=54 -BINARY=55 -CALL=56 -AS_COPY=57 -LITERAL=58 -SELF=59 -THIS=60 -LOCAL=61 -GLOBAL=62 -BUILD_OBJECT=63 -BUILD_ARRAY=64 -BUILD_ERROR=65 -ABSENT=66 -LITERAL_wheat="wheat"=67 -LITERAL_version="version"=68 -NUMBER=69 -LITERAL_charset="charset"=70 -LITERAL_use="use"=71 -STRING=72 -LITERAL_as="as"=73 -ID=74 -LITERAL_include="include"=75 -LITERAL_if="if"=76 -LITERAL_else="else"=77 -LITERAL_while="while"=78 -LITERAL_break="break"=79 -LITERAL_return="return"=80 -LITERAL_do="do"=81 -LITERAL_self="self"=82 -LITERAL_this="this"=83 -OP_1=84 -OP_2=85 -OP_3=86 -OP_4=87 -OP_5=88 -INSTANCE_ID=89 -GLOBAL_ID=90 -WSCHAR=91 -WS=92 -NL=93 -LINE_COMMENT=94 -NEST_COMMENT=95 -COMMENT=96 -WHITESPACE=97 -SEGMENT=98 -SIMPLE_STRING=99 -MULTI_LINE_STRING=100 -ESCAPE=101 -OP_2_LT=102 -OP_2_GT=103 -OP_2_NE=104 -OP_2_EQ=105 -OP_2_CMP=106 -OP_CHARS=107 -OP_CHAR=108 -DIGIT=109 -ALPHA=110 +OP_2_LT="<"=17 +OP_2_GT=">"=18 +IS_DEFINED="?"=19 +SHORT_DEFINED="??"=20 +V_UNKNOWN="???"=21 +IS_ERROR="!"=22 +SHORT_ERROR="!!"=23 +V_ERROR="!!!"=24 +AS_LINK="\\"=25 +AS_IS="\\\\"=26 +V_NULL="null"=27 +V_TRUE="true"=28 +V_FALSE="false"=29 +SHORT_AND="&&"=30 +SHORT_OR="||"=31 +ASSIGN_OP=":="=32 +ASSIGN_SUFFIX="="=33 +SCRIPT=34 +DECLS=35 +USE=36 +PATH=37 +ARRAY=38 +OBJECT=39 +MODE=40 +MEMBER=41 +INCLUDE=42 +METHOD=43 +ARGS=44 +ARG_POS=45 +ARG_KEY=46 +BLOCK=47 +CONDITIONAL=48 +IF=49 +ELSE=50 +LOOP=51 +BREAK=52 +RETURN=53 +ASSIGN=54 +SHORT=55 +UNARY=56 +BINARY=57 +CALL=58 +AS_COPY=59 +LITERAL=60 +SELF=61 +THIS=62 +LOCAL=63 +GLOBAL=64 +BUILD_OBJECT=65 +BUILD_INSTANCE=66 +BUILD_ARRAY=67 +BUILD_ERROR=68 +ABSENT=69 +LITERAL_wheat="wheat"=70 +LITERAL_version="version"=71 +NUMBER=72 +LITERAL_charset="charset"=73 +LITERAL_use="use"=74 +STRING=75 +LITERAL_as="as"=76 +ID=77 +LITERAL_include="include"=78 +LITERAL_if="if"=79 +LITERAL_else="else"=80 +LITERAL_while="while"=81 +LITERAL_break="break"=82 +LITERAL_return="return"=83 +LITERAL_do="do"=84 +LITERAL_self="self"=85 +LITERAL_this="this"=86 +OP_1=87 +OP_2=88 +OP_3=89 +OP_4=90 +OP_5=91 +INSTANCE_ID=92 +GLOBAL_ID=93 +WSCHAR=94 +WS=95 +NL=96 +LINE_COMMENT=97 +NEST_COMMENT=98 +COMMENT=99 +WHITESPACE=100 +SEGMENT=101 +SIMPLE_STRING=102 +MULTI_LINE_STRING=103 +ESCAPE=104 +OP_2_LE=105 +OP_2_GE=106 +OP_2_NE=107 +OP_2_EQ=108 +OP_2_CMP=109 +OP_CHARS=110 +OP_CHAR=111 +DIGIT=112 +ALPHA=113 Index: ScriptParserTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParserTokenTypes.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- ScriptParserTokenTypes.txt 18 Mar 2005 07:18:50 -0000 1.17 +++ ScriptParserTokenTypes.txt 24 Mar 2005 19:18:28 -0000 1.18 @@ -13,77 +13,80 @@ COLON=":"=14 DASHDASH="--"=15 LINK="->"=16 -IS_DEFINED="?"=17 -SHORT_DEFINED="??"=18 -V_UNKNOWN="???"=19 -IS_ERROR="!"=20 -SHORT_ERROR="!!"=21 -V_ERROR="!!!"=22 -AS_LINK="\\"=23 -AS_IS="\\\\"=24 -V_NULL="null"=25 -V_TRUE="true"=26 -V_FALSE="false"=27 -SHORT_AND="&&"=28 -SHORT_OR="||"=29 -ASSIGN_OP=":="=30 -ASSIGN_SUFFIX="="=31 -SCRIPT=32 -DECLS=33 -USE=34 -PATH=35 -ARRAY=36 -OBJECT=37 -MODE=38 -MEMBER=39 -INCLUDE=40 -METHOD=41 -ARGS=42 -ARG_POS=43 -ARG_KEY=44 -BLOCK=45 -CONDITIONAL=46 -IF=47 -ELSE=48 -LOOP=49 -BREAK=50 -RETURN=51 -ASSIGN=52 -SHORT=53 -UNARY=54 -BINARY=55 -CALL=56 -AS_COPY=57 -LITERAL=58 -SELF=59 -THIS=60 -LOCAL=61 -GLOBAL=62 -BUILD_OBJECT=63 -BUILD_ARRAY=64 -BUILD_ERROR=65 -ABSENT=66 -LITERAL_wheat="wheat"=67 -LITERAL_version="version"=68 -NUMBER=69 -LITERAL_charset="charset"=70 -LITERAL_use="use"=71 -STRING=72 -LITERAL_as="as"=73 -ID=74 -LITERAL_include="include"=75 -LITERAL_if="if"=76 -LITERAL_else="else"=77 -LITERAL_while="while"=78 -LITERAL_break="break"=79 -LITERAL_return="return"=80 -LITERAL_do="do"=81 -LITERAL_self="self"=82 -LITERAL_this="this"=83 -OP_1=84 -OP_2=85 -OP_3=86 -OP_4=87 -OP_5=88 -INSTANCE_ID=89 -GLOBAL_ID=90 +OP_2_LT="<"=17 +OP_2_GT=">"=18 +IS_DEFINED="?"=19 +SHORT_DEFINED="??"=20 +V_UNKNOWN="???"=21 +IS_ERROR="!"=22 +SHORT_ERROR="!!"=23 +V_ERROR="!!!"=24 +AS_LINK="\\"=25 +AS_IS="\\\\"=26 +V_NULL="null"=27 +V_TRUE="true"=28 +V_FALSE="false"=29 +SHORT_AND="&&"=30 +SHORT_OR="||"=31 +ASSIGN_OP=":="=32 +ASSIGN_SUFFIX="="=33 +SCRIPT=34 +DECLS=35 +USE=36 +PATH=37 +ARRAY=38 +OBJECT=39 +MODE=40 +MEMBER=41 +INCLUDE=42 +METHOD=43 +ARGS=44 +ARG_POS=45 +ARG_KEY=46 +BLOCK=47 +CONDITIONAL=48 +IF=49 +ELSE=50 +LOOP=51 +BREAK=52 +RETURN=53 +ASSIGN=54 +SHORT=55 +UNARY=56 +BINARY=57 +CALL=58 +AS_COPY=59 +LITERAL=60 +SELF=61 +THIS=62 +LOCAL=63 +GLOBAL=64 +BUILD_OBJECT=65 +BUILD_INSTANCE=66 +BUILD_ARRAY=67 +BUILD_ERROR=68 +ABSENT=69 +LITERAL_wheat="wheat"=70 +LITERAL_version="version"=71 +NUMBER=72 +LITERAL_charset="charset"=73 +LITERAL_use="use"=74 +STRING=75 +LITERAL_as="as"=76 +ID=77 +LITERAL_include="include"=78 +LITERAL_if="if"=79 +LITERAL_else="else"=80 +LITERAL_while="while"=81 +LITERAL_break="break"=82 +LITERAL_return="return"=83 +LITERAL_do="do"=84 +LITERAL_self="self"=85 +LITERAL_this="this"=86 +OP_1=87 +OP_2=88 +OP_3=89 +OP_4=90 +OP_5=91 +INSTANCE_ID=92 +GLOBAL_ID=93 Index: ScriptParser.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- ScriptParser.cpp 19 Mar 2005 01:43:34 -0000 1.26 +++ ScriptParser.cpp 24 Mar 2005 19:18:27 -0000 1.27 @@ -1418,6 +1418,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case V_NULL: @@ -1456,6 +1458,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case V_NULL: @@ -1617,6 +1621,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case V_NULL: @@ -1711,6 +1717,8 @@ { switch ( LA(1)) { case DASHDASH: + case OP_2_LT: + case OP_2_GT: case ASSIGN_OP: case OP_1: case OP_2: @@ -1721,6 +1729,8 @@ { switch ( LA(1)) { case DASHDASH: + case OP_2_LT: + case OP_2_GT: case OP_1: case OP_2: case OP_3: @@ -2068,6 +2078,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case AS_LINK: @@ -2358,6 +2370,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case V_NULL: @@ -2515,6 +2529,8 @@ } break; } + case OP_2_LT: + case OP_2_GT: case OP_2: { op2(); @@ -2632,7 +2648,7 @@ } { // ( ... )* for (;;) { - if ((LA(1) == OP_2) && (_tokenSet_5.member(LA(2)))) { + if ((LA(1) == OP_2_LT || LA(1) == OP_2_GT || LA(1) == OP_2) && (_tokenSet_5.member(LA(2)))) { op2(); if (inputState->guessing==0) { op_AST = returnAST; @@ -2733,12 +2749,44 @@ antlr::ASTPair currentAST; antlr::RefSpanAST op2_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefSpanAST tmp66_AST = antlr::RefSpanAST(antlr::nullAST); - if ( inputState->guessing == 0 ) { - tmp66_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp66_AST)); + { + switch ( LA(1)) { + case OP_2: + { + antlr::RefSpanAST tmp66_AST = antlr::RefSpanAST(antlr::nullAST); + if ( inputState->guessing == 0 ) { + tmp66_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp66_AST)); + } + match(OP_2); + break; + } + case OP_2_LT: + { + antlr::RefSpanAST tmp67_AST = antlr::RefSpanAST(antlr::nullAST); + if ( inputState->guessing == 0 ) { + tmp67_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp67_AST)); + } + match(OP_2_LT); + break; + } + case OP_2_GT: + { + antlr::RefSpanAST tmp68_AST = antlr::RefSpanAST(antlr::nullAST); + if ( inputState->guessing == 0 ) { + tmp68_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp68_AST)); + } + match(OP_2_GT); + break; + } + default: + { + throw antlr::NoViableAltException(LT(1), getFilename()); + } + } } - match(OP_2); if ( inputState->guessing==0 ) { op2_AST = antlr::RefSpanAST(currentAST.root); op2_AST->setType(ID); @@ -2801,20 +2849,20 @@ switch ( LA(1)) { case OP_3: { - antlr::RefSpanAST tmp67_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp69_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp67_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp67_AST)); + tmp69_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp69_AST)); } match(OP_3); break; } case DASHDASH: { - antlr::RefSpanAST tmp68_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp70_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp68_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp68_AST)); + tmp70_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp70_AST)); } match(DASHDASH); break; @@ -2883,10 +2931,10 @@ antlr::ASTPair currentAST; antlr::RefSpanAST op4_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefSpanAST tmp69_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp71_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp69_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp69_AST)); + tmp71_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp71_AST)); } match(OP_4); if ( inputState->guessing==0 ) { @@ -2904,6 +2952,8 @@ switch ( LA(1)) { case DASHDASH: + case OP_2_LT: + case OP_2_GT: case OP_1: case OP_2: case OP_3: @@ -2969,10 +3019,10 @@ antlr::ASTPair currentAST; antlr::RefSpanAST op5_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefSpanAST tmp70_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp72_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp70_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp70_AST)); + tmp72_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp72_AST)); } match(OP_5); if ( inputState->guessing==0 ) { @@ -3286,6 +3336,8 @@ case LCURLY: case DASHDASH: case LINK: + case OP_2_LT: + case OP_2_GT: case V_UNKNOWN: case V_ERROR: case AS_LINK: @@ -3352,6 +3404,8 @@ case PERIOD: case SEMI: case DASHDASH: + case OP_2_LT: + case OP_2_GT: case IS_DEFINED: case SHORT_DEFINED: case IS_ERROR: @@ -3554,10 +3608,10 @@ antlr::ASTPair currentAST; antlr::RefSpanAST instanceID_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefSpanAST tmp82_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp84_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp82_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp82_AST)); + tmp84_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp84_AST)); } match(INSTANCE_ID); if ( inputState->guessing==0 ) { @@ -3573,10 +3627,10 @@ antlr::ASTPair currentAST; antlr::RefSpanAST globalID_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefSpanAST tmp83_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST tmp85_AST = antlr::RefSpanAST(antlr::nullAST); if ( inputState->guessing == 0 ) { - tmp83_AST = astFactory->create(LT(1)); - astFactory->addASTChild(currentAST, antlr::RefAST(tmp83_AST)); + tmp85_AST = astFactory->create(LT(1)); + astFactory->addASTChild(currentAST, antlr::RefAST(tmp85_AST)); } match(GLOBAL_ID); if ( inputState->guessing==0 ) { @@ -3593,39 +3647,102 @@ antlr::RefSpanAST buildObject_AST = antlr::RefSpanAST(antlr::nullAST); antlr::RefToken zs = antlr::nullToken; antlr::RefSpanAST ... [truncated message content] |
From: Mark L. <mar...@us...> - 2005-03-24 19:18:04
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14628/grammar Modified Files: ScriptCompiler.g ScriptLexer.g ScriptParser.g ScriptLexer-test.cpp ScriptParser-test.cpp Log Message: added new syntax to distinguish making an instance vs. a sub-class: { :foo: x: 8 } -- makes an instance { <:foo: x: 8 } -- makes a subclass { x: 8 } -- makes a subclass of object the difference is that the first is compiled as: new-object.x := 8 and the second and third are: new-object.add-member("x", 8); small lexer change in how "<" and ">" are tokenized: they are now their own tokens OP_2_LT and OP_2_GT contemplated what { :foo: x: 8 } should mean when foo has no member x: We'd like this to be an error, but there isn't an obvious way to fit it in to the error system yet Index: ScriptLexer.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.g,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- ScriptLexer.g 18 Mar 2005 07:18:49 -0000 1.22 +++ ScriptLexer.g 24 Mar 2005 19:17:52 -0000 1.23 @@ -140,9 +140,11 @@ | NUMBER { $setType(NUMBER); } )) ; -OP_2 : ('<' | '>' ) OP_CHARS ; -OP_2_LT : "<=" { $setType(OP_2); } ; -OP_2_GT : ">=" { $setType(OP_2); } ; +OP_2 : ('<' | '>' ) OP_CHAR OP_CHARS ; +OP_2_LT : "<" ; +OP_2_GT : ">" ; +OP_2_LE : "<=" { $setType(OP_2); } ; +OP_2_GE : ">=" { $setType(OP_2); } ; OP_2_NE : "!=" { $setType(OP_2); } ; OP_2_EQ : "==" { $setType(OP_2); } ; OP_2_CMP : "<=>" { $setType(OP_2); } ; Index: ScriptCompiler.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.g,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- ScriptCompiler.g 19 Mar 2005 01:42:59 -0000 1.26 +++ ScriptCompiler.g 24 Mar 2005 19:17:52 -0000 1.27 @@ -492,6 +492,7 @@ { SOURCE(#valueExpression); } ( r=selfExpression[mb] | r=buildObject[mb] + | r=buildInstance[mb] | r=buildArray[mb] | r=buildError[mb] | #(LOCAL l:ID) { r = mb.genLocal(astString(l), false);} @@ -520,28 +521,18 @@ buildObject [Wheat::MethodBuilder& mb] returns [Wheat::MethodBuilder::Register r]: { SOURCE(#buildObject); } - #(BUILD_OBJECT { MethodBuilder::Register p; bool nop; } - p=buildProto[mb, nop] { r = mb.genNewObject(p); } + #(BUILD_OBJECT { MethodBuilder::Register p; } + p=buildProto[mb] { r = mb.genNewObject(p); } ( options{greedy=true;}: { MethodBuilder::Register v; } #(MEMBER i:ID v=reference[mb]) { MethodBuilder::Call c; c.setReceiver(r); - if (nop) { - ObjectPointer op; - c.setMessage("add-member"); - c.addPosArg(mb.genLiteral(op)); - op.storeString(astString(i)); - c.addPosArg(v); - } - else { - c.setMessage(astString(i)); - ObjectPointer trueOp; - c.addKeyArg("assign", - mb.genLiteral(trueOp)); - trueOp.storeBool(true); - c.addKeyArg("value", v); - } + ObjectPointer op; + c.setMessage("add-member"); + c.addPosArg(mb.genLiteral(op)); + op.storeString(astString(i)); + c.addPosArg(v); mb.genCall(c); } )* @@ -553,11 +544,38 @@ exception catch [const Wheat::Exception& e] { throw buildException(e, ##_in); } +buildInstance [Wheat::MethodBuilder& mb] + returns [Wheat::MethodBuilder::Register r]: + { SOURCE(#buildInstance); } + #(BUILD_INSTANCE { MethodBuilder::Register p; } + p=buildProto[mb] { r = mb.genNewObject(p); } + ( options{greedy=true;}: { MethodBuilder::Register v; } + #(MEMBER i:ID v=reference[mb]) + { + MethodBuilder::Call c; + c.setReceiver(r); + c.setMessage(astString(i)); + ObjectPointer trueOp; + c.addKeyArg("assign", + mb.genLiteral(trueOp)); + trueOp.storeBool(true); + c.addKeyArg("value", v); + mb.genCall(c); + } + )* + ( x:. { throw buildException( + "unrecognized element when building instance", #x); } + )* + ) + ; + exception + catch [const Wheat::Exception& e] { throw buildException(e, ##_in); } + buildArray [Wheat::MethodBuilder& mb] returns [Wheat::MethodBuilder::Register r]: { SOURCE(#buildArray); } - #(BUILD_ARRAY { MethodBuilder::Register p; bool nop; } - p=buildProto[mb, nop] { r = mb.genNewArray(p); } + #(BUILD_ARRAY { MethodBuilder::Register p; } + p=buildProto[mb] { r = mb.genNewArray(p); } ( { MethodBuilder::Register v; } v=reference[mb] { @@ -573,7 +591,7 @@ exception catch [const Wheat::Exception& e] { throw buildException(e, ##_in); } -buildProto [Wheat::MethodBuilder& mb, bool& nop] +buildProto [Wheat::MethodBuilder& mb] returns [Wheat::MethodBuilder::Register r]: { SOURCE(#buildProto); } r=selfExpression[mb] { @@ -581,19 +599,16 @@ c.setReceiver(r); c.setMessage("absolute-path"); r = mb.genCall(c); - nop = false; } | i:ID { ObjectPointer op; r = mb.genLiteral(op); op.storePath(Path(astString(i))); - nop = false; } | ABSENT { ObjectPointer op; r = mb.genLiteral(op); op.storePath(Path(Path::Empty)); - nop = true; } ; exception Index: ScriptParser.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.g,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- ScriptParser.g 19 Mar 2005 01:43:00 -0000 1.26 +++ ScriptParser.g 24 Mar 2005 19:17:53 -0000 1.27 @@ -50,6 +50,9 @@ DASHDASH = "--"; LINK = "->"; + OP_2_LT = "<"; + OP_2_GT = ">"; + IS_DEFINED = "?"; SHORT_DEFINED = "??"; V_UNKNOWN = "???"; @@ -121,7 +124,9 @@ LOCAL; GLOBAL; // id - BUILD_OBJECT; // proto, member... + BUILD_OBJECT; // proto, (member|mode|method)... + // MEMBER; // id, reference + BUILD_INSTANCE; // proto, member... // MEMBER; // id, reference BUILD_ARRAY; // proto, reference... BUILD_ERROR; // reference... @@ -440,17 +445,32 @@ build: buildObject | buildArray | buildError; buildObject!: - zs:"{" p:buildProto mayEnd! - c:buildObjectContent - ze:"}" { ## = #([BUILD_OBJECT], #p, #c); } - { ##->includeSpan(zs, ze); } + zs:"{" ( + "<" op:buildProto mayEnd oc:buildObjectContent + { ## = #([BUILD_OBJECT], #op, #oc); } + | ip:buildProto mayEnd ic:buildInstanceContent + { ## = #([BUILD_INSTANCE], #ip, #ic); } + | mayEnd dc:buildObjectContent + { ## = #([BUILD_OBJECT], [ABSENT], #dc); } + ) ze:"}" { ##->includeSpan(zs, ze); } ; + buildObjectContent: ( buildObjectMember ( end! ( buildObjectMember )? )* - )? ; + )? + ; + +buildInstanceContent: + ( + objectMember ( + end! ( objectMember )? + )* + )? + ; + buildObjectMember: objectMode | objectMember @@ -470,13 +490,16 @@ i:id a:methodArgs ":" b:methodBody { ## = #([MEMBER], #i, ([METHOD], #a, #b)); } ; - + buildArray!: - zs:"[" p:buildProto mayEnd! - c:buildArrayContent - ze:"]" { ## = #([BUILD_ARRAY], #p, #c); } - { ##->includeSpan(zs, ze); } + zs:"[" ( + p:buildProto mayEnd c:buildArrayContent + { ## = #([BUILD_ARRAY], #p, #c); } + | mayEnd dc:buildArrayContent + { ## = #([BUILD_ARRAY], [ABSENT], #dc); } + ) ze:"]" { ##->includeSpan(zs, ze); } ; + buildArrayContent: ( reference ( options{warnWhenFollowAmbig=false;}: @@ -486,9 +509,7 @@ )? ; buildProto: - ( ":"! (ID | selfTerm) ":"! - | empty { ## = #[ABSENT]; } - ) + ":"! (ID | selfTerm) ":"! ; buildError: @@ -501,7 +522,7 @@ { #shortOp->setType(ID); }; anyOp: ( op1 | op2 | op3 | op4 | op5 ) ; op1: OP_1 { #op1->setType(ID); }; -op2: OP_2 { #op2->setType(ID); }; +op2: ( OP_2 | OP_2_LT | OP_2_GT ) { #op2->setType(ID); }; op3: ( OP_3 | DASHDASH ) { #op3->setType(ID); }; op4: OP_4 { #op4->setType(ID); }; op5: OP_5 { #op5->setType(ID); }; Index: ScriptParser-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser-test.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ScriptParser-test.cpp 19 Mar 2005 01:43:00 -0000 1.28 +++ ScriptParser-test.cpp 24 Mar 2005 19:17:53 -0000 1.29 @@ -515,11 +515,11 @@ checkBlockParseTree(HERE, "{ {:'/library/base/gizmo':}; }", - " (BLOCK (BUILD_OBJECT ID</library/base/gizmo>))"); + " (BLOCK (BUILD_INSTANCE ID</library/base/gizmo>))"); checkBlockParseTree(HERE, "{ {:self: x: y }; }", - " (BLOCK (BUILD_OBJECT SELF" + " (BLOCK (BUILD_INSTANCE SELF" " (MEMBER ID<x> (AS_COPY (LOCAL ID<y>)))" "))"); @@ -538,6 +538,12 @@ " (RETURN (AS_COPY (CALL ID<var> SELF)))" ")))" "))"); + + checkBlockParseTree(HERE, + "{ {<:self: x: y }; }", + " (BLOCK (BUILD_OBJECT SELF" + " (MEMBER ID<x> (AS_COPY (LOCAL ID<y>)))" + "))"); } TEST(scriptParser, buildArrays) Index: ScriptLexer-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer-test.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptLexer-test.cpp 18 Mar 2005 07:18:49 -0000 1.24 +++ ScriptLexer-test.cpp 24 Mar 2005 19:17:53 -0000 1.25 @@ -253,12 +253,12 @@ { t::DASHDASH, "--" }, { t::OP_3, "~" }, - { t::OP_2, "<" }, + { t::OP_2_LT, "<" }, { t::OP_2, "<=" }, { t::OP_2, "==" }, { t::OP_2, "!=" }, { t::OP_2, ">=" }, - { t::OP_2, ">" }, + { t::OP_2_GT, ">" }, { t::OP_2, "<=>" }, { t::ASSIGN_OP, ":=" }, |
From: Mark L. <mar...@us...> - 2005-03-24 19:18:04
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14628/wheat Modified Files: compiler-test.cpp Log Message: added new syntax to distinguish making an instance vs. a sub-class: { :foo: x: 8 } -- makes an instance { <:foo: x: 8 } -- makes a subclass { x: 8 } -- makes a subclass of object the difference is that the first is compiled as: new-object.x := 8 and the second and third are: new-object.add-member("x", 8); small lexer change in how "<" and ">" are tokenized: they are now their own tokens OP_2_LT and OP_2_GT contemplated what { :foo: x: 8 } should mean when foo has no member x: We'd like this to be an error, but there isn't an obvious way to fit it in to the error system yet Index: compiler-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/compiler-test.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- compiler-test.cpp 19 Mar 2005 01:43:00 -0000 1.36 +++ compiler-test.cpp 24 Mar 2005 19:17:54 -0000 1.37 @@ -355,6 +355,7 @@ "o2(): { return {:'/test/compiler/compiler-test-setup/dest': " " a: 80; b: \"deb\"; }; }\n" "o3(): { return {:self: a: 99; b: \"sue\"; }; }\n" + "o4(): { return {:self: c: 99 } }\n" ); CHECK_SAME("/library/base/object", @@ -376,6 +377,9 @@ c.target().send("o3").prototype().asString()); CHECK_SAME(99, c.target().send("o3").send("a").asInt()); CHECK_SAME("sue", c.target().send("o3").send("b").asString()); + + //CHECK(c.target().send("o4").error()); + // we'd like this to be some sort of error, but we're not sure what } TEST(compiler, arrays) |
From: Mark L. <mar...@us...> - 2005-03-24 19:18:04
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14628/root/library Modified Files: base.ws Log Message: added new syntax to distinguish making an instance vs. a sub-class: { :foo: x: 8 } -- makes an instance { <:foo: x: 8 } -- makes a subclass { x: 8 } -- makes a subclass of object the difference is that the first is compiled as: new-object.x := 8 and the second and third are: new-object.add-member("x", 8); small lexer change in how "<" and ">" are tokenized: they are now their own tokens OP_2_LT and OP_2_GT contemplated what { :foo: x: 8 } should mean when foo has no member x: We'd like this to be an error, but there isn't an obvious way to fit it in to the error system yet Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- base.ws 18 Mar 2005 07:18:50 -0000 1.53 +++ base.ws 24 Mar 2005 19:17:53 -0000 1.54 @@ -553,6 +553,19 @@ #assert-equals("/library/base/tests/simple-thing", t.prototype.as-string()); } + + test-instance(): { + i := { :'/library/base/tests/simple-thing': x: 18 }; + j := { :'/library/base/tests/simple-thing': x: 20 }; + #assert-equals(18, i.x); + #assert-equals(20, j.x); +``( + It isn't clear how this should work. + z: 33 is an error, but what do we do with it. + (k := { :'/library/base/tests/simple-thing': z: 33 })! + #assert-error("system/vm/exception/not-found(z)", k); +``) + } test-is-copydown(): { thing := \$/library/base/tests/simple-thing; |
From: Jim K. <ki...@us...> - 2005-03-20 06:51:06
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15589/root/applications Modified Files: farm.ws Log Message: Re-enable a byte vs character test which had been commented out. The code it was testing for was fixed a while ago. Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- farm.ws 19 Mar 2005 08:58:54 -0000 1.59 +++ farm.ws 20 Mar 2005 06:50:41 -0000 1.60 @@ -642,11 +642,11 @@ #assert-equals( "parses: \"x<y || &foo > 5 || ãã¥ã¼ã¹\"\n" + - ... "error: \"<&>\" ", + ... "error: \"<&>æ¥æ¬èª\" ", before-error.value); failure-code := instruction.contexts[1].get-instruction("failure-code"); - #assert-equals("bad \"<&>\"", failure-code.value); + #assert-equals("bad \"<&>ãã¥ã¼ã¹\"", failure-code.value); message := instruction.contexts[1].get-instruction("compile-message"); #assert-equals("expecting EOF, found 'bad'", message.value); @@ -926,20 +926,12 @@ } "") - ``( Check that the compiler and the viewer agree on what a - column is (bytes or characters or other choices like - character width or whatever). - Alas, current compiler says bytes and current viewer - says characters, so the test is commented out. ``) source-text-odd-characters: ""( parses: "x<y || &foo > 5 || ãã¥ã¼ã¹" -error: "<&>" bad "<&>" +error: "<&>æ¥æ¬èª" bad "<&>ãã¥ã¼ã¹" next-line: "don't <stop> æ¥æ¬èª" "") -`` This is the case: "bad" is where the error happens -`` error: "<&>æ¥æ¬èª" bad "<&>ãã¥ã¼ã¹" - built-module: ??? } |
From: Jim K. <ki...@us...> - 2005-03-19 08:59:04
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25594/root/applications Modified Files: farm.ws Log Message: Add a start of trace display to the farm template and CSS. Refactor existing template for errors, so that it repeats blocks, rather than hardcoding the notion of blocks before and after the (single) error. Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- farm.ws 18 Mar 2005 07:18:50 -0000 1.58 +++ farm.ws 19 Mar 2005 08:58:54 -0000 1.59 @@ -120,9 +120,12 @@ expander: {:'/applications/farm/farm-expander': tt-source(): { return #subject.source.as-string; } tt-target(): { return #subject.target.as-string; } - tt-compile-message(): { + compile-message(): { return #subject.compile-result.error-message; } + tt-compile-message(): { + return #compile-message(); + } tt-never-compiled(): { return #subject.compilation-state.matches("never"); } @@ -164,36 +167,31 @@ request: \#request)); } - tt-before-error(): { + tt-listing(): { if (#subject.compilation-state.matches("compile-error-location")) { - return #subject.split-source[0]; - } - else { - return #subject.source.dereference(); + split := #subject.split-source; + #expand(subject: split[0], expander: \#plain-text-expander); + #expand(subject: { code: split[1]; message: #compile-message }, + expander: \#failure-listing-expander); + #expand(subject: split[2], expander: \#plain-text-expander); + } else { + #expand(subject: #subject.source.dereference(), + expander: \#plain-text-expander); } } - tt-is-failure(): { - return #subject.compilation-state.matches( - "compile-error-location"); - } - - tt-failure-code(): { - if (#subject.compilation-state.matches("compile-error-location")) { - return #subject.split-source[1]; - } - else { - return !!!("should look at failure-code only if is-failure"); - } + plain-text-expander: { :'/library/render/expander': + tt-plain-text(): { #replace-text(#subject); } + tt-failure-block(): { #skip(); } + tt-trace-block(): { #skip(); } } - tt-after-error(): { - if (#subject.compilation-state.matches("compile-error-location")) { - return #subject.split-source[2]; - } - else { - return false; - } + failure-listing-expander: { :'/library/render/expander': + tt-plain-text(): { #skip(); } + tt-failure-block(): { #keep(); } + tt-failure-code(): { #replace-text(#subject.code); } + tt-compile-message(): { #replace-text(#subject.message); } + tt-trace-block(): { #skip(); } } } @@ -547,6 +545,13 @@ } check-good-listing(expander): { + instruction := expander.get-instruction("listing") + #assert-equals("/library/render/instructions/repeat", + instruction.prototype().as-string); + + #assert-equals(1, instruction.contexts.size); + before-error := instruction.contexts[0].get-instruction("plain-text"); + #assert-equals( ""( a-number: 42 @@ -556,9 +561,7 @@ test-a-number(): { #assert-equals("bob", "bob"); } } ""), - expander.tt-before-error()); - #assert-equals(false, expander.tt-is-failure()); - #assert-equals(false, expander.tt-after-error()); + before-error.value); } test-view-bad-compile-location(): { @@ -566,30 +569,31 @@ #sample.do-compile(); expander := #sample.expander.new( subject: \#sample, request: \#sample-request); + + instruction := expander.get-instruction("listing") + #assert-equals("/library/render/instructions/repeat", + instruction.prototype().as-string); + + before-error := instruction.contexts[0].get-instruction("plain-text"); + #assert-equals("/library/render/instructions/replace", + before-error.prototype().as-string); + #assert-equals( "a-number: 142\n" + ... "a-string(", - expander.tt-before-error()); - #assert-equals(true, expander.tt-is-failure()); - #assert-equals(": \"the answer\")", expander.tt-failure-code()); - #assert-equals("unexpected token: :", expander.tt-compile-message()); - #assert-equals("\n", expander.tt-after-error()); + before-error.value); + + failure-code := instruction.contexts[1].get-instruction("failure-code"); + #assert-equals(": \"the answer\")", failure-code.value); + message := instruction.contexts[1].get-instruction("compile-message"); + #assert-equals("unexpected token: :", message.value); + + after-error := instruction.contexts[2].get-instruction("plain-text"); + #assert-equals("\n", after-error.value); } - test-view-bad-compile-location-2(): { - #sample.init(\#sample.source-text-bad-compile-2); - #sample.do-compile(); - expander := #sample.expander.new( - subject: \#sample, request: \#sample-request); - #assert-equals( - "a-number: 242\n" + - ... "a-string(): { return", - expander.tt-before-error()); - #assert-equals(true, expander.tt-is-failure()); - #assert-equals(" bob; }", expander.tt-failure-code()); - #assert-equals("system/method/exception/unknown-local(bob)", - expander.tt-compile-message()); - #assert-equals("\n", expander.tt-after-error()); + do-not-have-test-view-bad-compile-no-location(): { + #fail(); } test-view-page-good(): { @@ -628,17 +632,32 @@ expander := #sample.expander.new( subject: \#sample, request: \#sample-request); + instruction := expander.get-instruction("listing") + #assert-equals("/library/render/instructions/repeat", + instruction.prototype().as-string); + + before-error := instruction.contexts[0].get-instruction("plain-text"); + #assert-equals("/library/render/instructions/replace", + before-error.prototype().as-string); + #assert-equals( "parses: \"x<y || &foo > 5 || ãã¥ã¼ã¹\"\n" + ... "error: \"<&>\" ", - expander.tt-before-error()); - #assert-equals(true, expander.tt-is-failure()); - #assert-equals("bad \"<&>\"", expander.tt-failure-code()); + before-error.value); + + failure-code := instruction.contexts[1].get-instruction("failure-code"); + #assert-equals("bad \"<&>\"", failure-code.value); + message := instruction.contexts[1].get-instruction("compile-message"); + #assert-equals("expecting EOF, found 'bad'", message.value); + + after-error := instruction.contexts[2].get-instruction("plain-text"); #assert-equals( "\nnext-line: \"don't <stop> " + ... "æ¥æ¬èª\"\n", - expander.tt-after-error()); - #assert-equals("expecting EOF, found 'bad'", expander.tt-compile-message()); + after-error.value); + + #assert-equals("expecting EOF, found 'bad'", + expander.compile-message()); `` Pushing it through the template too is kind of redundant, `` but does provide a sanity check that we have replace-text |
From: Jim K. <ki...@us...> - 2005-03-19 08:59:04
|
Update of /cvsroot/wheat/r1/root/applications/farm.d/r In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25594/root/applications/farm.d/r Modified Files: farm.css Log Message: Add a start of trace display to the farm template and CSS. Refactor existing template for errors, so that it repeats blocks, rather than hardcoding the notion of blocks before and after the (single) error. Index: farm.css =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.d/r/farm.css,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- farm.css 12 Feb 2005 19:42:51 -0000 1.6 +++ farm.css 19 Mar 2005 08:58:55 -0000 1.7 @@ -306,4 +306,15 @@ margin-bottom: 0.3em; } -td.failure, td.pass { vertical-align: top } \ No newline at end of file +.traceMessage { + display: block; + color: #000060; + margin-left: 2em; + margin-bottom: 0.3em; +} + +.trace { + background: #bfbfff; +} + +td.failure, td.pass { vertical-align: top } |
From: Jim K. <ki...@us...> - 2005-03-19 08:59:04
|
Update of /cvsroot/wheat/r1/root/applications/farm.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25594/root/applications/farm.d Modified Files: view.html Log Message: Add a start of trace display to the farm template and CSS. Refactor existing template for errors, so that it repeats blocks, rather than hardcoding the notion of blocks before and after the (single) error. Index: view.html =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.d/view.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- view.html 14 Feb 2005 08:16:00 -0000 1.3 +++ view.html 19 Mar 2005 08:58:55 -0000 1.4 @@ -11,14 +11,20 @@ <div class="banner"> <h1><span class="suffix">Wheat</span>Farm</h1> </div> -<tt:span name="listing"> <pre> -<tt:span name="before-error">five: 5; -method(foo</tt:span><tt:span name="is-failure"><span class="failure"><a name="error" /><tt:span name="failure-code">: {</tt:span></span> -<span class="errorMessage" tt:name="compile-message">Don't you go putting that colon there</span></tt:span><tt:span name="after-error"> +<tt:span name="listing"><tt:span name="plain-text">five: 5; +method(foo</tt:span><tt:span name="failure-block"><span class="failure"><a name="error" /><tt:span name="failure-code">: {</tt:span></span> +<span class="errorMessage" tt:name="compile-message">Don't you go putting that colon there</span></tt:span><tt:example> #bar(); } -</tt:span></pre> -</tt:span> + +</tt:example><tt:span name="trace-block"><span class="trace"><tt:span name="trace-code">bar(): { + return !!!; +}</tt:span></span> +<span class="traceMessage" tt:name="trace-message">generated by bar()</span></tt:span><tt:example> + +baz(): { + return 4; +}</tt:example></tt:span></pre> </body> </html> |
From: Mark L. <mar...@us...> - 2005-03-19 01:43:51
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13572/grammar Modified Files: ScriptCompiler.cpp ScriptCompiler.hpp ScriptParser.cpp ScriptParser.hpp Log Message: checkin of antlr generates source Index: ScriptCompiler.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- ScriptCompiler.cpp 18 Mar 2005 07:18:48 -0000 1.33 +++ ScriptCompiler.cpp 19 Mar 2005 01:43:34 -0000 1.34 @@ -634,6 +634,8 @@ Wheat::MethodBuilder& mb, bool needsRet ) { antlr::RefSpanAST block_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; + antlr::RefSpanAST x = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST y = antlr::RefSpanAST(antlr::nullAST); try { // for error handling SOURCE(block_AST_in); @@ -661,16 +663,52 @@ if (_t == antlr::RefSpanAST(antlr::nullAST) ) _t = ASTNULL; switch ( _t->getType()) { - case BREAK: + case RETURN: { - breakStatement(_t,mb); + returnStatement(_t,mb); _t = _retTree; + { // ( ... )* + for (;;) { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + if (((_t->getType() >= NEWLINE && _t->getType() <= GLOBAL_ID))) { + x = _t; + if ( _t == antlr::RefSpanAST(antlr::nullAST) ) throw antlr::MismatchedTokenException(); + _t = _t->getNextSibling(); + throw buildException( + "system/method/exception/statement-after-return", x); + } + else { + goto _loop51; + } + + } + _loop51:; + } // ( ... )* break; } - case RETURN: + case BREAK: { - returnStatement(_t,mb); + breakStatement(_t,mb); _t = _retTree; + { // ( ... )* + for (;;) { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + if (((_t->getType() >= NEWLINE && _t->getType() <= GLOBAL_ID))) { + y = _t; + if ( _t == antlr::RefSpanAST(antlr::nullAST) ) throw antlr::MismatchedTokenException(); + _t = _t->getNextSibling(); + throw buildException( + "system/method/exception/statement-after-break", y); + } + else { + goto _loop53; + } + + } + _loop53:; + } // ( ... )* break; } case 3: @@ -798,17 +836,6 @@ _retTree = _t; } -void ScriptCompiler::breakStatement(antlr::RefSpanAST _t, - Wheat::MethodBuilder& mb -) { - antlr::RefSpanAST breakStatement_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; - - antlr::RefSpanAST tmp25_AST_in = _t; - match(antlr::RefAST(_t),BREAK); - _t = _t->getNextSibling(); - _retTree = _t; -} - void ScriptCompiler::returnStatement(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ) { @@ -816,8 +843,8 @@ try { // for error handling SOURCE(returnStatement_AST_in); - antlr::RefSpanAST __t64 = _t; - antlr::RefSpanAST tmp26_AST_in = _t; + antlr::RefSpanAST __t68 = _t; + antlr::RefSpanAST tmp25_AST_in = _t; match(antlr::RefAST(_t),RETURN); _t = _t->getFirstChild(); { @@ -826,7 +853,7 @@ switch ( _t->getType()) { case ABSENT: { - antlr::RefSpanAST tmp27_AST_in = _t; + antlr::RefSpanAST tmp26_AST_in = _t; match(antlr::RefAST(_t),ABSENT); _t = _t->getNextSibling(); mb.genReturn(); @@ -848,7 +875,7 @@ } } } - _t = __t64; + _t = __t68; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -857,6 +884,17 @@ _retTree = _t; } +void ScriptCompiler::breakStatement(antlr::RefSpanAST _t, + Wheat::MethodBuilder& mb +) { + antlr::RefSpanAST breakStatement_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; + + antlr::RefSpanAST tmp27_AST_in = _t; + match(antlr::RefAST(_t),BREAK); + _t = _t->getNextSibling(); + _retTree = _t; +} + void ScriptCompiler::expressionStatement(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ) { @@ -881,7 +919,7 @@ antlr::RefSpanAST conditionalStatement_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; try { // for error handling - antlr::RefSpanAST __t52 = _t; + antlr::RefSpanAST __t56 = _t; antlr::RefSpanAST tmp28_AST_in = _t; match(antlr::RefAST(_t),CONDITIONAL); _t = _t->getFirstChild(); @@ -897,11 +935,11 @@ mb.setTarget(toNext); } else { - goto _loop54; + goto _loop58; } } - _loop54:; + _loop58:; } // ( ... )* { if (_t == antlr::RefSpanAST(antlr::nullAST) ) @@ -924,7 +962,7 @@ } } mb.setTargets(toEnd); - _t = __t52; + _t = __t56; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -940,7 +978,7 @@ try { // for error handling SOURCE(loopStatement_AST_in); - antlr::RefSpanAST __t61 = _t; + antlr::RefSpanAST __t65 = _t; antlr::RefSpanAST tmp29_AST_in = _t; match(antlr::RefAST(_t),LOOP); _t = _t->getFirstChild(); @@ -961,7 +999,7 @@ mb.setTarget(toTop, top); mb.setTarget(toEnd); - _t = __t61; + _t = __t65; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -978,7 +1016,7 @@ try { // for error handling SOURCE(ifCondition_AST_in); - antlr::RefSpanAST __t57 = _t; + antlr::RefSpanAST __t61 = _t; antlr::RefSpanAST tmp30_AST_in = _t; match(antlr::RefAST(_t),IF); _t = _t->getFirstChild(); @@ -989,7 +1027,7 @@ block(_t,mb); _t = _retTree; bl.add(mb.genBranchAlways()); - _t = __t57; + _t = __t61; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1004,13 +1042,13 @@ ) { antlr::RefSpanAST elseCondition_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; - antlr::RefSpanAST __t59 = _t; + antlr::RefSpanAST __t63 = _t; antlr::RefSpanAST tmp31_AST_in = _t; match(antlr::RefAST(_t),ELSE); _t = _t->getFirstChild(); block(_t,mb); _t = _retTree; - _t = __t59; + _t = __t63; _t = _t->getNextSibling(); _retTree = _t; } @@ -1084,39 +1122,39 @@ switch ( _t->getType()) { case AS_COPY: { - antlr::RefSpanAST __t69 = _t; + antlr::RefSpanAST __t73 = _t; antlr::RefSpanAST tmp32_AST_in = _t; match(antlr::RefAST(_t),AS_COPY); _t = _t->getFirstChild(); r=expression(_t,mb); _t = _retTree; - _t = __t69; + _t = __t73; _t = _t->getNextSibling(); r = r.copy(); break; } case AS_LINK: { - antlr::RefSpanAST __t70 = _t; + antlr::RefSpanAST __t74 = _t; antlr::RefSpanAST tmp33_AST_in = _t; match(antlr::RefAST(_t),AS_LINK); _t = _t->getFirstChild(); r=expression(_t,mb); _t = _retTree; - _t = __t70; + _t = __t74; _t = _t->getNextSibling(); r = r.link(); break; } case AS_IS: { - antlr::RefSpanAST __t71 = _t; + antlr::RefSpanAST __t75 = _t; antlr::RefSpanAST tmp34_AST_in = _t; match(antlr::RefAST(_t),AS_IS); _t = _t->getFirstChild(); r=expression(_t,mb); _t = _retTree; - _t = __t71; + _t = __t75; _t = _t->getNextSibling(); r = r.asis(); break; @@ -1143,7 +1181,7 @@ try { // for error handling SOURCE(assignExpression_AST_in); - antlr::RefSpanAST __t73 = _t; + antlr::RefSpanAST __t77 = _t; antlr::RefSpanAST tmp35_AST_in = _t; match(antlr::RefAST(_t),ASSIGN); _t = _t->getFirstChild(); @@ -1163,14 +1201,14 @@ switch ( _t->getType()) { case LOCAL: { - antlr::RefSpanAST __t76 = _t; + antlr::RefSpanAST __t80 = _t; antlr::RefSpanAST tmp37_AST_in = _t; match(antlr::RefAST(_t),LOCAL); _t = _t->getFirstChild(); la = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t76; + _t = __t80; _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; @@ -1182,14 +1220,14 @@ } case GLOBAL: { - antlr::RefSpanAST __t77 = _t; + antlr::RefSpanAST __t81 = _t; antlr::RefSpanAST tmp38_AST_in = _t; match(antlr::RefAST(_t),GLOBAL); _t = _t->getFirstChild(); ga = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t77; + _t = __t81; _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; @@ -1237,14 +1275,14 @@ switch ( _t->getType()) { case LOCAL: { - antlr::RefSpanAST __t79 = _t; + antlr::RefSpanAST __t83 = _t; antlr::RefSpanAST tmp39_AST_in = _t; match(antlr::RefAST(_t),LOCAL); _t = _t->getFirstChild(); lb = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t79; + _t = __t83; _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; @@ -1259,14 +1297,14 @@ } case GLOBAL: { - antlr::RefSpanAST __t80 = _t; + antlr::RefSpanAST __t84 = _t; antlr::RefSpanAST tmp40_AST_in = _t; match(antlr::RefAST(_t),GLOBAL); _t = _t->getFirstChild(); gb = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t80; + _t = __t84; _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; @@ -1311,7 +1349,7 @@ } } } - _t = __t73; + _t = __t77; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1330,7 +1368,7 @@ try { // for error handling SOURCE(shortExpression_AST_in); - antlr::RefSpanAST __t82 = _t; + antlr::RefSpanAST __t86 = _t; antlr::RefSpanAST tmp41_AST_in = _t; match(antlr::RefAST(_t),SHORT); _t = _t->getFirstChild(); @@ -1357,7 +1395,7 @@ mb.genCopy(v, r); mb.setTarget(toEnd); - _t = __t82; + _t = __t86; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1401,26 +1439,26 @@ switch ( _t->getType()) { case IS_DEFINED: { - antlr::RefSpanAST __t98 = _t; + antlr::RefSpanAST __t102 = _t; antlr::RefSpanAST tmp42_AST_in = _t; match(antlr::RefAST(_t),IS_DEFINED); _t = _t->getFirstChild(); r=expression(_t,mb); _t = _retTree; - _t = __t98; + _t = __t102; _t = _t->getNextSibling(); r = mb.genIsDefined(r); break; } case IS_ERROR: { - antlr::RefSpanAST __t99 = _t; + antlr::RefSpanAST __t103 = _t; antlr::RefSpanAST tmp43_AST_in = _t; match(antlr::RefAST(_t),IS_ERROR); _t = _t->getFirstChild(); r=expression(_t,mb); _t = _retTree; - _t = __t99; + _t = __t103; _t = _t->getNextSibling(); r = mb.genIsError(r); break; @@ -1480,35 +1518,35 @@ } case LOCAL: { - antlr::RefSpanAST __t102 = _t; + antlr::RefSpanAST __t106 = _t; antlr::RefSpanAST tmp44_AST_in = _t; match(antlr::RefAST(_t),LOCAL); _t = _t->getFirstChild(); l = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t102; + _t = __t106; _t = _t->getNextSibling(); r = mb.genLocal(astString(l), false); break; } case GLOBAL: { - antlr::RefSpanAST __t103 = _t; + antlr::RefSpanAST __t107 = _t; antlr::RefSpanAST tmp45_AST_in = _t; match(antlr::RefAST(_t),GLOBAL); _t = _t->getFirstChild(); g = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t103; + _t = __t107; _t = _t->getNextSibling(); r = mb.genGlobal(astString(g)); break; } case LITERAL: { - antlr::RefSpanAST __t104 = _t; + antlr::RefSpanAST __t108 = _t; antlr::RefSpanAST tmp46_AST_in = _t; match(antlr::RefAST(_t),LITERAL); _t = _t->getFirstChild(); @@ -1518,7 +1556,7 @@ value(_t,op); _t = _retTree; - _t = __t104; + _t = __t108; _t = _t->getNextSibling(); break; } @@ -1552,7 +1590,7 @@ switch ( _t->getType()) { case UNARY: { - antlr::RefSpanAST __t86 = _t; + antlr::RefSpanAST __t90 = _t; antlr::RefSpanAST tmp47_AST_in = _t; match(antlr::RefAST(_t),UNARY); _t = _t->getFirstChild(); @@ -1562,13 +1600,13 @@ c.setMessage(astString(uop)); r=expression(_t,mb); _t = _retTree; - _t = __t86; + _t = __t90; _t = _t->getNextSibling(); break; } case BINARY: { - antlr::RefSpanAST __t87 = _t; + antlr::RefSpanAST __t91 = _t; antlr::RefSpanAST tmp48_AST_in = _t; match(antlr::RefAST(_t),BINARY); _t = _t->getFirstChild(); @@ -1582,13 +1620,13 @@ arg=expression(_t,mb); _t = _retTree; c.addPosArg(arg); - _t = __t87; + _t = __t91; _t = _t->getNextSibling(); break; } case CALL: { - antlr::RefSpanAST __t88 = _t; + antlr::RefSpanAST __t92 = _t; antlr::RefSpanAST tmp49_AST_in = _t; match(antlr::RefAST(_t),CALL); _t = _t->getFirstChild(); @@ -1600,7 +1638,7 @@ _t = _retTree; callArgs(_t,mb, c); _t = _retTree; - _t = __t88; + _t = __t92; _t = _t->getNextSibling(); break; } @@ -1632,11 +1670,11 @@ _t = _retTree; } else { - goto _loop91; + goto _loop95; } } - _loop91:; + _loop95:; } // ( ... )* _retTree = _t; } @@ -1655,7 +1693,7 @@ switch ( _t->getType()) { case ARG_KEY: { - antlr::RefSpanAST __t94 = _t; + antlr::RefSpanAST __t98 = _t; antlr::RefSpanAST tmp50_AST_in = _t; match(antlr::RefAST(_t),ARG_KEY); _t = _t->getFirstChild(); @@ -1664,20 +1702,20 @@ _t = _t->getNextSibling(); r=reference(_t,mb); _t = _retTree; - _t = __t94; + _t = __t98; _t = _t->getNextSibling(); c.addKeyArg(astString(i), r); break; } case ARG_POS: { - antlr::RefSpanAST __t95 = _t; + antlr::RefSpanAST __t99 = _t; antlr::RefSpanAST tmp51_AST_in = _t; match(antlr::RefAST(_t),ARG_POS); _t = _t->getFirstChild(); r=reference(_t,mb); _t = _retTree; - _t = __t95; + _t = __t99; _t = _t->getNextSibling(); c.addPosArg(r); break; @@ -1743,10 +1781,11 @@ Wheat::MethodBuilder::Register r; antlr::RefSpanAST buildObject_AST_in = (_t == ASTNULL) ? antlr::RefSpanAST(antlr::nullAST) : _t; antlr::RefSpanAST i = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST x = antlr::RefSpanAST(antlr::nullAST); try { // for error handling SOURCE(buildObject_AST_in); - antlr::RefSpanAST __t108 = _t; + antlr::RefSpanAST __t112 = _t; antlr::RefSpanAST tmp54_AST_in = _t; match(antlr::RefAST(_t),BUILD_OBJECT); _t = _t->getFirstChild(); @@ -1760,7 +1799,7 @@ _t = ASTNULL; if ((_t->getType() == MEMBER)) { MethodBuilder::Register v; - antlr::RefSpanAST __t110 = _t; + antlr::RefSpanAST __t114 = _t; antlr::RefSpanAST tmp55_AST_in = _t; match(antlr::RefAST(_t),MEMBER); _t = _t->getFirstChild(); @@ -1769,7 +1808,7 @@ _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; - _t = __t110; + _t = __t114; _t = _t->getNextSibling(); MethodBuilder::Call c; @@ -1793,13 +1832,31 @@ } else { - goto _loop111; + goto _loop115; } } - _loop111:; + _loop115:; } // ( ... )* - _t = __t108; + { // ( ... )* + for (;;) { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + if (((_t->getType() >= NEWLINE && _t->getType() <= GLOBAL_ID))) { + x = _t; + if ( _t == antlr::RefSpanAST(antlr::nullAST) ) throw antlr::MismatchedTokenException(); + _t = _t->getNextSibling(); + throw buildException( + "unrecognized element when building object", x); + } + else { + goto _loop117; + } + + } + _loop117:; + } // ( ... )* + _t = __t112; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1817,7 +1874,7 @@ try { // for error handling SOURCE(buildArray_AST_in); - antlr::RefSpanAST __t113 = _t; + antlr::RefSpanAST __t119 = _t; antlr::RefSpanAST tmp56_AST_in = _t; match(antlr::RefAST(_t),BUILD_ARRAY); _t = _t->getFirstChild(); @@ -1842,13 +1899,13 @@ } else { - goto _loop115; + goto _loop121; } } - _loop115:; + _loop121:; } // ( ... )* - _t = __t113; + _t = __t119; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1866,7 +1923,7 @@ try { // for error handling SOURCE(buildError_AST_in); - antlr::RefSpanAST __t118 = _t; + antlr::RefSpanAST __t124 = _t; antlr::RefSpanAST tmp57_AST_in = _t; match(antlr::RefAST(_t),BUILD_ERROR); _t = _t->getFirstChild(); @@ -1896,13 +1953,13 @@ } else { - goto _loop120; + goto _loop126; } } - _loop120:; + _loop126:; } // ( ... )* - _t = __t118; + _t = __t124; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { Index: ScriptCompiler.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.hpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ScriptCompiler.hpp 18 Mar 2005 07:18:49 -0000 1.23 +++ ScriptCompiler.hpp 19 Mar 2005 01:43:34 -0000 1.24 @@ -99,10 +99,10 @@ public: void statement(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ); - public: void breakStatement(antlr::RefSpanAST _t, + public: void returnStatement(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ); - public: void returnStatement(antlr::RefSpanAST _t, + public: void breakStatement(antlr::RefSpanAST _t, Wheat::MethodBuilder& mb ); public: void expressionStatement(antlr::RefSpanAST _t, Index: ScriptParser.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- ScriptParser.cpp 18 Mar 2005 07:18:49 -0000 1.25 +++ ScriptParser.cpp 19 Mar 2005 01:43:34 -0000 1.26 @@ -3852,6 +3852,7 @@ { switch ( LA(1)) { + case DASHDASH: case ID: { buildObjectMember(); @@ -3864,6 +3865,7 @@ end(); { switch ( LA(1)) { + case DASHDASH: case ID: { buildObjectMember(); @@ -3912,32 +3914,136 @@ returnAST = antlr::RefSpanAST(antlr::nullAST); antlr::ASTPair currentAST; antlr::RefSpanAST buildObjectMember_AST = antlr::RefSpanAST(antlr::nullAST); - antlr::RefToken i = antlr::nullToken; + + if ((LA(1) == DASHDASH)) { + objectMode(); + if (inputState->guessing==0) { + astFactory->addASTChild(currentAST, antlr::RefAST(returnAST)); + } + buildObjectMember_AST = antlr::RefSpanAST(currentAST.root); + } + else if ((LA(1) == ID) && (LA(2) == COLON)) { + objectMember(); + if (inputState->guessing==0) { + astFactory->addASTChild(currentAST, antlr::RefAST(returnAST)); + } + buildObjectMember_AST = antlr::RefSpanAST(currentAST.root); + } + else if ((LA(1) == ID) && (LA(2) == LPAREN)) { + objectMethod(); + if (inputState->guessing==0) { + astFactory->addASTChild(currentAST, antlr::RefAST(returnAST)); + } + buildObjectMember_AST = antlr::RefSpanAST(currentAST.root); + } + else { + throw antlr::NoViableAltException(LT(1), getFilename()); + } + + returnAST = buildObjectMember_AST; +} + +void ScriptParser::objectMode() { + returnAST = antlr::RefSpanAST(antlr::nullAST); + antlr::ASTPair currentAST; + antlr::RefSpanAST objectMode_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefToken zs = antlr::nullToken; + antlr::RefSpanAST zs_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST i_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefToken ze = antlr::nullToken; + antlr::RefSpanAST ze_AST = antlr::RefSpanAST(antlr::nullAST); + + zs = LT(1); + zs_AST = astFactory->create(zs); + match(DASHDASH); + id(); + if (inputState->guessing==0) { + i_AST = returnAST; + } + ze = LT(1); + ze_AST = astFactory->create(ze); + match(DASHDASH); + if ( inputState->guessing==0 ) { + objectMode_AST = antlr::RefSpanAST(currentAST.root); + objectMode_AST = antlr::RefSpanAST(astFactory->make((new antlr::ASTArray(2))->add(antlr::RefAST(astFactory->create(MODE)))->add(antlr::RefAST(i_AST)))); + currentAST.root = objectMode_AST; + if ( objectMode_AST!=antlr::RefSpanAST(antlr::nullAST) && + objectMode_AST->getFirstChild() != antlr::RefSpanAST(antlr::nullAST) ) + currentAST.child = objectMode_AST->getFirstChild(); + else + currentAST.child = objectMode_AST; + currentAST.advanceChildToEnd(); + } + if ( inputState->guessing==0 ) { + objectMode_AST = antlr::RefSpanAST(currentAST.root); + objectMode_AST->includeSpan(zs, ze); + } + returnAST = objectMode_AST; +} + +void ScriptParser::objectMember() { + returnAST = antlr::RefSpanAST(antlr::nullAST); + antlr::ASTPair currentAST; + antlr::RefSpanAST objectMember_AST = antlr::RefSpanAST(antlr::nullAST); antlr::RefSpanAST i_AST = antlr::RefSpanAST(antlr::nullAST); antlr::RefSpanAST v_AST = antlr::RefSpanAST(antlr::nullAST); - i = LT(1); - if ( inputState->guessing == 0 ) { - i_AST = astFactory->create(i); + id(); + if (inputState->guessing==0) { + i_AST = returnAST; } - match(ID); match(COLON); reference(); if (inputState->guessing==0) { v_AST = returnAST; } if ( inputState->guessing==0 ) { - buildObjectMember_AST = antlr::RefSpanAST(currentAST.root); - buildObjectMember_AST = antlr::RefSpanAST(astFactory->make((new antlr::ASTArray(3))->add(antlr::RefAST(astFactory->create(MEMBER)))->add(antlr::RefAST(i_AST))->add(antlr::RefAST(v_AST)))); - currentAST.root = buildObjectMember_AST; - if ( buildObjectMember_AST!=antlr::RefSpanAST(antlr::nullAST) && - buildObjectMember_AST->getFirstChild() != antlr::RefSpanAST(antlr::nullAST) ) - currentAST.child = buildObjectMember_AST->getFirstChild(); + objectMember_AST = antlr::RefSpanAST(currentAST.root); + objectMember_AST = antlr::RefSpanAST(astFactory->make((new antlr::ASTArray(3))->add(antlr::RefAST(astFactory->create(MEMBER)))->add(antlr::RefAST(i_AST))->add(antlr::RefAST(v_AST)))); + currentAST.root = objectMember_AST; + if ( objectMember_AST!=antlr::RefSpanAST(antlr::nullAST) && + objectMember_AST->getFirstChild() != antlr::RefSpanAST(antlr::nullAST) ) + currentAST.child = objectMember_AST->getFirstChild(); else - currentAST.child = buildObjectMember_AST; + currentAST.child = objectMember_AST; currentAST.advanceChildToEnd(); } - returnAST = buildObjectMember_AST; + returnAST = objectMember_AST; +} + +void ScriptParser::objectMethod() { + returnAST = antlr::RefSpanAST(antlr::nullAST); + antlr::ASTPair currentAST; + antlr::RefSpanAST objectMethod_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST i_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST a_AST = antlr::RefSpanAST(antlr::nullAST); + antlr::RefSpanAST b_AST = antlr::RefSpanAST(antlr::nullAST); + + id(); + if (inputState->guessing==0) { + i_AST = returnAST; + } + methodArgs(); + if (inputState->guessing==0) { + a_AST = returnAST; + } + match(COLON); + methodBody(); + if (inputState->guessing==0) { + b_AST = returnAST; + } + if ( inputState->guessing==0 ) { + objectMethod_AST = antlr::RefSpanAST(currentAST.root); + objectMethod_AST = antlr::RefSpanAST(astFactory->make((new antlr::ASTArray(3))->add(antlr::RefAST(astFactory->create(MEMBER)))->add(antlr::RefAST(i_AST))->add(antlr::RefAST(antlr::RefSpanAST(astFactory->make((new antlr::ASTArray(3))->add(antlr::RefAST(astFactory->create(METHOD)))->add(antlr::RefAST(a_AST))->add(antlr::RefAST(b_AST)))))))); + currentAST.root = objectMethod_AST; + if ( objectMethod_AST!=antlr::RefSpanAST(antlr::nullAST) && + objectMethod_AST->getFirstChild() != antlr::RefSpanAST(antlr::nullAST) ) + currentAST.child = objectMethod_AST->getFirstChild(); + else + currentAST.child = objectMethod_AST; + currentAST.advanceChildToEnd(); + } + returnAST = objectMethod_AST; } void ScriptParser::buildArrayContent() { @@ -3987,11 +4093,11 @@ } } else { - goto _loop140; + goto _loop143; } } - _loop140:; + _loop143:; } // ( ... )* { switch ( LA(1)) { Index: ScriptParser.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.hpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ScriptParser.hpp 18 Mar 2005 07:18:50 -0000 1.20 +++ ScriptParser.hpp 19 Mar 2005 01:43:34 -0000 1.21 @@ -129,6 +129,9 @@ public: void buildProto(); public: void buildObjectContent(); public: void buildObjectMember(); + public: void objectMode(); + public: void objectMember(); + public: void objectMethod(); public: void buildArrayContent(); public: antlr::RefAST getAST() |
From: Mark L. <mar...@us...> - 2005-03-19 01:43:12
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12627/grammar Modified Files: ScriptCompiler.g ScriptParser.g ScriptParser-test.cpp Log Message: parsing of modes and methods inside dynamically built objects - still can't compile them yet (see commented out test) catching and reporting statements that follow return or break statements Index: ScriptCompiler.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.g,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- ScriptCompiler.g 3 Mar 2005 02:41:40 -0000 1.25 +++ ScriptCompiler.g 19 Mar 2005 01:42:59 -0000 1.26 @@ -239,10 +239,18 @@ block [Wheat::MethodBuilder& mb, bool needsRet = false]: { SOURCE(#block); } #(BLOCK { mb.startLocalBlock(); } - (statement[mb])* + ( options{greedy=true;}: + statement[mb] + )* ( - breakStatement[mb] - | returnStatement[mb] + returnStatement[mb] + ( x:. { throw buildException( + "system/method/exception/statement-after-return", #x); } + )* + | breakStatement[mb] + ( y:. { throw buildException( + "system/method/exception/statement-after-break", #y); } + )* | { if (needsRet) mb.genReturn(); } ) { mb.endLocalBlock(); } @@ -514,7 +522,7 @@ { SOURCE(#buildObject); } #(BUILD_OBJECT { MethodBuilder::Register p; bool nop; } p=buildProto[mb, nop] { r = mb.genNewObject(p); } - ( { MethodBuilder::Register v; } + ( options{greedy=true;}: { MethodBuilder::Register v; } #(MEMBER i:ID v=reference[mb]) { MethodBuilder::Call c; @@ -537,6 +545,9 @@ mb.genCall(c); } )* + ( x:. { throw buildException( + "unrecognized element when building object", #x); } + )* ) ; exception Index: ScriptParser-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser-test.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- ScriptParser-test.cpp 18 Mar 2005 07:18:49 -0000 1.27 +++ ScriptParser-test.cpp 19 Mar 2005 01:43:00 -0000 1.28 @@ -489,7 +489,7 @@ } -TEST(scriptParser, buildTerms) +TEST(scriptParser, buildObjects) { checkBlockParseTree(HERE, "{ { }; }", @@ -522,7 +522,26 @@ " (BLOCK (BUILD_OBJECT SELF" " (MEMBER ID<x> (AS_COPY (LOCAL ID<y>)))" "))"); + + checkBlockParseTree(HERE, + "{ {\n" + " -- instance --\n" + " var: ???\n" + " -- public --\n" + " foo(): { return #var }\n" + "} }\n", + " (BLOCK (BUILD_OBJECT ABSENT" + " (MODE ID<instance>)" + " (MEMBER ID<var> (AS_COPY (LITERAL V_UNKNOWN)))" + " (MODE ID<public>)" + " (MEMBER ID<foo> (METHOD ARGS (BLOCK" + " (RETURN (AS_COPY (CALL ID<var> SELF)))" + ")))" + "))"); +} +TEST(scriptParser, buildArrays) +{ checkBlockParseTree(HERE, "{ [ ]; }", " (BLOCK (BUILD_ARRAY ABSENT))"); @@ -547,8 +566,10 @@ checkBlockParseTree(HERE, "{ [:'../../bob': \"zoo\"]; }", " (BLOCK (BUILD_ARRAY ID<../../bob> (AS_COPY (LITERAL STRING<zoo>))))"); +} - +TEST(scriptParser, buildErrors) +{ checkBlockParseTree(HERE, "{ !!!; }", " (BLOCK BUILD_ERROR)"); @@ -1162,4 +1183,13 @@ ")" " (LOCAL[1:15~20] ID<carla>[1:15~20])" "))"); + + checkBlockParseSpans(HERE, + // 1234.6789.1234.6789.1234.6789.1234 + "{ { -- instance --; var: ??? } }", + " (BLOCK[1:0~32] (BUILD_OBJECT[1:2~30] ABSENT[]" + " (MODE[1:4~18] ID<instance>[1:7~15])" + " (MEMBER[1:20~28] ID<var>[1:20~23]" + " (AS_COPY[1:25~28] (LITERAL[1:25~28] V_UNKNOWN[1:25~28])))" + "))"); } Index: ScriptParser.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.g,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- ScriptParser.g 18 Mar 2005 07:18:49 -0000 1.25 +++ ScriptParser.g 19 Mar 2005 01:43:00 -0000 1.26 @@ -451,10 +451,26 @@ end! ( buildObjectMember )? )* )? ; -buildObjectMember!: - i:ID ":" v:reference { ## = #([MEMBER], #i, #v); } +buildObjectMember: + objectMode + | objectMember + | objectMethod + ; + +objectMode!: + zs:"--" i:id ze:"--" { ## = #([MODE], #i); } + { ##->includeSpan(zs, ze); } + ; + +objectMember!: + i:id ":" v:reference { ## = #([MEMBER], #i, #v); } ; +objectMethod!: + i:id a:methodArgs ":" b:methodBody + { ## = #([MEMBER], #i, ([METHOD], #a, #b)); } + ; + buildArray!: zs:"[" p:buildProto mayEnd! c:buildArrayContent |
From: Mark L. <mar...@us...> - 2005-03-19 01:43:12
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12627/wheat Modified Files: compiler-test.cpp Log Message: parsing of modes and methods inside dynamically built objects - still can't compile them yet (see commented out test) catching and reporting statements that follow return or break statements Index: compiler-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/compiler-test.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- compiler-test.cpp 3 Mar 2005 02:43:55 -0000 1.35 +++ compiler-test.cpp 19 Mar 2005 01:43:00 -0000 1.36 @@ -751,6 +751,36 @@ CHECK_SAME("alt", c.target().send("asis-link").asString()); } +#if 0 +TEST(compiler, dynamicObjects) +{ + CompilerTestSetup c( + "outer-thing: {\n" + " -- instance --\n" + " var: ???\n" + " -- public --\n" + " new(n): { return {:self: var: n } }\n" + " make-inner-thing(n): {\n" + " return {:self:\n" + " -- instance --\n" + " var: n\n" + " -- public --\n" + " get-var(): { return #var }\n" + " }\n" + " }\n" + "}\n" + "make-outer-thing(n): { return #outer-thing.new(n) }\n" + "a(): {\n" + " o := #make-outer-thing(34)\n" + " i := o.make-inner-thing(56)\n" + " return i.get-var()\n" + "}\n" + ); + + CHECK_SAME(56, c.target().send("a").asInt()); +} +#endif + TEST(compiler, errorPropagation) { CompilerTestSetup c( @@ -812,6 +842,12 @@ CHECK_SAME("system/method/exception/unknown-local(b)", r.errorMessage); CHECK_SAME(1, r.errorLocation.start.line); CHECK_SAME(14, r.errorLocation.start.byte); + + // statements after return + r = setup.compileWithResult("a(): { return 34; #foo() }\n"); + CHECK_SAME(false, r.success); + CHECK_SAME("system/method/exception/statement-after-return", + r.errorMessage); } namespace { |
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30557/grammar Modified Files: ScriptCompiler.cpp ScriptCompiler.hpp ScriptCompilerTokenTypes.hpp ScriptCompilerTokenTypes.txt ScriptLexer-test.cpp ScriptLexer.cpp ScriptLexer.g ScriptLexer.hpp ScriptLexerTokenTypes.hpp ScriptLexerTokenTypes.txt ScriptParser-test.cpp ScriptParser.cpp ScriptParser.g ScriptParser.hpp ScriptParserTokenTypes.hpp ScriptParserTokenTypes.txt Log Message: newlines as statement and member terminator (see http://www.wheatfarm.org/wiki/NewlineAsTerminator for notes) Index: ScriptLexer.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.g,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ScriptLexer.g 19 Feb 2005 00:34:30 -0000 1.21 +++ ScriptLexer.g 18 Mar 2005 07:18:49 -0000 1.22 @@ -37,22 +37,13 @@ virtual void tab(); } -WS : ( ' ' | '\t' | '\f' )+ - { $setType(antlr::Token::SKIP); } ; +protected WSCHAR : ' ' | '\t' | '\f' ; +protected WS : ( options{greedy=true;}: WSCHAR )+ ; -NL : ( '\r' ( options{greedy=true;}: '\n' )? | '\n' ) - { newline(); $setType(antlr::Token::SKIP); } ; +protected NL : ( '\r' ( options{greedy=true;}: '\n' )? | '\n' ) { newline(); } ; -COMMENT : - ( - ( "(``" | "``(" ) => NEST_COMMENT - | ( "``" ~')' ) => LINE_COMMENT - ) - { $setType(antlr::Token::SKIP); } - ; - protected LINE_COMMENT : - "``" (~('\r'|'\n'))* NL ; + "``" ( options{greedy=true;}: ~('\r'|'\n'))* ; protected NEST_COMMENT : ( "(``" | "``(" ) @@ -68,6 +59,29 @@ "``)" ; +COMMENT : + ( + ( "(``" | "``(" ) => NEST_COMMENT + | ( "``" ~')' ) => LINE_COMMENT + ) { $setType(antlr::Token::SKIP); } + ; + +WHITESPACE : + WS { $setType(antlr::Token::SKIP); } + ; + +NEWLINE : + ( NL ( WS )? )+ + ( + ('"' '"' '(')=> { $setType(antlr::Token::SKIP); } + | ("...")=> "..." { $setType(antlr::Token::SKIP); } +// | "\u00e2\u0080\u00a6" { $setType(antlr::Token::SKIP); } +// unicode elipses -- Antlr fails here! + | + ) + ; + + NUMBER: ( DIGIT )+ ; @@ -103,7 +117,7 @@ )* NL! { append('\n'); } )* - "\"\")"! (WS!)? NL! + "\"\")"! ; protected ESCAPE: '\\'! Index: ScriptCompiler.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.hpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- ScriptCompiler.hpp 7 Jan 2005 03:57:29 -0000 1.22 +++ ScriptCompiler.hpp 18 Mar 2005 07:18:49 -0000 1.23 @@ -177,10 +177,10 @@ private: static const char* tokenNames[]; #ifndef NO_STATIC_CONSTS - static const int NUM_TOKENS = 90; + static const int NUM_TOKENS = 91; #else enum { - NUM_TOKENS = 90 + NUM_TOKENS = 91 }; #endif Index: ScriptCompilerTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompilerTokenTypes.hpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- ScriptCompilerTokenTypes.hpp 4 Jan 2005 07:17:48 -0000 1.17 +++ ScriptCompilerTokenTypes.hpp 18 Mar 2005 07:18:49 -0000 1.18 @@ -12,92 +12,93 @@ #endif enum { EOF_ = 1, - LPAREN = 4, - RPAREN = 5, - LBRACK = 6, - RBRACK = 7, - LCURLY = 8, - RCURLY = 9, - COMMA = 10, - PERIOD = 11, - SEMI = 12, - COLON = 13, - DASHDASH = 14, - LINK = 15, - IS_DEFINED = 16, - SHORT_DEFINED = 17, - V_UNKNOWN = 18, - IS_ERROR = 19, - SHORT_ERROR = 20, - V_ERROR = 21, - AS_LINK = 22, - AS_IS = 23, - V_NULL = 24, - V_TRUE = 25, - V_FALSE = 26, - SHORT_AND = 27, - SHORT_OR = 28, - ASSIGN_OP = 29, - ASSIGN_SUFFIX = 30, - SCRIPT = 31, - DECLS = 32, - USE = 33, - PATH = 34, - ARRAY = 35, - OBJECT = 36, - MODE = 37, - MEMBER = 38, - INCLUDE = 39, - METHOD = 40, - ARGS = 41, - ARG_POS = 42, - ARG_KEY = 43, - BLOCK = 44, - CONDITIONAL = 45, - IF = 46, - ELSE = 47, - LOOP = 48, - BREAK = 49, - RETURN = 50, - ASSIGN = 51, - SHORT = 52, - UNARY = 53, - BINARY = 54, - CALL = 55, - AS_COPY = 56, - LITERAL = 57, - SELF = 58, - THIS = 59, - LOCAL = 60, - GLOBAL = 61, - BUILD_OBJECT = 62, - BUILD_ARRAY = 63, - BUILD_ERROR = 64, - ABSENT = 65, - LITERAL_wheat = 66, - LITERAL_version = 67, - NUMBER = 68, - LITERAL_charset = 69, - LITERAL_use = 70, - STRING = 71, - LITERAL_as = 72, - ID = 73, - LITERAL_include = 74, - LITERAL_if = 75, - LITERAL_else = 76, - LITERAL_while = 77, - LITERAL_break = 78, - LITERAL_return = 79, - LITERAL_do = 80, - LITERAL_self = 81, - LITERAL_this = 82, - OP_1 = 83, - OP_2 = 84, - OP_3 = 85, - OP_4 = 86, - OP_5 = 87, - INSTANCE_ID = 88, - GLOBAL_ID = 89, + NEWLINE = 4, + LPAREN = 5, + RPAREN = 6, + LBRACK = 7, + RBRACK = 8, + LCURLY = 9, + RCURLY = 10, + COMMA = 11, + PERIOD = 12, + SEMI = 13, + COLON = 14, + DASHDASH = 15, + LINK = 16, + IS_DEFINED = 17, + SHORT_DEFINED = 18, + V_UNKNOWN = 19, + IS_ERROR = 20, + SHORT_ERROR = 21, + V_ERROR = 22, + AS_LINK = 23, + AS_IS = 24, + V_NULL = 25, + V_TRUE = 26, + V_FALSE = 27, + SHORT_AND = 28, + SHORT_OR = 29, + ASSIGN_OP = 30, + ASSIGN_SUFFIX = 31, + SCRIPT = 32, + DECLS = 33, + USE = 34, + PATH = 35, + ARRAY = 36, + OBJECT = 37, + MODE = 38, + MEMBER = 39, + INCLUDE = 40, + METHOD = 41, + ARGS = 42, + ARG_POS = 43, + ARG_KEY = 44, + BLOCK = 45, + CONDITIONAL = 46, + IF = 47, + ELSE = 48, + LOOP = 49, + BREAK = 50, + RETURN = 51, + ASSIGN = 52, + SHORT = 53, + UNARY = 54, + BINARY = 55, + CALL = 56, + AS_COPY = 57, + LITERAL = 58, + SELF = 59, + THIS = 60, + LOCAL = 61, + GLOBAL = 62, + BUILD_OBJECT = 63, + BUILD_ARRAY = 64, + BUILD_ERROR = 65, + ABSENT = 66, + LITERAL_wheat = 67, + LITERAL_version = 68, + NUMBER = 69, + LITERAL_charset = 70, + LITERAL_use = 71, + STRING = 72, + LITERAL_as = 73, + ID = 74, + LITERAL_include = 75, + LITERAL_if = 76, + LITERAL_else = 77, + LITERAL_while = 78, + LITERAL_break = 79, + LITERAL_return = 80, + LITERAL_do = 81, + LITERAL_self = 82, + LITERAL_this = 83, + OP_1 = 84, + OP_2 = 85, + OP_3 = 86, + OP_4 = 87, + OP_5 = 88, + INSTANCE_ID = 89, + GLOBAL_ID = 90, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptCompilerTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompilerTokenTypes.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- ScriptCompilerTokenTypes.txt 4 Jan 2005 07:17:48 -0000 1.17 +++ ScriptCompilerTokenTypes.txt 18 Mar 2005 07:18:49 -0000 1.18 @@ -1,88 +1,89 @@ // $ANTLR 2.7.3 (20041222-1): ScriptCompiler.g -> ScriptCompilerTokenTypes.txt$ ScriptCompiler // output token vocab name -LPAREN="("=4 -RPAREN=")"=5 -LBRACK="["=6 -RBRACK="]"=7 -LCURLY="{"=8 -RCURLY="}"=9 -COMMA=","=10 -PERIOD="."=11 -SEMI=";"=12 -COLON=":"=13 -DASHDASH="--"=14 -LINK="->"=15 -IS_DEFINED="?"=16 -SHORT_DEFINED="??"=17 -V_UNKNOWN="???"=18 -IS_ERROR="!"=19 -SHORT_ERROR="!!"=20 -V_ERROR="!!!"=21 -AS_LINK="\\"=22 -AS_IS="\\\\"=23 -V_NULL="null"=24 -V_TRUE="true"=25 -V_FALSE="false"=26 -SHORT_AND="&&"=27 -SHORT_OR="||"=28 -ASSIGN_OP=":="=29 -ASSIGN_SUFFIX="="=30 -SCRIPT=31 -DECLS=32 -USE=33 -PATH=34 -ARRAY=35 -OBJECT=36 -MODE=37 -MEMBER=38 -INCLUDE=39 -METHOD=40 -ARGS=41 -ARG_POS=42 -ARG_KEY=43 -BLOCK=44 -CONDITIONAL=45 -IF=46 -ELSE=47 -LOOP=48 -BREAK=49 -RETURN=50 -ASSIGN=51 -SHORT=52 -UNARY=53 -BINARY=54 -CALL=55 -AS_COPY=56 -LITERAL=57 -SELF=58 -THIS=59 -LOCAL=60 -GLOBAL=61 -BUILD_OBJECT=62 -BUILD_ARRAY=63 -BUILD_ERROR=64 -ABSENT=65 -LITERAL_wheat="wheat"=66 -LITERAL_version="version"=67 -NUMBER=68 -LITERAL_charset="charset"=69 -LITERAL_use="use"=70 -STRING=71 -LITERAL_as="as"=72 -ID=73 -LITERAL_include="include"=74 -LITERAL_if="if"=75 -LITERAL_else="else"=76 -LITERAL_while="while"=77 -LITERAL_break="break"=78 -LITERAL_return="return"=79 -LITERAL_do="do"=80 -LITERAL_self="self"=81 -LITERAL_this="this"=82 -OP_1=83 -OP_2=84 -OP_3=85 -OP_4=86 -OP_5=87 -INSTANCE_ID=88 -GLOBAL_ID=89 +NEWLINE=4 +LPAREN="("=5 +RPAREN=")"=6 +LBRACK="["=7 +RBRACK="]"=8 +LCURLY="{"=9 +RCURLY="}"=10 +COMMA=","=11 +PERIOD="."=12 +SEMI=";"=13 +COLON=":"=14 +DASHDASH="--"=15 +LINK="->"=16 +IS_DEFINED="?"=17 +SHORT_DEFINED="??"=18 +V_UNKNOWN="???"=19 +IS_ERROR="!"=20 +SHORT_ERROR="!!"=21 +V_ERROR="!!!"=22 +AS_LINK="\\"=23 +AS_IS="\\\\"=24 +V_NULL="null"=25 +V_TRUE="true"=26 +V_FALSE="false"=27 +SHORT_AND="&&"=28 +SHORT_OR="||"=29 +ASSIGN_OP=":="=30 +ASSIGN_SUFFIX="="=31 +SCRIPT=32 +DECLS=33 +USE=34 +PATH=35 +ARRAY=36 +OBJECT=37 +MODE=38 +MEMBER=39 +INCLUDE=40 +METHOD=41 +ARGS=42 +ARG_POS=43 +ARG_KEY=44 +BLOCK=45 +CONDITIONAL=46 +IF=47 +ELSE=48 +LOOP=49 +BREAK=50 +RETURN=51 +ASSIGN=52 +SHORT=53 +UNARY=54 +BINARY=55 +CALL=56 +AS_COPY=57 +LITERAL=58 +SELF=59 +THIS=60 +LOCAL=61 +GLOBAL=62 +BUILD_OBJECT=63 +BUILD_ARRAY=64 +BUILD_ERROR=65 +ABSENT=66 +LITERAL_wheat="wheat"=67 +LITERAL_version="version"=68 +NUMBER=69 +LITERAL_charset="charset"=70 +LITERAL_use="use"=71 +STRING=72 +LITERAL_as="as"=73 +ID=74 +LITERAL_include="include"=75 +LITERAL_if="if"=76 +LITERAL_else="else"=77 +LITERAL_while="while"=78 +LITERAL_break="break"=79 +LITERAL_return="return"=80 +LITERAL_do="do"=81 +LITERAL_self="self"=82 +LITERAL_this="this"=83 +OP_1=84 +OP_2=85 +OP_3=86 +OP_4=87 +OP_5=88 +INSTANCE_ID=89 +GLOBAL_ID=90 Index: ScriptLexer.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- ScriptLexer.cpp 19 Feb 2005 00:34:29 -0000 1.29 +++ ScriptLexer.cpp 18 Mar 2005 07:18:49 -0000 1.30 @@ -30,47 +30,47 @@ void ScriptLexer::initLiterals() { - literals["!!!"] = 21; - literals[","] = 10; - literals["]"] = 7; - literals["break"] = 78; - literals["while"] = 77; - literals["??"] = 17; - literals["||"] = 28; - literals["["] = 6; [...1014 lines suppressed...] -// ALPHA +// null EOF null NULL_TREE_LOOKAHEAD NEWLINE "(" ")" "[" "]" "{" "," "." +// ":" "--" "->" "?" "??" "???" "!" "!!" "!!!" "\\" "\\\\" "null" "true" +// "false" "&&" "||" ":=" "=" SCRIPT DECLS PATH ARRAY OBJECT MODE MEMBER +// INCLUDE METHOD ARGS ARG_POS ARG_KEY BLOCK CONDITIONAL IF ELSE LOOP BREAK +// RETURN ASSIGN SHORT UNARY BINARY CALL AS_COPY LITERAL SELF THIS LOCAL +// GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR ABSENT "wheat" "version" +// NUMBER "charset" "use" STRING "as" ID "include" "if" "else" "while" +// "break" "return" "do" "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID +// GLOBAL_ID WSCHAR NL LINE_COMMENT NEST_COMMENT COMMENT WHITESPACE SEGMENT +// SIMPLE_STRING MULTI_LINE_STRING ESCAPE OP_2_LT OP_2_GT OP_2_NE OP_2_EQ +// OP_2_CMP OP_CHARS OP_CHAR DIGIT ALPHA const antlr::BitSet ScriptLexer::_tokenSet_4(_tokenSet_4_data_,16); const unsigned long ScriptLexer::_tokenSet_5_data_[] = { 0UL, 3489705058UL, 1342177281UL, 1342177280UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; -// USE MODE MEMBER ARG_POS ARG_KEY CONDITIONAL ELSE LOCAL BUILD_OBJECT -// BUILD_ARRAY BUILD_ERROR COMMENT NEST_COMMENT +// DECLS OBJECT MODE ARGS ARG_POS BLOCK IF THIS GLOBAL BUILD_OBJECT BUILD_ARRAY +// WS LINE_COMMENT const antlr::BitSet ScriptLexer::_tokenSet_5(_tokenSet_5_data_,10); Index: ScriptLexerTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexerTokenTypes.hpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ScriptLexerTokenTypes.hpp 23 Dec 2004 00:29:35 -0000 1.23 +++ ScriptLexerTokenTypes.hpp 18 Mar 2005 07:18:49 -0000 1.24 @@ -12,110 +12,113 @@ #endif enum { EOF_ = 1, - LPAREN = 4, - RPAREN = 5, - LBRACK = 6, - RBRACK = 7, - LCURLY = 8, - RCURLY = 9, - COMMA = 10, - PERIOD = 11, - SEMI = 12, - COLON = 13, - DASHDASH = 14, - LINK = 15, - IS_DEFINED = 16, - SHORT_DEFINED = 17, - V_UNKNOWN = 18, - IS_ERROR = 19, - SHORT_ERROR = 20, - V_ERROR = 21, - AS_LINK = 22, - AS_IS = 23, - V_NULL = 24, - V_TRUE = 25, - V_FALSE = 26, - SHORT_AND = 27, - SHORT_OR = 28, - ASSIGN_OP = 29, - ASSIGN_SUFFIX = 30, - SCRIPT = 31, - DECLS = 32, - USE = 33, - PATH = 34, - ARRAY = 35, - OBJECT = 36, - MODE = 37, - MEMBER = 38, - INCLUDE = 39, - METHOD = 40, - ARGS = 41, - ARG_POS = 42, - ARG_KEY = 43, - BLOCK = 44, - CONDITIONAL = 45, - IF = 46, - ELSE = 47, - LOOP = 48, - BREAK = 49, - RETURN = 50, - ASSIGN = 51, - SHORT = 52, - UNARY = 53, - BINARY = 54, - CALL = 55, - AS_COPY = 56, - LITERAL = 57, - SELF = 58, - THIS = 59, - LOCAL = 60, - GLOBAL = 61, - BUILD_OBJECT = 62, - BUILD_ARRAY = 63, - BUILD_ERROR = 64, - ABSENT = 65, - LITERAL_wheat = 66, - LITERAL_version = 67, - NUMBER = 68, - LITERAL_charset = 69, - LITERAL_use = 70, - STRING = 71, - LITERAL_as = 72, - ID = 73, - LITERAL_include = 74, - LITERAL_if = 75, - LITERAL_else = 76, - LITERAL_while = 77, - LITERAL_break = 78, - LITERAL_return = 79, - LITERAL_do = 80, - LITERAL_self = 81, - LITERAL_this = 82, - OP_1 = 83, - OP_2 = 84, - OP_3 = 85, - OP_4 = 86, - OP_5 = 87, - INSTANCE_ID = 88, - GLOBAL_ID = 89, - WS = 90, - NL = 91, - COMMENT = 92, - LINE_COMMENT = 93, - NEST_COMMENT = 94, - SEGMENT = 95, - SIMPLE_STRING = 96, - MULTI_LINE_STRING = 97, - ESCAPE = 98, - OP_2_LT = 99, - OP_2_GT = 100, - OP_2_NE = 101, - OP_2_EQ = 102, - OP_2_CMP = 103, - OP_CHARS = 104, - OP_CHAR = 105, - DIGIT = 106, - ALPHA = 107, + NEWLINE = 4, + LPAREN = 5, + RPAREN = 6, + LBRACK = 7, + RBRACK = 8, + LCURLY = 9, + RCURLY = 10, + COMMA = 11, + PERIOD = 12, + SEMI = 13, + COLON = 14, + DASHDASH = 15, + LINK = 16, + IS_DEFINED = 17, + SHORT_DEFINED = 18, + V_UNKNOWN = 19, + IS_ERROR = 20, + SHORT_ERROR = 21, + V_ERROR = 22, + AS_LINK = 23, + AS_IS = 24, + V_NULL = 25, + V_TRUE = 26, + V_FALSE = 27, + SHORT_AND = 28, + SHORT_OR = 29, + ASSIGN_OP = 30, + ASSIGN_SUFFIX = 31, + SCRIPT = 32, + DECLS = 33, + USE = 34, + PATH = 35, + ARRAY = 36, + OBJECT = 37, + MODE = 38, + MEMBER = 39, + INCLUDE = 40, + METHOD = 41, + ARGS = 42, + ARG_POS = 43, + ARG_KEY = 44, + BLOCK = 45, + CONDITIONAL = 46, + IF = 47, + ELSE = 48, + LOOP = 49, + BREAK = 50, + RETURN = 51, + ASSIGN = 52, + SHORT = 53, + UNARY = 54, + BINARY = 55, + CALL = 56, + AS_COPY = 57, + LITERAL = 58, + SELF = 59, + THIS = 60, + LOCAL = 61, + GLOBAL = 62, + BUILD_OBJECT = 63, + BUILD_ARRAY = 64, + BUILD_ERROR = 65, + ABSENT = 66, + LITERAL_wheat = 67, + LITERAL_version = 68, + NUMBER = 69, + LITERAL_charset = 70, + LITERAL_use = 71, + STRING = 72, + LITERAL_as = 73, + ID = 74, + LITERAL_include = 75, + LITERAL_if = 76, + LITERAL_else = 77, + LITERAL_while = 78, + LITERAL_break = 79, + LITERAL_return = 80, + LITERAL_do = 81, + LITERAL_self = 82, + LITERAL_this = 83, + OP_1 = 84, + OP_2 = 85, + OP_3 = 86, + OP_4 = 87, + OP_5 = 88, + INSTANCE_ID = 89, + GLOBAL_ID = 90, + WSCHAR = 91, + WS = 92, + NL = 93, + LINE_COMMENT = 94, + NEST_COMMENT = 95, + COMMENT = 96, + WHITESPACE = 97, + SEGMENT = 98, + SIMPLE_STRING = 99, + MULTI_LINE_STRING = 100, + ESCAPE = 101, + OP_2_LT = 102, + OP_2_GT = 103, + OP_2_NE = 104, + OP_2_EQ = 105, + OP_2_CMP = 106, + OP_CHARS = 107, + OP_CHAR = 108, + DIGIT = 109, + ALPHA = 110, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptParserTokenTypes.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParserTokenTypes.hpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- ScriptParserTokenTypes.hpp 7 Jan 2005 03:57:30 -0000 1.17 +++ ScriptParserTokenTypes.hpp 18 Mar 2005 07:18:50 -0000 1.18 @@ -12,92 +12,93 @@ #endif enum { EOF_ = 1, - LPAREN = 4, - RPAREN = 5, - LBRACK = 6, - RBRACK = 7, - LCURLY = 8, - RCURLY = 9, - COMMA = 10, - PERIOD = 11, - SEMI = 12, - COLON = 13, - DASHDASH = 14, - LINK = 15, - IS_DEFINED = 16, - SHORT_DEFINED = 17, - V_UNKNOWN = 18, - IS_ERROR = 19, - SHORT_ERROR = 20, - V_ERROR = 21, - AS_LINK = 22, - AS_IS = 23, - V_NULL = 24, - V_TRUE = 25, - V_FALSE = 26, - SHORT_AND = 27, - SHORT_OR = 28, - ASSIGN_OP = 29, - ASSIGN_SUFFIX = 30, - SCRIPT = 31, - DECLS = 32, - USE = 33, - PATH = 34, - ARRAY = 35, - OBJECT = 36, - MODE = 37, - MEMBER = 38, - INCLUDE = 39, - METHOD = 40, - ARGS = 41, - ARG_POS = 42, - ARG_KEY = 43, - BLOCK = 44, - CONDITIONAL = 45, - IF = 46, - ELSE = 47, - LOOP = 48, - BREAK = 49, - RETURN = 50, - ASSIGN = 51, - SHORT = 52, - UNARY = 53, - BINARY = 54, - CALL = 55, - AS_COPY = 56, - LITERAL = 57, - SELF = 58, - THIS = 59, - LOCAL = 60, - GLOBAL = 61, - BUILD_OBJECT = 62, - BUILD_ARRAY = 63, - BUILD_ERROR = 64, - ABSENT = 65, - LITERAL_wheat = 66, - LITERAL_version = 67, - NUMBER = 68, - LITERAL_charset = 69, - LITERAL_use = 70, - STRING = 71, - LITERAL_as = 72, - ID = 73, - LITERAL_include = 74, - LITERAL_if = 75, - LITERAL_else = 76, - LITERAL_while = 77, - LITERAL_break = 78, - LITERAL_return = 79, - LITERAL_do = 80, - LITERAL_self = 81, - LITERAL_this = 82, - OP_1 = 83, - OP_2 = 84, - OP_3 = 85, - OP_4 = 86, - OP_5 = 87, - INSTANCE_ID = 88, - GLOBAL_ID = 89, + NEWLINE = 4, + LPAREN = 5, + RPAREN = 6, + LBRACK = 7, + RBRACK = 8, + LCURLY = 9, + RCURLY = 10, + COMMA = 11, + PERIOD = 12, + SEMI = 13, + COLON = 14, + DASHDASH = 15, + LINK = 16, + IS_DEFINED = 17, + SHORT_DEFINED = 18, + V_UNKNOWN = 19, + IS_ERROR = 20, + SHORT_ERROR = 21, + V_ERROR = 22, + AS_LINK = 23, + AS_IS = 24, + V_NULL = 25, + V_TRUE = 26, + V_FALSE = 27, + SHORT_AND = 28, + SHORT_OR = 29, + ASSIGN_OP = 30, + ASSIGN_SUFFIX = 31, + SCRIPT = 32, + DECLS = 33, + USE = 34, + PATH = 35, + ARRAY = 36, + OBJECT = 37, + MODE = 38, + MEMBER = 39, + INCLUDE = 40, + METHOD = 41, + ARGS = 42, + ARG_POS = 43, + ARG_KEY = 44, + BLOCK = 45, + CONDITIONAL = 46, + IF = 47, + ELSE = 48, + LOOP = 49, + BREAK = 50, + RETURN = 51, + ASSIGN = 52, + SHORT = 53, + UNARY = 54, + BINARY = 55, + CALL = 56, + AS_COPY = 57, + LITERAL = 58, + SELF = 59, + THIS = 60, + LOCAL = 61, + GLOBAL = 62, + BUILD_OBJECT = 63, + BUILD_ARRAY = 64, + BUILD_ERROR = 65, + ABSENT = 66, + LITERAL_wheat = 67, + LITERAL_version = 68, + NUMBER = 69, + LITERAL_charset = 70, + LITERAL_use = 71, + STRING = 72, + LITERAL_as = 73, + ID = 74, + LITERAL_include = 75, + LITERAL_if = 76, + LITERAL_else = 77, + LITERAL_while = 78, + LITERAL_break = 79, + LITERAL_return = 80, + LITERAL_do = 81, + LITERAL_self = 82, + LITERAL_this = 83, + OP_1 = 84, + OP_2 = 85, + OP_3 = 86, + OP_4 = 87, + OP_5 = 88, + INSTANCE_ID = 89, + GLOBAL_ID = 90, NULL_TREE_LOOKAHEAD = 3 }; #ifdef __cplusplus Index: ScriptLexer-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer-test.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ScriptLexer-test.cpp 20 Jan 2005 01:01:42 -0000 1.23 +++ ScriptLexer-test.cpp 18 Mar 2005 07:18:49 -0000 1.24 @@ -96,8 +96,16 @@ }; testTokenRun(HERE, "", eof); testTokenRun(HERE, " ", eof); - testTokenRun(HERE, "\n", eof); - testTokenRun(HERE, " \n \n \r\n\n\n\t\t \n", eof); +} + +TEST(scriptLexer, newline) +{ + static const tokenMatch newline[] = { + { t::NEWLINE, 0 }, + { t::EOF_, 0 } + }; + testTokenRun(HERE, "\n", newline); + testTokenRun(HERE, " \n \n \r\n \r \n\n\t\t \n", newline); } TEST(scriptLexer, punctuation) @@ -119,7 +127,7 @@ { t::EOF_, 0 } }; testTokenRun(HERE, "()[]{}.,;:-- -> ???", punctuation); - testTokenRun(HERE, " ( ) [ ] { }\n. , ; :\n-- -> ???\n", punctuation); + testTokenRun(HERE, " ( ) [ ] { } . , ; : -- -> ??? ", punctuation); } TEST(scriptLexer, reservedWords) @@ -157,6 +165,7 @@ { t::ID, "now" }, { t::ID, "is" }, { t::ID, "ForT2" }, + { t::NEWLINE, 0 }, { t::ID, "XYZ" }, { t::ID, "and-another" }, { t::ID, "72/P" }, @@ -353,20 +362,27 @@ { static const tokenMatch ids[] = { { t::ID, "alpha" }, + { t::NEWLINE, 0 }, { t::ID, "gamma" }, { t::ID, "epsilon" }, + { t::NEWLINE, 0 }, { t::ID, "theta" }, + { t::NEWLINE, 0 }, { t::ID, "iota" }, { t::ID, "pi" }, + { t::NEWLINE, 0 }, { t::ID, "rho" }, + { t::NEWLINE, 0 }, { t::ID, "sigma" }, { t::ID, "tau" }, + { t::NEWLINE, 0 }, { t::ID, "upsilon" }, { t::ID, "phi" }, + { t::NEWLINE, 0 }, { t::ID, "chi" }, { t::ID, "psi" }, { t::ID, "omega" }, - + { t::NEWLINE, 0 }, { t::EOF_, 0 } }; static const char text[] @@ -408,14 +424,20 @@ { static const tokenMatch ids[] = { { t::STRING, "theory" }, + { t::NEWLINE, 0 }, { t::STRING, "" }, + { t::NEWLINE, 0 }, { t::STRING, "\n" }, + { t::NEWLINE, 0 }, { t::STRING, "\r" }, + { t::NEWLINE, 0 }, { t::STRING, "\\" }, + { t::NEWLINE, 0 }, { t::STRING, "\"" }, { t::STRING, "a long string\nla la\n" }, { t::STRING, "another long string\nla la\n" }, { t::STRING, "she said \"foo\"\nhe said \"\"\n\"\", came the reply\n" }, + { t::NEWLINE, 0 }, { t::EOF_, 0 } }; static const char text[] = @@ -424,7 +446,8 @@ " \"\\n\" \n" " \"\\r\" \n" " \"\\\\\" \n" - " \"\\\"\" \n" + " \"\\\"\" \n" // this newline quenched since long strings are + // automatic continuations "\"\"(\n" "a long string\n" @@ -450,6 +473,7 @@ { static const tokenMatch ids[] = { { t::STRING, "e\xc4\xa5o" }, + { t::NEWLINE, 0 }, { t::EOF_, 0 } }; static const char text[] = Index: ScriptParser-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser-test.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- ScriptParser-test.cpp 28 Feb 2005 07:56:00 -0000 1.26 +++ ScriptParser-test.cpp 18 Mar 2005 07:18:49 -0000 1.27 @@ -270,19 +270,19 @@ " (MEMBER ID<y> NUMBER<20>)" "))"; - checkScriptParseTree(HERE, "{x:80 y:20}", twoMemberObject); checkScriptParseTree(HERE, "{x:80; y:20}", twoMemberObject); checkScriptParseTree(HERE, "{x:80; y:20;}", twoMemberObject); checkScriptParseTree(HERE, "{\n x: 80\n y: 20\n}\n", twoMemberObject); - checkScriptParseTree(HERE, "x:80 y:20", twoMemberObject); checkScriptParseTree(HERE, "x:80; y:20", twoMemberObject); checkScriptParseTree(HERE, "x:80; y:20;", twoMemberObject); checkScriptParseTree(HERE, "x: 80\ny: 20\n", twoMemberObject); checkScriptParseTree(HERE, - "{ names: { a: \"a\" b: \"b\" } values: { a: 20; b: 30 } extra: { } }", + "{ names: { a: \"a\"; b: \"b\" }\n" + " values: { a: 20; b: 30 }\n" + " extra: { } }", " (SCRIPT DECLS (OBJECT ABSENT" " (MEMBER ID<names> (OBJECT ABSENT" " (MEMBER ID<a> STRING<a>)" @@ -314,7 +314,7 @@ "))"); checkScriptParseTree(HERE, - "{ -- instance -- x: 80; -- public -- y: 90; -- rwr-r-c- -- z: 100}", + "{ -- instance --; x: 80; -- public --; y: 90; -- rwr-r-c- --; z: 100}", " (SCRIPT DECLS (OBJECT ABSENT" " (MODE ID<instance>)" " (MEMBER ID<x> NUMBER<80>)" Index: ScriptParser.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.hpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- ScriptParser.hpp 7 Jan 2005 03:57:30 -0000 1.19 +++ ScriptParser.hpp 18 Mar 2005 07:18:50 -0000 1.20 @@ -47,6 +47,8 @@ { return ScriptParser::tokenNames; } + public: void end(); + public: void mayEnd(); public: void script(); public: void scriptHeader(); public: void declarations(); @@ -86,14 +88,16 @@ public: void methodArg(); public: void startBlock(); public: void statement(); - public: void returnStatement(); - public: void breakStatement(); public: void expression(); public: void conditionalStatement(); public: void loopStatement(); public: void doStatement(); + public: void returnStatement(); + public: void breakStatement(); public: void ifPart(); - public: void ifElsePart(); + public: void elseIfLeader(); + public: void elseLeader(); + public: void elseIfPart(); public: void elsePart(); public: void reference(); public: void doArgs(); @@ -137,10 +141,10 @@ private: static const char* tokenNames[]; #ifndef NO_STATIC_CONSTS - static const int NUM_TOKENS = 90; + static const int NUM_TOKENS = 91; #else enum { - NUM_TOKENS = 90 + NUM_TOKENS = 91 }; #endif @@ -154,6 +158,14 @@ static const antlr::BitSet _tokenSet_3; static const unsigned long _tokenSet_4_data_[]; static const antlr::BitSet _tokenSet_4; + static const unsigned long _tokenSet_5_data_[]; + static const antlr::BitSet _tokenSet_5; + static const unsigned long _tokenSet_6_data_[]; + static const antlr::BitSet _tokenSet_6; + static const unsigned long _tokenSet_7_data_[]; + static const antlr::BitSet _tokenSet_7; + static const unsigned long _tokenSet_8_data_[]; + static const antlr::BitSet _tokenSet_8; }; #endif /*INC_ScriptParser_hpp_*/ Index: ScriptParser.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.g,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptParser.g 3 Mar 2005 02:41:40 -0000 1.24 +++ ScriptParser.g 18 Mar 2005 07:18:49 -0000 1.25 @@ -35,6 +35,8 @@ } tokens { + NEWLINE; + LPAREN = "("; RPAREN = ")"; LBRACK = "["; @@ -132,12 +134,17 @@ antlr::RefSpanAST getSpanAST() { return returnAST; } } +end!: ( NEWLINE | SEMI ) ( options{greedy=true;}: NEWLINE )*; +mayEnd!: ( options{greedy=true;}: NEWLINE )* ; + script!: - scriptHeader d:declarations v:scriptValue EOF + mayEnd + scriptHeader d:declarations v:scriptValue + EOF { #script = #([SCRIPT], #d, #v); } ; -scriptHeader: ( "wheat" "(" ( scriptParams )? ")" (";")? )? ; +scriptHeader: ( "wheat" "(" ( scriptParams )? ")" end! )? ; scriptParams: scriptParam ( "," scriptParam )* ; scriptParam: "version" ":" NUMBER @@ -149,7 +156,7 @@ { #declarations = #([DECLS], #declarations); } ; declaration!: - "use" s:STRING ( "as" i:id )? (";")? + "use" s:STRING ( "as" i:id )? end { if (#i == antlr::nullAST) #i = #[ABSENT]; #declaration = #([USE], #s, #i); @@ -157,8 +164,8 @@ ; scriptValue: - simpleValue (";"!)? - | compoundValue + simpleValue mayEnd! + | compoundValue mayEnd! |! o:objectContent { #scriptValue = #([OBJECT], [ABSENT], #o); } ; @@ -200,25 +207,31 @@ arrayValue: - "["! compoundProto arrayContent "]"! + "["! compoundProto mayEnd! arrayContent "]"! { #arrayValue = #([ARRAY], #arrayValue); } ; arrayContent: ( arrayElement )* ; arrayElement: - simpleValue (","!)? - | compoundValue (","!)? + simpleValue (","!)? mayEnd! + | compoundValue (","!)? mayEnd! ; objectValue: - "{"! compoundProto objectContent "}"! + "{"! compoundProto mayEnd! objectContent "}"! { #objectValue = #([OBJECT], #objectValue); } ; -objectContent: ( objectElement )* ; +objectContent: + ( + objectElement ( + end! ( objectElement )? + )* + )? ; + objectElement: mode | member | methodMember ; compoundProto: - ":"! ID ":"! + ":"! ID ":"! mayEnd! | empty { ## = #[ABSENT]; } ; @@ -226,12 +239,12 @@ ; member!: - i:id ":" v:memberValue { ## = #([MEMBER], #i, #v); } + i:id ":" mayEnd! v:memberValue { ## = #([MEMBER], #i, #v); } ; memberValue: - simpleValue (";"!)? - | include (";"!)? - | compoundValue // why not allow a semicolon here? + simpleValue + | include + | compoundValue ; include!: @@ -248,7 +261,7 @@ a:methodArgs b:methodBody { #methodValue = #([METHOD], #a, #b); } ; -methodBody: block; +methodBody: mayEnd! block ; methodArgs: @@ -261,59 +274,73 @@ ; -startBlock: block EOF! ; +startBlock: block mayEnd! EOF! ; // this is here for unit tests block: - zs:"{"! ( statement )* ( returnStatement | breakStatement )? ze:"}"! + zs:"{"! mayEnd! + ( statement ( + end! ( statement )? + )* )? + ze:"}"! { ## = #([BLOCK], ##); ##->includeSpan(zs, ze); } ; statement: - expression (";"!) + expression | conditionalStatement | loopStatement | doStatement + | returnStatement + | breakStatement ; conditionalStatement: - ifPart ( options{greedy=true;}: ifElsePart )* ( elsePart )? + ifPart + (( end ( elseIfLeader | elseLeader ))=> end! | empty ) + ( options{greedy=true;}: + elseIfPart + (( end ( elseIfLeader | elseLeader ))=> end! | empty ) + )* + ( elsePart )? { #conditionalStatement = #([CONDITIONAL], #conditionalStatement); } ; ifPart!: - z:"if" "(" e:expression ")" b:block + z:"if" "(" e:expression ")" mayEnd b:block { #ifPart = #([IF], #e, #b); ##->includeSpan(z); } ; -ifElsePart!: - z:"else" "if" "(" e:expression ")" b:block - { #ifElsePart = #([IF], #e, #b); ##->includeSpan(z); } +elseIfLeader: "else" "if" ; +elseIfPart!: + z:elseIfLeader "(" e:expression ")" mayEnd b:block + { #elseIfPart = #([IF], #e, #b); ##->includeSpan(#z); } ; +elseLeader: "else" ; elsePart!: - z:"else" b:block - { #elsePart = #([ELSE], #b); ##->includeSpan(z); } + z:elseLeader mayEnd b:block + { #elsePart = #([ELSE], #b); ##->includeSpan(#z); } ; loopStatement!: - z:"while" "(" e:expression ")" b:block + z:"while" "(" e:expression ")" mayEnd b:block { #loopStatement = #([LOOP], #e, #b); ##->includeSpan(z); } ; breakStatement!: - zs:"break" ze:";" - { #breakStatement = #[BREAK]; ##->includeSpan(zs, ze); } + z:"break" { ## = #[BREAK]; } + { ##->includeSpan(z); } ; returnStatement!: z:"return" ( r:reference { ## = #([RETURN], #r); } | empty { ## = #([RETURN], [ABSENT]); } - ) ";" { ##->includeSpan(z); } + ) { ##->includeSpan(z); } ; doStatement!: - z:"do" i:id m:methodArgs e:expression a:doArgs b:block + z:"do" i:id m:methodArgs e:expression a:doArgs mayEnd b:block { #doStatement = #([CALL], #i, #e, #a, ([ARG_POS], ([LITERAL], ([OBJECT], ([MEMBER], [ID,"do"], ([METHOD], #m, #b)))))); @@ -384,12 +411,14 @@ )* ; -args: ( "("! ( arg ( ","! arg )* )? ")"! )? ; +args: ( "("! ( arg ( ","! arg )* mayEnd! )? ")"! )? ; arg!: - (id ":")=> + mayEnd! + ( (id ":")=> k:id ":" v:reference { #arg = #([ARG_KEY], #k, #v); } | p:reference { #arg = #([ARG_POS], #p); } + ) ; term!: @@ -411,24 +440,23 @@ build: buildObject | buildArray | buildError; buildObject!: - zs:"{" p:buildProto + zs:"{" p:buildProto mayEnd! c:buildObjectContent ze:"}" { ## = #([BUILD_OBJECT], #p, #c); } { ##->includeSpan(zs, ze); } ; buildObjectContent: ( - buildObjectMember ( options{warnWhenFollowAmbig=false;}: - ";"! buildObjectMember + buildObjectMember ( + end! ( buildObjectMember )? )* - (";"!)? - )* ; + )? ; buildObjectMember!: i:ID ":" v:reference { ## = #([MEMBER], #i, #v); } ; buildArray!: - zs:"[" p:buildProto + zs:"[" p:buildProto mayEnd! c:buildArrayContent ze:"]" { ## = #([BUILD_ARRAY], #p, #c); } { ##->includeSpan(zs, ze); } @@ -436,9 +464,9 @@ buildArrayContent: ( reference ( options{warnWhenFollowAmbig=false;}: - ","! reference + ","! mayEnd! reference )* - (","!)? + (","!)? mayEnd! )? ; buildProto: Index: ScriptLexer.hpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexer.hpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ScriptLexer.hpp 19 Feb 2005 00:34:30 -0000 1.14 +++ ScriptLexer.hpp 18 Mar 2005 07:18:49 -0000 1.15 @@ -38,11 +38,14 @@ ScriptLexer(antlr::InputBuffer& ib); ScriptLexer(const antlr::LexerSharedInputState& state); antlr::RefToken nextToken(); - public: void mWS(bool _createToken); - public: void mNL(bool _createToken); - public: void mCOMMENT(bool _createToken); - protected: void mNEST_COMMENT(bool _createToken); + protected: void mWSCHAR(bool _createToken); + protected: void mWS(bool _createToken); + protected: void mNL(bool _createToken); protected: void mLINE_COMMENT(bool _createToken); + protected: void mNEST_COMMENT(bool _createToken); + public: void mCOMMENT(bool _createToken); + public: void mWHITESPACE(bool _createToken); + public: void mNEWLINE(bool _createToken); public: void mNUMBER(bool _createToken); protected: void mDIGIT(bool _createToken); public: void mID(bool _createToken); Index: ScriptLexerTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptLexerTokenTypes.txt,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ScriptLexerTokenTypes.txt 23 Dec 2004 00:29:35 -0000 1.23 +++ ScriptLexerTokenTypes.txt 18 Mar 2005 07:18:49 -0000 1.24 @@ -1,106 +1,109 @@ // $ANTLR 2.7.3 (20041222-1): ScriptLexer.g -> ScriptLexerTokenTypes.txt$ ScriptLexer // output token vocab name -LPAREN="("=4 -RPAREN=")"=5 -LBRACK="["=6 -RBRACK="]"=7 -LCURLY="{"=8 -RCURLY="}"=9 -COMMA=","=10 -PERIOD="."=11 -SEMI=";"=12 -COLON=":"=13 -DASHDASH="--"=14 -LINK="->"=15 -IS_DEFINED="?"=16 -SHORT_DEFINED="??"=17 -V_UNKNOWN="???"=18 -IS_ERROR="!"=19 -SHORT_ERROR="!!"=20 -V_ERROR="!!!"=21 -AS_LINK="\\"=22 -AS_IS="\\\\"=23 -V_NULL="null"=24 -V_TRUE="true"=25 -V_FALSE="false"=26 -SHORT_AND="&&"=27 -SHORT_OR="||"=28 -ASSIGN_OP=":="=29 -ASSIGN_SUFFIX="="=30 -SCRIPT=31 -DECLS=32 -USE=33 -PATH=34 -ARRAY=35 -OBJECT=36 -MODE=37 -MEMBER=38 -INCLUDE=39 -METHOD=40 -ARGS=41 -ARG_POS=42 -ARG_KEY=43 -BLOCK=44 -CONDITIONAL=45 -IF=46 -ELSE=47 -LOOP=48 -BREAK=49 -RETURN=50 -ASSIGN=51 -SHORT=52 -UNARY=53 -BINARY=54 -CALL=55 -AS_COPY=56 -LITERAL=57 -SELF=58 -THIS=59 -LOCAL=60 -GLOBAL=61 -BUILD_OBJECT=62 -BUILD_ARRAY=63 -BUILD_ERROR=64 -ABSENT=65 -LITERAL_wheat="wheat"=66 -LITERAL_version="version"=67 -NUMBER=68 -LITERAL_charset="charset"=69 -LITERAL_use="use"=70 -STRING=71 -LITERAL_as="as"=72 -ID=73 -LITERAL_include="include"=74 -LITERAL_if="if"=75 -LITERAL_else="else"=76 -LITERAL_while="while"=77 -LITERAL_break="break"=78 -LITERAL_return="return"=79 -LITERAL_do="do"=80 -LITERAL_self="self"=81 -LITERAL_this="this"=82 -OP_1=83 -OP_2=84 -OP_3=85 -OP_4=86 -OP_5=87 -INSTANCE_ID=88 -GLOBAL_ID=89 -WS=90 -NL=91 -COMMENT=92 -LINE_COMMENT=93 -NEST_COMMENT=94 -SEGMENT=95 -SIMPLE_STRING=96 -MULTI_LINE_STRING=97 -ESCAPE=98 -OP_2_LT=99 -OP_2_GT=100 -OP_2_NE=101 -OP_2_EQ=102 -OP_2_CMP=103 -OP_CHARS=104 -OP_CHAR=105 -DIGIT=106 -ALPHA=107 +NEWLINE=4 +LPAREN="("=5 +RPAREN=")"=6 +LBRACK="["=7 +RBRACK="]"=8 +LCURLY="{"=9 +RCURLY="}"=10 +COMMA=","=11 +PERIOD="."=12 +SEMI=";"=13 +COLON=":"=14 +DASHDASH="--"=15 +LINK="->"=16 +IS_DEFINED="?"=17 +SHORT_DEFINED="??"=18 +V_UNKNOWN="???"=19 +IS_ERROR="!"=20 +SHORT_ERROR="!!"=21 +V_ERROR="!!!"=22 +AS_LINK="\\"=23 +AS_IS="\\\\"=24 +V_NULL="null"=25 +V_TRUE="true"=26 +V_FALSE="false"=27 +SHORT_AND="&&"=28 +SHORT_OR="||"=29 +ASSIGN_OP=":="=30 +ASSIGN_SUFFIX="="=31 +SCRIPT=32 +DECLS=33 +USE=34 +PATH=35 +ARRAY=36 +OBJECT=37 +MODE=38 +MEMBER=39 +INCLUDE=40 +METHOD=41 +ARGS=42 +ARG_POS=43 +ARG_KEY=44 +BLOCK=45 +CONDITIONAL=46 +IF=47 +ELSE=48 +LOOP=49 +BREAK=50 +RETURN=51 +ASSIGN=52 +SHORT=53 +UNARY=54 +BINARY=55 +CALL=56 +AS_COPY=57 +LITERAL=58 +SELF=59 +THIS=60 +LOCAL=61 +GLOBAL=62 +BUILD_OBJECT=63 +BUILD_ARRAY=64 +BUILD_ERROR=65 +ABSENT=66 +LITERAL_wheat="wheat"=67 +LITERAL_version="version"=68 +NUMBER=69 +LITERAL_charset="charset"=70 +LITERAL_use="use"=71 +STRING=72 +LITERAL_as="as"=73 +ID=74 +LITERAL_include="include"=75 +LITERAL_if="if"=76 +LITERAL_else="else"=77 +LITERAL_while="while"=78 +LITERAL_break="break"=79 +LITERAL_return="return"=80 +LITERAL_do="do"=81 +LITERAL_self="self"=82 +LITERAL_this="this"=83 +OP_1=84 +OP_2=85 +OP_3=86 +OP_4=87 +OP_5=88 +INSTANCE_ID=89 +GLOBAL_ID=90 +WSCHAR=91 +WS=92 +NL=93 +LINE_COMMENT=94 +NEST_COMMENT=95 +COMMENT=96 +WHITESPACE=97 +SEGMENT=98 +SIMPLE_STRING=99 +MULTI_LINE_STRING=100 +ESCAPE=101 +OP_2_LT=102 +OP_2_GT=103 +OP_2_NE=104 +OP_2_EQ=105 +OP_2_CMP=106 +OP_CHARS=107 +OP_CHAR=108 +DIGIT=109 +ALPHA=110 Index: ScriptParserTokenTypes.txt =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParserTokenTypes.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- ScriptParserTokenTypes.txt 7 Jan 2005 03:57:30 -0000 1.16 +++ ScriptParserTokenTypes.txt 18 Mar 2005 07:18:50 -0000 1.17 @@ -1,88 +1,89 @@ // $ANTLR 2.7.3 (20041222-1): ScriptParser.g -> ScriptParserTokenTypes.txt$ ScriptParser // output token vocab name -LPAREN="("=4 -RPAREN=")"=5 -LBRACK="["=6 -RBRACK="]"=7 -LCURLY="{"=8 -RCURLY="}"=9 -COMMA=","=10 -PERIOD="."=11 -SEMI=";"=12 -COLON=":"=13 -DASHDASH="--"=14 -LINK="->"=15 -IS_DEFINED="?"=16 -SHORT_DEFINED="??"=17 -V_UNKNOWN="???"=18 -IS_ERROR="!"=19 -SHORT_ERROR="!!"=20 -V_ERROR="!!!"=21 -AS_LINK="\\"=22 -AS_IS="\\\\"=23 -V_NULL="null"=24 -V_TRUE="true"=25 -V_FALSE="false"=26 -SHORT_AND="&&"=27 -SHORT_OR="||"=28 -ASSIGN_OP=":="=29 -ASSIGN_SUFFIX="="=30 -SCRIPT=31 -DECLS=32 -USE=33 -PATH=34 -ARRAY=35 -OBJECT=36 -MODE=37 -MEMBER=38 -INCLUDE=39 -METHOD=40 -ARGS=41 -ARG_POS=42 -ARG_KEY=43 -BLOCK=44 -CONDITIONAL=45 -IF=46 -ELSE=47 -LOOP=48 -BREAK=49 -RETURN=50 -ASSIGN=51 -SHORT=52 -UNARY=53 -BINARY=54 -CALL=55 -AS_COPY=56 -LITERAL=57 -SELF=58 -THIS=59 -LOCAL=60 -GLOBAL=61 -BUILD_OBJECT=62 -BUILD_ARRAY=63 -BUILD_ERROR=64 -ABSENT=65 -LITERAL_wheat="wheat"=66 -LITERAL_version="version"=67 -NUMBER=68 -LITERAL_charset="charset"=69 -LITERAL_use="use"=70 -STRING=71 -LITERAL_as="as"=72 -ID=73 -LITERAL_include="include"=74 -LITERAL_if="if"=75 -LITERAL_else="else"=76 -LITERAL_while="while"=77 -LITERAL_break="break"=78 -LITERAL_return="return"=79 -LITERAL_do="do"=80 -LITERAL_self="self"=81 -LITERAL_this="this"=82 -OP_1=83 -OP_2=84 -OP_3=85 -OP_4=86 -OP_5=87 -INSTANCE_ID=88 -GLOBAL_ID=89 +NEWLINE=4 +LPAREN="("=5 +RPAREN=")"=6 +LBRACK="["=7 +RBRACK="]"=8 +LCURLY="{"=9 +RCURLY="}"=10 +COMMA=","=11 +PERIOD="."=12 +SEMI=";"=13 +COLON=":"=14 +DASHDASH="--"=15 +LINK="->"=16 +IS_DEFINED="?"=17 +SHORT_DEFINED="??"=18 +V_UNKNOWN="???"=19 +IS_ERROR="!"=20 +SHORT_ERROR="!!"=21 +V_ERROR="!!!"=22 +AS_LINK="\\"=23 +AS_IS="\\\\"=24 +V_NULL="null"=25 +V_TRUE="true"=26 +V_FALSE="false"=27 +SHORT_AND="&&"=28 +SHORT_OR="||"=29 +ASSIGN_OP=":="=30 +ASSIGN_SUFFIX="="=31 +SCRIPT=32 +DECLS=33 +USE=34 +PATH=35 +ARRAY=36 +OBJECT=37 +MODE=38 +MEMBER=39 +INCLUDE=40 +METHOD=41 +ARGS=42 +ARG_POS=43 +ARG_KEY=44 +BLOCK=45 +CONDITIONAL=46 +IF=47 +ELSE=48 +LOOP=49 +BREAK=50 +RETURN=51 +ASSIGN=52 +SHORT=53 +UNARY=54 +BINARY=55 +CALL=56 +AS_COPY=57 +LITERAL=58 +SELF=59 +THIS=60 +LOCAL=61 +GLOBAL=62 +BUILD_OBJECT=63 +BUILD_ARRAY=64 +BUILD_ERROR=65 +ABSENT=66 +LITERAL_wheat="wheat"=67 +LITERAL_version="version"=68 +NUMBER=69 +LITERAL_charset="charset"=70 +LITERAL_use="use"=71 +STRING=72 +LITERAL_as="as"=73 +ID=74 +LITERAL_include="include"=75 +LITERAL_if="if"=76 +LITERAL_else="else"=77 +LITERAL_while="while"=78 +LITERAL_break="break"=79 +LITERAL_return="return"=80 +LITERAL_do="do"=81 +LITERAL_self="self"=82 +LITERAL_this="this"=83 +OP_1=84 +OP_2=85 +OP_3=86 +OP_4=87 +OP_5=88 +INSTANCE_ID=89 +GLOBAL_ID=90 Index: ScriptParser.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptParser.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ScriptParser.cpp 3 Mar 2005 02:41:40 -0000 1.24 +++ ScriptParser.cpp 18 Mar 2005 07:18:49 -0000 1.25 @@ -28,6 +28,80 @@ { } +void ScriptParser::end() { + returnAST = antlr::RefSpanAST(antlr::nullAST); + antlr::ASTPair currentAST; + antlr::RefSpanAST end_AST = antlr::RefSpanAST(antlr::nullAST); + + { + switch ( LA(1)) { + case NEWLINE: [...2079 lines suppressed...] // GLOBAL_ID -const antlr::BitSet ScriptParser::_tokenSet_3(_tokenSet_3_data_,8); -const unsigned long ScriptParser::_tokenSet_4_data_[] = { 1073737712UL, 0UL, 66978448UL, 0UL, 0UL, 0UL, 0UL, 0UL }; -// "(" ")" "[" "]" "{" "}" "," "." ":" "--" "->" "?" "??" "???" "!" "!!" -// "!!!" "\\" "\\\\" "null" "true" "false" "&&" "||" ":=" NUMBER STRING -// ID "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID GLOBAL_ID -const antlr::BitSet ScriptParser::_tokenSet_4(_tokenSet_4_data_,8); +const antlr::BitSet ScriptParser::_tokenSet_6(_tokenSet_6_data_,8); +const unsigned long ScriptParser::_tokenSet_7_data_[] = { 2147475440UL, 0UL, 133956896UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +// NEWLINE "(" ")" "[" "]" "{" "}" "," "." ":" "--" "->" "?" "??" "???" +// "!" "!!" "!!!" "\\" "\\\\" "null" "true" "false" "&&" "||" ":=" NUMBER +// STRING ID "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID GLOBAL_ID +const antlr::BitSet ScriptParser::_tokenSet_7(_tokenSet_7_data_,8); +const unsigned long ScriptParser::_tokenSet_8_data_[] = { 264864432UL, 0UL, 133956896UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +// NEWLINE "(" "[" "{" "--" "->" "???" "!!!" "\\" "\\\\" "null" "true" +// "false" NUMBER STRING ID "self" "this" OP_1 OP_2 OP_3 OP_4 OP_5 INSTANCE_ID +// GLOBAL_ID +const antlr::BitSet ScriptParser::_tokenSet_8(_tokenSet_8_data_,8); Index: ScriptCompiler.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- ScriptCompiler.cpp 3 Mar 2005 02:41:40 -0000 1.32 +++ ScriptCompiler.cpp 18 Mar 2005 07:18:48 -0000 1.33 @@ -1985,6 +1985,7 @@ "EOF", "<2>", "NULL_TREE_LOOKAHEAD", + "NEWLINE", "\"(\"", "\")\"", "\"[\"", @@ -2074,10 +2075,10 @@ 0 }; -const unsigned long ScriptCompiler::_tokenSet_0_data_[] = { 117735424UL, 280UL, 144UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptCompiler::_tokenSet_0_data_[] = { 235470848UL, 560UL, 288UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // "->" "???" "null" "true" "false" ARRAY OBJECT METHOD NUMBER STRING const antlr::BitSet ScriptCompiler::_tokenSet_0(_tokenSet_0_data_,8); -const unsigned long ScriptCompiler::_tokenSet_1_data_[] = { 589824UL, 4277739520UL, 1UL, 0UL, 0UL, 0UL, 0UL, 0UL }; +const unsigned long ScriptCompiler::_tokenSet_1_data_[] = { 1179648UL, 4260511744UL, 3UL, 0UL, 0UL, 0UL, 0UL, 0UL }; // "?" "!" CONDITIONAL LOOP ASSIGN SHORT UNARY BINARY CALL LITERAL SELF // THIS LOCAL GLOBAL BUILD_OBJECT BUILD_ARRAY BUILD_ERROR const antlr::BitSet ScriptCompiler::_tokenSet_1(_tokenSet_1_data_,8); |
From: Mark L. <mar...@us...> - 2005-03-18 07:19:00
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30557/root/applications Modified Files: blog.ws farm.ws Log Message: newlines as statement and member terminator (see http://www.wheatfarm.org/wiki/NewlineAsTerminator for notes) Index: blog.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/blog.ws,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- blog.ws 18 Mar 2005 04:46:41 -0000 1.29 +++ blog.ws 18 Mar 2005 07:18:50 -0000 1.30 @@ -80,9 +80,9 @@ new(blog, dest): { return {:self: blog: \blog; dest: \\dest; }; } submit(request: r, post-args: args): { if (~ args.account.is-empty() - && ~ args.password.is-empty() - && #blog.users.has(args.account) - && #blog.users[args.account].password == args.password) + ... && ~ args.password.is-empty() + ... && #blog.users.has(args.account) + ... && #blog.users[args.account].password == args.password) { r.session("logged-in") := true; r.session("account") := args.account; @@ -124,18 +124,18 @@ template(): { return \#blog.templates.'editadd.html'; } submit(post-args: args, request: r): { if (args.title.is-empty() - || args.author.is-empty() - || args.story.is-empty() - || args.title == #default-title - || args.author == #default-author - || args.story == #default-story) + ... || args.author.is-empty() + ... || args.story.is-empty() + ... || args.title == #default-title + ... || args.author == #default-author + ... || args.story == #default-story) { #args := args; return #render(request: r); } newEntry := { `` :'../blog-entry': -- relative paths don't work - :'/applications/blog/blog-entry': + ... :'/applications/blog/blog-entry': title: args.title; author: args.author; full-story: args.story; @@ -320,8 +320,8 @@ tt-date(): { date := #subject.date; return date.year.as-string() - + "-" + date.month.as-string() - + "-" + date.day.as-string(); + ... + "-" + date.month.as-string() + ... + "-" + date.day.as-string(); } tt-full-story(): { html := $/library/writeup/formatter.convert(#subject.full-story); @@ -368,7 +368,7 @@ tt-edit-link(): { #attribute("href", $/library/render.url-path(\#subject, request: \#request) - + "edit" + ... + "edit" ); } } @@ -387,7 +387,7 @@ } submit(request: r, post-args: args): { if (args.title.is-empty() - || args.story.is-empty()) + ... || args.story.is-empty()) { return #render(request: r); } @@ -539,7 +539,8 @@ blog := \#sample-blog-1; request := #sample-request; `` Not \#sample-request. Why not? page := blog.rss.render(request: \request); - #assert-equals(""( + #assert-equals( +""( <channel> <title>Test Blog</title> <link>http://example.com/blog</link> @@ -557,8 +558,8 @@ <description>Crowned on Christmas Day</description> </item> </channel> -"") - , page); +""), + page); } test-base(): { @@ -578,8 +579,8 @@ #assert("template is string", blog.template.is-string()); page := blog.render(); #assert-equals("<story>Tennis Court Oath</story>\n" + - "<story>National Assembly</story>\n" + - "<story>William is Crowned</story>\n\n", + ... "<story>National Assembly</story>\n" + + ... "<story>William is Crowned</story>\n\n", page); } @@ -665,7 +666,7 @@ } check-page-universals(page, is-main-page: is-main-page, - logged-in: logged-in): { + ... logged-in: logged-in): { $/library/render/tests.assert-rendered-cleanly(\self, page); #assert-contains("base href=\"http://example.com/files/blog.d/r/\" />", page); @@ -755,9 +756,9 @@ index-page := blog.render(); #assert-equals( "<story>City-Wide Garage Sale</story>\n" + - "<story>Tennis Court Oath</story>\n" + - "<story>National Assembly</story>\n" + - "<story>William is Crowned</story>\n\n", + ... "<story>Tennis Court Oath</story>\n" + + ... "<story>National Assembly</story>\n" + + ... "<story>William is Crowned</story>\n\n", \index-page); } Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- farm.ws 18 Mar 2005 04:46:41 -0000 1.57 +++ farm.ws 18 Mar 2005 07:18:50 -0000 1.58 @@ -174,8 +174,8 @@ } tt-is-failure(): { - return - #subject.compilation-state.matches("compile-error-location"); + return #subject.compilation-state.matches( + "compile-error-location"); } tt-failure-code(): { @@ -270,7 +270,7 @@ t := args.target.as-path; (r := $/applications/farm/instantiator - .instantiate( + ... .instantiate( prototype: \p.dereference, target: t, create-intermediates: true))!; @@ -351,7 +351,7 @@ create-intermediates: true); } container.dereference().member(t.last-segment(), create: true) := - p.new(); + ... p.new(); if (p.understands("initialize")) { t.dereference().initialize(); } @@ -548,12 +548,14 @@ check-good-listing(expander): { #assert-equals( - "a-number: 42\n" + - "a-string: \"the answer\"\n" + - "\n" + - "tests: {:'/library/wheatunit/test-case':\n" + - " test-a-number(): { #assert-equals(\"bob\", \"bob\"); }\n" + - "}\n", +""( +a-number: 42 +a-string: "the answer" + +tests: {:'/library/wheatunit/test-case': + test-a-number(): { #assert-equals("bob", "bob"); } +} +""), expander.tt-before-error()); #assert-equals(false, expander.tt-is-failure()); #assert-equals(false, expander.tt-after-error()); @@ -566,7 +568,7 @@ subject: \#sample, request: \#sample-request); #assert-equals( "a-number: 142\n" + - "a-string(", + ... "a-string(", expander.tt-before-error()); #assert-equals(true, expander.tt-is-failure()); #assert-equals(": \"the answer\")", expander.tt-failure-code()); @@ -581,7 +583,7 @@ subject: \#sample, request: \#sample-request); #assert-equals( "a-number: 242\n" + - "a-string(): { return", + ... "a-string(): { return", expander.tt-before-error()); #assert-equals(true, expander.tt-is-failure()); #assert-equals(" bob; }", expander.tt-failure-code()); @@ -611,10 +613,11 @@ request: #sample-request ); #assert-contains( - "a-string(<span class=\"failure\"><a name=\"error\" />: " + - ""the answer")</span>\n" + - "<span class=\"errorMessage\">unexpected token: :</span>\n" + - "</pre>\n", +""( +a-string(<span class="failure"><a name="error" />: "the answer")</span> +<span class="errorMessage">unexpected token: :</span> +</pre> +""), html); $/library/render/tests.assert-rendered-cleanly(\self, html); } @@ -627,15 +630,15 @@ #assert-equals( "parses: \"x<y || &foo > 5 || ãã¥ã¼ã¹\"\n" + - "error: \"<&>\" ", + ... "error: \"<&>\" ", expander.tt-before-error()); #assert-equals(true, expander.tt-is-failure()); #assert-equals("bad \"<&>\"", expander.tt-failure-code()); #assert-equals( "\nnext-line: \"don't <stop> " + - "æ¥æ¬èª\"\n", + ... "æ¥æ¬èª\"\n", expander.tt-after-error()); - #assert-equals("unexpected token: bad", expander.tt-compile-message()); + #assert-equals("expecting EOF, found 'bad'", expander.tt-compile-message()); `` Pushing it through the template too is kind of redundant, `` but does provide a sanity check that we have replace-text @@ -646,7 +649,7 @@ ); $/library/render/tests.assert-rendered-cleanly(\self, html); #assert-contains("\nparses: "x<y || " + - "&foo > 5 || ãã¥ã¼ã¹"\n", + ... "&foo > 5 || ãã¥ã¼ã¹"\n", html); } |
From: Mark L. <mar...@us...> - 2005-03-18 07:19:00
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30557/wheat Modified Files: baselibrary-test.cpp Log Message: newlines as statement and member terminator (see http://www.wheatfarm.org/wiki/NewlineAsTerminator for notes) Index: baselibrary-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/baselibrary-test.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- baselibrary-test.cpp 21 Feb 2005 07:40:45 -0000 1.38 +++ baselibrary-test.cpp 18 Mar 2005 07:18:51 -0000 1.39 @@ -77,11 +77,11 @@ TestUtil::SetupCompile s("/test/baselibrary"); s.compile( - "elevator: {" - " up(): { return \"going up\"; }" - " floor: 5" - " down(): { return \"going down\"; }" - "}" + "elevator: {\n" + " up(): { return \"going up\"; }\n" + " floor: 5\n" + " down(): { return \"going down\"; }\n" + "}\n" ); Thread t; |
From: Mark L. <mar...@us...> - 2005-03-18 07:18:59
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30557/root/library Modified Files: base.ws render.ws wheatunit.ws Log Message: newlines as statement and member terminator (see http://www.wheatfarm.org/wiki/NewlineAsTerminator for notes) Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- wheatunit.ws 18 Mar 2005 04:46:43 -0000 1.40 +++ wheatunit.ws 18 Mar 2005 07:18:50 -0000 1.41 @@ -167,7 +167,7 @@ } #assert("expected " + expected.debug-string() + - " was " + actual.debug-string(), + ... " was " + actual.debug-string(), expected == actual); } assert-not-equals(undesirable, actual): { @@ -177,38 +177,38 @@ assert-starts-with(expectedSubstring, actualContainer): { #assert("expected " + expectedSubstring + - " as start of " + actualContainer, + ... " as start of " + actualContainer, actualContainer.starts-with(expectedSubstring)); } assert-ends-with(expectedSubstring, actualContainer): { #assert("expected " + expectedSubstring + - " as end of " + actualContainer, + ... " as end of " + actualContainer, actualContainer.ends-with(expectedSubstring)); } assert-contains(expectedSubstring, actualContainer): { #assert("expected " + expectedSubstring + - " as substring of " + actualContainer, + ... " as substring of " + actualContainer, actualContainer.contains(expectedSubstring)); } assert-not-contains(unexpectedSubstring, actualContainer): { #assert("didn't expect " + unexpectedSubstring + - " as substring of " + actualContainer, + ... " as substring of " + actualContainer, ~actualContainer.contains(unexpectedSubstring)); } assert-error(expectedReasonPath, actualValue): { if (??? == actualValue - && (expectedReasonPath! - || ~ (expectedReasonPath.is-string()))) + ... && (expectedReasonPath! + ... || ~ (expectedReasonPath.is-string()))) { #failure := "missing second argument to assert-error"; } else if (actualValue!) { #assert("expected " + expectedReasonPath + " error got " + - actualValue!.reason-string(), + ... actualValue!.reason-string(), expectedReasonPath == actualValue!.reason-string()); } else { #assert("expected " + expectedReasonPath + " error got none", @@ -511,11 +511,11 @@ #assert-equals(false, result.passed); #assert-equals( "<pre>warp-drive-failed\n" + - file + ":" + (l + 6) + ": generated by bar()\n" + - file + ":" + (l + 3) + ": returned to foo()\n" + - file + ":" + l + ": returned to test-error()\n" + - "</pre>" - , result.failure-info()); + ... file + ":" + (l + 6) + ": generated by bar()\n" + + ... file + ":" + (l + 3) + ": returned to foo()\n" + + ... file + ":" + l + ": returned to test-error()\n" + + ... "</pre>" + ... , result.failure-info()); } @@ -562,7 +562,7 @@ -- public -- test-debug-info(): { #assert-fail("expected foo was " + - "object(/library/wheatunit/tests/coordinate)[2/0]", + ... "object(/library/wheatunit/tests/coordinate)[2/0]", \#debug-info); } Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- render.ws 18 Mar 2005 04:46:43 -0000 1.31 +++ render.ws 18 Mar 2005 07:18:50 -0000 1.32 @@ -214,9 +214,9 @@ #key-counter += 1; #key := - #request.entropy.as-string() - + $/system/config/startup/library/render/site-entropy - + #key-counter.as-string(); + ... #request.entropy.as-string() + ... + $/system/config/startup/library/render/site-entropy + ... + #key-counter.as-string(); #key := #key.md5(); } s := \$/library/render/request/session-manager/sessions; @@ -274,7 +274,7 @@ if (dest!) { return dest; } `` Why is this "request: r" and not "request: \r"? Oversight? return #url-path-of-path(dest.absolute-path - !! !!!("library/render/exception/no-object-to-map"), request: r); + ... !! !!!("library/render/exception/no-object-to-map"), request: r); } url-of-path(path, request: r): { @@ -456,11 +456,13 @@ #assert-equals("<x><y><z>Hello</z></y></x>", #expand( template: "<x><y tt:name='rep-one'><z tt:name='hello' /></y></x>", expander: \e)); - #assert-equals("<x><y><z>Hello</z></y>" + - "<y><z>Hello</z></y>" + - "<y><z>Goodbye</z></y></x>", #expand( - template: "<x><y tt:name='rep-three'><z tt:name='hello' /></y></x>", - expander: \e)); + #assert-equals( + "<x><y><z>Hello</z></y>" + + ... "<y><z>Hello</z></y>" + + ... "<y><z>Goodbye</z></y></x>", + #expand( + template: "<x><y tt:name='rep-three'><z tt:name='hello' /></y></x>", + expander: \e)); } -- private -- @@ -534,11 +536,12 @@ template := "<x tt:name='replace' href='' />"; out := $/library/render.expand(template: template, expander: \e); #assert-contains(#errstr, out); - #assert-contains(""( + #assert-contains( +""( While expanding tag replace (fetching value) bad replace -"") - , out); +""), + out); #assert-contains("bad replace", out); } @@ -554,19 +557,20 @@ out := $/library/render.expand(template: template, expander: \e); #assert-contains(#errstr, out); #assert-contains("While expanding tag prefix\n" + - "system/vm/exception/not-found(as-string)\n" ``( + - "as-string sent to /proc" ``) - , out); + ... "system/vm/exception/not-found(as-string)\n" ``( + + ... "as-string sent to /proc" ``) + ... , out); template := "<x tt:name='replace' href='' />"; out := $/library/render.expand(template: template, expander: \e); #assert-contains(#errstr, out); - #assert-contains(""( + #assert-contains( +""( While expanding tag replace system/vm/exception/not-found(as-string) -"") - , out); +""), + out); } not-a-string-expander: {:'/library/render/expander': @@ -611,7 +615,7 @@ #assert-equals("<x><y>amy avacado</y><y>bob broccoli</y></x>", r); t := "<x><y tt:name='null-case'><tt:span name='alpha'>deb</tt:span>" + - " <tt:span name='beta'>daikon</tt:span></y></x>"; + ... " <tt:span name='beta'>daikon</tt:span></y></x>"; out := $/library/render.expand(template: t, subject: s, expander: \e); #assert-equals("<x></x>", out); } @@ -681,8 +685,8 @@ <body><ul> <li>organic apple</li><li>mexican banana</li> </ul></body> -"") - , r); +""), + r); } @@ -801,8 +805,8 @@ <li>Tootsie Pop</li> </ul> </body> -"") - , #composite.render()); +""), + #composite.render()); } test-file-render(): { Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- base.ws 18 Mar 2005 04:46:42 -0000 1.52 +++ base.ws 18 Mar 2005 07:18:50 -0000 1.53 @@ -674,7 +674,7 @@ test-regex-groups(): { matcher := "line ([0-9]*) column ([0-9]*)" - .match-against("error at line 523 column 4: silly"); + ... .match-against("error at line 523 column 4: silly"); #assert-equals("/library/base/matcher", matcher.prototype()); #assert-equals(3, matcher.groups.array-size()); #assert-equals("line 523 column 4", matcher.groups[0]); @@ -917,7 +917,7 @@ test-enum(): { (empty := $/library/base/enum.new())!; #assert-error("system/base/exception/enum/bad-value" + - "(/library/base/indefiniteness)", + ... "(/library/base/indefiniteness)", empty); (bad-value := $/library/base/tests/model.new("bad"))!; @@ -929,7 +929,7 @@ `` constructors :-(). no-value := { :'/library/base/enum': values: ["one", "two"] }; #assert-error("system/base/exception/enum/bad-value" + - "(/library/base/indefiniteness)", + ... "(/library/base/indefiniteness)", no-value.value); } |
From: Mark L. <mar...@us...> - 2005-03-18 07:18:59
|
Update of /cvsroot/wheat/r1/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30557/server Modified Files: mod_file-test.cpp Log Message: newlines as statement and member terminator (see http://www.wheatfarm.org/wiki/NewlineAsTerminator for notes) Index: mod_file-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/server/mod_file-test.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- mod_file-test.cpp 21 Feb 2005 07:40:43 -0000 1.14 +++ mod_file-test.cpp 18 Mar 2005 07:18:50 -0000 1.15 @@ -130,7 +130,7 @@ " type: \"ok\";\n" " mime-type: \"text/plain\";\n" " content: \"fruit=\" + args.fruit + \n" - " \"; tool=\" + args.tool + \"\\n\";\n" + " ... \"; tool=\" + args.tool + \"\\n\";\n" " };\n" " }\n" "}\n" |
From: Jim K. <ki...@us...> - 2005-03-18 04:46:52
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28791/root/library Modified Files: base.ws render.ws wheatunit.ws Log Message: Add #start-repeat which cleans up some kludgy code (and also might fix some code which is buggy in corner cases, not as sure about that part). Take a few steps towards making the farm relocatable (now can pass unit tests with target of /applications/farm-dev - doesn't yet run correctly from /applications/farm-dev ). Fix bug in asDouble (etc), whereby it was mishandling the case in which as-number (etc) exist but return something other than the desired type (such as ???). Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- wheatunit.ws 17 Mar 2005 07:08:13 -0000 1.39 +++ wheatunit.ws 18 Mar 2005 04:46:43 -0000 1.40 @@ -304,26 +304,22 @@ } -- public -- tt-results(): { - any := false; + #start-repeat(); i := 0; while (i < #subject.size) { #expand(subject: #subject[i], expander: \#result-expander); - any := true; i += 1; } - if (~any) { #skip; } } tt-failures(): { - any := false; + #start-repeat(); i := 0; while (i < #subject.size) { if (~#subject[i].passed) { #expand(subject: #subject[i], expander: \#result-expander); - any := true; } i += 1; } - if (~any) { #skip; } } tt-all-passed(): { #keep(#tt-fails == 0); } tt-some-failed(): { #keep(#tt-fails > 0); } Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- render.ws 11 Mar 2005 00:35:57 -0000 1.30 +++ render.ws 18 Mar 2005 04:46:43 -0000 1.31 @@ -117,6 +117,15 @@ #instruction.contexts.add(e); } + + start-repeat(): { + if (#instruction?) { + return !!!("/library/render/exception/already-have-instruction"); + } + #instruction := {:'/library/render/instructions/repeat': + contexts: [ ]; + }; + } get-instruction(name): { #instruction := ???; @@ -601,14 +610,10 @@ r := $/library/render.expand(template: t, subject: s, expander: \e); #assert-equals("<x><y>amy avacado</y><y>bob broccoli</y></x>", r); - `` Right now the expander has to explicitly call #skip for the - `` zero case, but just call #expand for the >0 case. - `` Should there be a #start-repeat the expander can call - `` before they loop calling #expand? See wheatunit/blog for examples. t := "<x><y tt:name='null-case'><tt:span name='alpha'>deb</tt:span>" + " <tt:span name='beta'>daikon</tt:span></y></x>"; out := $/library/render.expand(template: t, subject: s, expander: \e); - #assert-equals("<x><y>deb daikon</y></x>", out); + #assert-equals("<x></x>", out); } -- private -- @@ -652,6 +657,7 @@ } tt-null-case(): { + #start-repeat(); if (false) { #expand(); } Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- base.ws 13 Mar 2005 02:30:46 -0000 1.51 +++ base.ws 18 Mar 2005 04:46:42 -0000 1.52 @@ -70,6 +70,7 @@ tt-name(): { return #subject.name !! "/"; } tt-prototype(): { return #subject.prototype.as-string; } tt-member(): { + #start-repeat(); m := #subject.members; i := 0; while (i < m.size) { @@ -268,6 +269,7 @@ -- public -- trail-expander: {:'/library/render/expander': tt-segment(): { + #start-repeat(); p := #subject; prefixes := [ ]; while (~p.is-error) { @@ -810,6 +812,16 @@ #assert-equals(false, "eÄ¥oÅanÄo".ends-with("Ä")); } + test-string-as-number(): { + `` Not sure where we stand with unary operators + `` #assert-equals(-42, "-42".as-number); + + ``#assert-equals(5, " 5 ".as-number); + + #assert-equals(7, "7".as-number); + #assert-equals(???, "foo".as-number); + } + test-string-as-string(): { #assert("is string", "foo".is-string); @@ -834,6 +846,11 @@ return !!!("warp-failure"); } + test-conversion-fails(): { + #assert-error("system/base/exception/failed-conversion(as-number)", + 5 + "foo"); + } + -- public -- test-object-debug-info(): { #assert-equals("object(/library/base/array)[0/3]", [ "a", true, 41 ].debug-info()); @@ -1102,4 +1119,5 @@ #generate-error-inner(false); #generate-error-inner(true); `` line x + 14 } + } |
From: Jim K. <ki...@us...> - 2005-03-18 04:46:52
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28791/wheat Modified Files: reference.cpp Log Message: Add #start-repeat which cleans up some kludgy code (and also might fix some code which is buggy in corner cases, not as sure about that part). Take a few steps towards making the farm relocatable (now can pass unit tests with target of /applications/farm-dev - doesn't yet run correctly from /applications/farm-dev ). Fix bug in asDouble (etc), whereby it was mishandling the case in which as-number (etc) exist but return something other than the desired type (such as ???). Index: reference.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/reference.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- reference.cpp 7 Mar 2005 21:39:31 -0000 1.29 +++ reference.cpp 18 Mar 2005 04:46:43 -0000 1.30 @@ -354,6 +354,12 @@ op = PrimitiveAccess::targetObject(value); if ((op.*testFn)()) return (op.*fetchFn)(); + + /* Should probably also pass value as an argument, if we + can figure out the whole values-as-strings question + (or are arguments HTML, or renderable?) */ + throw Exception("system/base/exception/failed-conversion") + << convertMessage; } Local reasonArray(f); |
From: Jim K. <ki...@us...> - 2005-03-18 04:46:50
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28791/root/applications Modified Files: blog.ws farm.ws Log Message: Add #start-repeat which cleans up some kludgy code (and also might fix some code which is buggy in corner cases, not as sure about that part). Take a few steps towards making the farm relocatable (now can pass unit tests with target of /applications/farm-dev - doesn't yet run correctly from /applications/farm-dev ). Fix bug in asDouble (etc), whereby it was mishandling the case in which as-number (etc) exist but return something other than the desired type (such as ???). Index: blog.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/blog.ws,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- blog.ws 5 Mar 2005 03:08:23 -0000 1.28 +++ blog.ws 18 Mar 2005 04:46:41 -0000 1.29 @@ -23,15 +23,11 @@ tt-entry(): { entries := \#subject.entries; n := entries.size; - if (0 == n) { - #skip(); - } - else { - i := n - 1; - while (i >= 0) { - #expand(subject: \entries[i]); - i -= 1; - } + #start-repeat(); + i := n - 1; + while (i >= 0) { + #expand(subject: \entries[i]); + i -= 1; } } Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- farm.ws 13 Mar 2005 02:30:45 -0000 1.56 +++ farm.ws 18 Mar 2005 04:46:41 -0000 1.57 @@ -362,6 +362,7 @@ template(): { return \#root.'instantiator.html'; } expander: {:'/applications/farm/farm-expander': tt-entry(): { + #start-repeat(); entries := #subject.get-protos; i := 0; while (i < entries.size) { @@ -651,12 +652,16 @@ test-project-page(): { #sample.init(\#sample.source-text-good); - #assert-equals("/render/applications", $/library/render.url-path( - \$/applications, request: \#sample-request)); + + ``( Still not fully relocatable, but at least we can put it + elsewhere in /applications (or anything that has a mapping + in sample-request ``) + sample-url := $/library/render.url-path( + \#sample, request: \#sample-request); + result := #sample.render(request: #sample-request); #assert-contains( - "href=\"/render/applications/farm" + - "/tests/sample/built-module\">view</a>", result); + "href=\"" + sample-url + "/built-module\">view</a>", result); } test-project-has-instantiables(): { @@ -771,9 +776,9 @@ test-compilation-good(): { #sample.init(\#sample.source-text-good); - #assert-equals("/applications/farm/tests/sample/source-text-good", + #assert-equals(#sample.absolute-path + "source-text-good", #sample.source.as-string()); - #assert-equals("/applications/farm/tests/sample/built-module", + #assert-equals(#sample.absolute-path + "built-module", #sample.target.as-string()); #assert-equals(true, #sample.compile().success); |
From: Jim K. <ki...@us...> - 2005-03-17 07:08:25
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13507/root/library Modified Files: wheatunit.ws Log Message: Consolidate trace rendering (as string or as html) into result object. Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- wheatunit.ws 16 Mar 2005 07:11:03 -0000 1.38 +++ wheatunit.ws 17 Mar 2005 07:08:13 -0000 1.39 @@ -12,9 +12,16 @@ result: { -- instance -- name: ??? + + `` called from testutil.cpp passed: ??? + + `` called from testutil.cpp skipped: ??? - failure-message: ??? + + failure-error: ??? + nonerror-message: ??? + -- public -- new(method-name, instance, return-value): { if (return-value!) { @@ -22,44 +29,97 @@ name: method-name passed: false; skipped: false; - failure-message: $/library/wheatunit/test-case. - message-from-error(return-value!); + failure-error: return-value!; }; - } else { + } + else if (instance.failure-error?) { return { :'/library/wheatunit/result': name: method-name; - passed: instance.is-pass; + passed: false; skipped: instance.skipped; - failure-message: instance.failure-message + failure-error: instance.failure-error + }; + } + else if (instance.failure.is-string) { + return { :'/library/wheatunit/result': + name: method-name; + passed: false; + skipped: instance.skipped; + nonerror-message: instance.failure + }; + } + else if (instance.anypass) { + return { :'/library/wheatunit/result': + name: method-name; + passed: true; + skipped: instance.skipped; + }; + } + else { + return { :'/library/wheatunit/result': + name: method-name; + passed: false; + skipped: instance.skipped; + nonerror-message: "no assertions" }; } } + -- public -- + `` called from testutil.cpp + failure-message(): { + if (#failure-error?) { + return #message-from-error(#failure-error); + } + else { + return #nonerror-message; + } + } + + -- private -- + message-from-error(error-value): { + message := error-value.reason-string(); + trace := error-value.trace-string(); + if ( ~ trace.is-empty() ) { + message += "\n"; + message += trace; + } + return message; + } + + -- private -- failure-info-template: "<pre tt:name=\"failure-message\">failed</pre>" expander: { :'/library/render/expander': tt-failure-message(): { return #subject.failure-message; } } + -- public -- failure-info(): { - return $/library/render.expand(template: #failure-info-template, - subject: self); + if (#failure-message?) { + return $/library/render.expand(template: #failure-info-template, + subject: self); + } + else { + return ???; + } } } test-case: { -- instance -- failure: ??? + failure-error: ??? anypass: false skipped: false -- public -- assert(message, condition): { - if (#failure?) { + if (#has-failed()) { return; } if (condition!) { - #failure := #message-from-error(condition!); + #failure-error := condition!; return; } @@ -67,7 +127,7 @@ #anypass := true; } else if (condition? ){ if (message!) { - #failure := #message-from-error(message!); + #failure-error := message!; } else if (message?) { #failure := message; } else { @@ -92,17 +152,17 @@ } assert-equals(expected, actual): { - if (#failure?) { + if (#has-failed()) { return; } if (actual!) { - #failure := #message-from-error(actual!); + #failure-error := actual!; return; } if (expected!) { - #failure := #message-from-error(expected!); + #failure-error := expected!; return; } @@ -157,17 +217,6 @@ } -- public -- - message-from-error(error-value): { - message := error-value.reason-string(); - trace := error-value.trace-string(); - if ( ~ trace.is-empty() ) { - message += "\n"; - message += trace; - } - return message; - } - - -- public -- run-all(): { methods := #methods(); @@ -184,6 +233,7 @@ return results; } + `` called from testutil.cpp run-one(method): { instance := #new(); (return-value := instance.invoke(method))!; @@ -192,24 +242,11 @@ -- private -- new(): { return {:self:}; } - is-pass(): { - if (#failure.is-string) { - return false; - } - if (#anypass) { - return true; - } - return false; - } - failure-message(): { - if (#failure.is-string) { - return #failure; - } - if (#anypass) { - return ???; - } - return "no assertions"; + + has-failed(): { + return #failure? || #failure-error?; } + } run-all-for(package): { @@ -327,19 +364,19 @@ #assert-equals("test-pass", result.name); #assert-equals(true, result.passed); #assert-equals(false, result.skipped); - #assert-equals(???, result.failure-message); + #assert-equals(???, result.failure-info); result := basics.run-one("test-fail"); #assert-equals("test-fail", result.name); #assert-equals(false, result.passed); #assert-equals(false, result.skipped); - #assert-equals("expected 7 was 5", result.failure-message); + #assert-equals("<pre>expected 7 was 5</pre>", result.failure-info); result := basics.run-one("test-skip"); #assert-equals("test-skip", result.name); #assert-equals(false, result.passed); #assert-equals(true, result.skipped); - #assert-equals("#skip called", result.failure-message); + #assert-equals("<pre>#skip called</pre>", result.failure-info); } -- private -- @@ -415,7 +452,7 @@ #assert-equals("test-pass", results[1].name); #assert-equals(true, results[1].passed); - #assert-equals(???, results[1].failure-message); + #assert-equals(???, results[1].failure-info); } -- private -- @@ -451,7 +488,7 @@ assert-pass(testcase): { result := #one-result(\\testcase); - #assert-equals(???, result.failure-message); + #assert-equals(???, result.failure-info); return #assert-equals(true, result.passed); } @@ -470,11 +507,11 @@ } -- public -- - test-trace-string-in-error(): { + test-render-trace(): { result := #one-result(\#trace-string-in-error); -``( + file := "/root/library/wheatunit.ws"; - l := 501; + l := result.failure-error.trace-event(2).start-line; #assert-equals(false, result.passed); #assert-equals( "<pre>warp-drive-failed\n" + @@ -483,9 +520,12 @@ file + ":" + l + ": returned to test-error()\n" + "</pre>" , result.failure-info()); -``) - #assert-equals(false, result.passed); + } + + test-trace-as-string-for-testutil-cpp(): { + result := #one-result(\#trace-string-in-error); + lines := result.failure-message.split("\n"); #assert-equals(5, lines.size); |
From: Jim K. <ki...@us...> - 2005-03-16 07:11:27
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26890 Modified Files: wheatunit.ws Log Message: Start the process of moving the rendering of a failure result into the result object. Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- wheatunit.ws 14 Mar 2005 05:46:32 -0000 1.37 +++ wheatunit.ws 16 Mar 2005 07:11:03 -0000 1.38 @@ -34,6 +34,17 @@ }; } } + + failure-info-template: "<pre tt:name=\"failure-message\">failed</pre>" + + expander: { :'/library/render/expander': + tt-failure-message(): { return #subject.failure-message; } + } + + failure-info(): { + return $/library/render.expand(template: #failure-info-template, + subject: self); + } } test-case: { @@ -237,7 +248,9 @@ <table> <tr tt:name="failures"> <td class="failure" tt:name="name">test-sample-failure</td> - <td><pre tt:name="failure-message">expected something got nothing</pre></td> + <td tt:name="failure-info"> + <pre>expected something got nothing</pre> + </td> </tr> </table> </div> @@ -250,7 +263,7 @@ tt-passed(): { return #subject.passed; } tt-failed(): { return ~#subject.passed; } tt-name(): { return #subject.name; } - tt-failure-message(): { return #subject.failure-message; } + tt-failure-info(): { #replace-content(#subject.failure-info); } } -- public -- tt-results(): { @@ -459,8 +472,20 @@ -- public -- test-trace-string-in-error(): { result := #one-result(\#trace-string-in-error); +``( + file := "/root/library/wheatunit.ws"; + l := 501; #assert-equals(false, result.passed); + #assert-equals( + "<pre>warp-drive-failed\n" + + file + ":" + (l + 6) + ": generated by bar()\n" + + file + ":" + (l + 3) + ": returned to foo()\n" + + file + ":" + l + ": returned to test-error()\n" + + "</pre>" + , result.failure-info()); +``) + #assert-equals(false, result.passed); lines := result.failure-message.split("\n"); #assert-equals(5, lines.size); @@ -475,13 +500,13 @@ trace-string-in-error: { :'/library/wheatunit/test-case': -- public -- test-error(): { - #assert-equals(5, #foo()); + return #assert-equals(5, #foo()); `` line l } foo(): { - return #bar(); + return #bar(); `` line l + 3 } bar(): { - return !!!("warp-drive-failed"); + return !!!("warp-drive-failed"); `` line l + 6 } } |