MCPcopy Create free account
hub / github.com/Moli-X/Resources / YAML

Function YAML

Script/Parser.js:3142–3564  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3140*/
3141
3142function YAML() {
3143 var errors = [],
3144 reference_blocks = [],
3145 processing_time = 0,
3146 regex =
3147 {
3148 "regLevel" : new RegExp("^([\\s\\-]+)"),
3149 "invalidLine" : new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),
3150 "dashesString" : new RegExp("^\\s*\\\"([^\\\"]*)\\\"\\s*$"),
3151 "quotesString" : new RegExp("^\\s*\\\'([^\\\']*)\\\'\\s*$"),
3152 "float" : new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),
3153 "integer" : new RegExp("^[+-]?[0-9]+$"),
3154 "array" : new RegExp("\\[\\s*(.*)\\s*\\]"),
3155 "map" : new RegExp("\\{\\s*(.*)\\s*\\}"),
3156 "key_value" : new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)", "i"),
3157 "single_key_value" : new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$", "i"),
3158 "key" : new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?", "i"),
3159 "item" : new RegExp("^-\\s+"),
3160 "trim" : new RegExp("^\\s+|\\s+$"),
3161 "comment" : new RegExp("([^\\\'\\\"#]+([\\\'\\\"][^\\\'\\\"]*[\\\'\\\"])*)*(#.*)?")
3162 };
3163
3164 /**
3165 * @class A block of lines of a given level.
3166 * @param {int} lvl The block's level.
3167 * @private
3168 */
3169 function Block(lvl) {
3170 return {
3171 /* The block's parent */
3172 parent: null,
3173 /* Number of children */
3174 length: 0,
3175 /* Block's level */
3176 level: lvl,
3177 /* Lines of code to process */
3178 lines: [],
3179 /* Blocks with greater level */
3180 children : [],
3181 /* Add a block to the children collection */
3182 addChild : function(obj) {
3183 this.children.push(obj);
3184 obj.parent = this;
3185 ++this.length;
3186 }
3187 };
3188 }
3189
3190 // function to create an XMLHttpClient in a cross-browser manner
3191
3192 function fromURL(src, ondone) {
3193 var client = createXMLHTTPRequest();
3194 client.onreadystatechange = function() {
3195 if (this.readyState == 4 || this.status == 200) {
3196 var txt = this.responseText;
3197 ondone(YAML.eval0(txt));
3198 }
3199 };

Callers

nothing calls this directly

Calls 3

preProcessFunction · 0.85
parserFunction · 0.85
semanticAnalysisFunction · 0.85

Tested by

no test coverage detected