|
@@ -28,54 +28,6 @@ var ChainedContext = ContextHierarchy.Node;
|
|
ChainedContext.extend = Class.extend;
|
|
ChainedContext.extend = Class.extend;
|
|
ChainedContext.prototype.init = ContextHierarchy.Node;
|
|
ChainedContext.prototype.init = ContextHierarchy.Node;
|
|
|
|
|
|
-exports.Integer = ChainedContext.extend({
|
|
|
|
- init: function IntegerContext(context){
|
|
|
|
- ChainedContext.prototype.init.call(this, context);
|
|
|
|
- },
|
|
|
|
- endParse: function(){
|
|
|
|
- var n = this.attributes.int;
|
|
|
|
- this.parent().handleConst(basicTypes.integer, Code.makeIntConst(n), n.toString());
|
|
|
|
- }
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
-exports.Real = ChainedContext.extend({
|
|
|
|
- init: function RealContext(context){
|
|
|
|
- ChainedContext.prototype.init.call(this, context);
|
|
|
|
- },
|
|
|
|
- endParse: function(){
|
|
|
|
- var n = this.attributes.real;
|
|
|
|
- this.parent().handleConst(basicTypes.real, Code.makeRealConst(n), n.toString());
|
|
|
|
- }
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
-function escapeString(s){
|
|
|
|
- var escapeChars = {"\\": "\\\\",
|
|
|
|
- "\"": "\\\"",
|
|
|
|
- "\n": "\\n",
|
|
|
|
- "\r": "\\r",
|
|
|
|
- "\t": "\\t",
|
|
|
|
- "\b": "\\b",
|
|
|
|
- "\f": "\\f"
|
|
|
|
- };
|
|
|
|
- var result = "\"";
|
|
|
|
- for(var i = 0; i < s.length; ++i){
|
|
|
|
- var c = s[i];
|
|
|
|
- var escape = escapeChars[c];
|
|
|
|
- result += escape !== undefined ? escape : c;
|
|
|
|
- }
|
|
|
|
- return result + "\"";
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-exports.String = ChainedContext.extend({
|
|
|
|
- init: function StringContext(context){
|
|
|
|
- ChainedContext.prototype.init.call(this, context);
|
|
|
|
- },
|
|
|
|
- endParse: function(){
|
|
|
|
- var s = this.attributes.str;
|
|
|
|
- this.parent().handleConst(new Type.String(s), Code.makeStringConst(s), escapeString(s));
|
|
|
|
- }
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
exports.BaseType = ChainedContext.extend({
|
|
exports.BaseType = ChainedContext.extend({
|
|
init: function BaseTypeContext(context){
|
|
init: function BaseTypeContext(context){
|
|
ChainedContext.prototype.init.call(this, context);
|
|
ChainedContext.prototype.init.call(this, context);
|
|
@@ -1072,12 +1024,6 @@ exports.SetElement = ChainedContext.extend({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-function constValueCode(value){
|
|
|
|
- if (typeof value == "string")
|
|
|
|
- return escapeString(value);
|
|
|
|
- return value.toString();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
exports.SimpleExpression = ChainedContext.extend({
|
|
exports.SimpleExpression = ChainedContext.extend({
|
|
init: function SimpleExpressionContext(context){
|
|
init: function SimpleExpressionContext(context){
|
|
ChainedContext.prototype.init.call(this, context);
|
|
ChainedContext.prototype.init.call(this, context);
|