How to use Parser method in wpt

Best JavaScript code snippet using wpt

sax.js

Source:sax.js Github

copy

Full Screen

1;(function (sax) { // wrapper for non-node envs2 sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }3 sax.SAXParser = SAXParser4 sax.SAXStream = SAXStream5 sax.createStream = createStream6 // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.7 // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),8 // since that's the earliest that a buffer overrun could occur. This way, checks are9 // as rare as required, but as often as necessary to ensure never crossing this bound.10 // Furthermore, buffers are only tested at most once per write(), so passing a very11 // large string into write() might have undesirable effects, but this is manageable by12 // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme13 // edge case, result in creating at most one complete copy of the string passed in.14 // Set to Infinity to have unlimited buffers.15 sax.MAX_BUFFER_LENGTH = 64 * 102416 var buffers = [17 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',18 'procInstName', 'procInstBody', 'entity', 'attribName',19 'attribValue', 'cdata', 'script'20 ]21 sax.EVENTS = [22 'text',23 'processinginstruction',24 'sgmldeclaration',25 'doctype',26 'comment',27 'opentagstart',28 'attribute',29 'opentag',30 'closetag',31 'opencdata',32 'cdata',33 'closecdata',34 'error',35 'end',36 'ready',37 'script',38 'opennamespace',39 'closenamespace'40 ]41 function SAXParser (strict, opt) {42 if (!(this instanceof SAXParser)) {43 return new SAXParser(strict, opt)44 }45 var parser = this46 clearBuffers(parser)47 parser.q = parser.c = ''48 parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH49 parser.opt = opt || {}50 parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags51 parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'52 parser.tags = []53 parser.closed = parser.closedRoot = parser.sawRoot = false54 parser.tag = parser.error = null55 parser.strict = !!strict56 parser.noscript = !!(strict || parser.opt.noscript)57 parser.state = S.BEGIN58 parser.strictEntities = parser.opt.strictEntities59 parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)60 parser.attribList = []61 // namespaces form a prototype chain.62 // it always points at the current tag,63 // which protos to its parent tag.64 if (parser.opt.xmlns) {65 parser.ns = Object.create(rootNS)66 }67 // mostly just for error reporting68 parser.trackPosition = parser.opt.position !== false69 if (parser.trackPosition) {70 parser.position = parser.line = parser.column = 071 }72 emit(parser, 'onready')73 }74 if (!Object.create) {75 Object.create = function (o) {76 function F () {}77 F.prototype = o78 var newf = new F()79 return newf80 }81 }82 if (!Object.keys) {83 Object.keys = function (o) {84 var a = []85 for (var i in o) if (o.hasOwnProperty(i)) a.push(i)86 return a87 }88 }89 function checkBufferLength (parser) {90 var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)91 var maxActual = 092 for (var i = 0, l = buffers.length; i < l; i++) {93 var len = parser[buffers[i]].length94 if (len > maxAllowed) {95 // Text/cdata nodes can get big, and since they're buffered,96 // we can get here under normal conditions.97 // Avoid issues by emitting the text node now,98 // so at least it won't get any bigger.99 switch (buffers[i]) {100 case 'textNode':101 closeText(parser)102 break103 case 'cdata':104 emitNode(parser, 'oncdata', parser.cdata)105 parser.cdata = ''106 break107 case 'script':108 emitNode(parser, 'onscript', parser.script)109 parser.script = ''110 break111 default:112 error(parser, 'Max buffer length exceeded: ' + buffers[i])113 }114 }115 maxActual = Math.max(maxActual, len)116 }117 // schedule the next check for the earliest possible buffer overrun.118 var m = sax.MAX_BUFFER_LENGTH - maxActual119 parser.bufferCheckPosition = m + parser.position120 }121 function clearBuffers (parser) {122 for (var i = 0, l = buffers.length; i < l; i++) {123 parser[buffers[i]] = ''124 }125 }126 function flushBuffers (parser) {127 closeText(parser)128 if (parser.cdata !== '') {129 emitNode(parser, 'oncdata', parser.cdata)130 parser.cdata = ''131 }132 if (parser.script !== '') {133 emitNode(parser, 'onscript', parser.script)134 parser.script = ''135 }136 }137 SAXParser.prototype = {138 end: function () { end(this) },139 write: write,140 resume: function () { this.error = null; return this },141 close: function () { return this.write(null) },142 flush: function () { flushBuffers(this) }143 }144 var Stream145 try {146 Stream = require('stream').Stream147 } catch (ex) {148 Stream = function () {}149 }150 var streamWraps = sax.EVENTS.filter(function (ev) {151 return ev !== 'error' && ev !== 'end'152 })153 function createStream (strict, opt) {154 return new SAXStream(strict, opt)155 }156 function SAXStream (strict, opt) {157 if (!(this instanceof SAXStream)) {158 return new SAXStream(strict, opt)159 }160 Stream.apply(this)161 this._parser = new SAXParser(strict, opt)162 this.writable = true163 this.readable = true164 var me = this165 this._parser.onend = function () {166 me.emit('end')167 }168 this._parser.onerror = function (er) {169 me.emit('error', er)170 // if didn't throw, then means error was handled.171 // go ahead and clear error, so we can write again.172 me._parser.error = null173 }174 this._decoder = null175 streamWraps.forEach(function (ev) {...

Full Screen

Full Screen

WikiParser.js

Source:WikiParser.js Github

copy

Full Screen

1// Copyright 2014 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4/**5 * @constructor6 * @param {string} wikiMarkupText7 */8WebInspector.WikiParser = function(wikiMarkupText)9{10 var text = wikiMarkupText;11 this._tokenizer = new WebInspector.WikiParser.Tokenizer(text);12 this._document = this._parse();13}14/**15 * @constructor16 */17WebInspector.WikiParser.Section = function()18{19 /** @type {string} */20 this.title;21 /** @type {?WebInspector.WikiParser.Values} */22 this.values;23 /** @type {?WebInspector.WikiParser.ArticleElement} */24 this.singleValue;25}26/**27 * @constructor28 */29WebInspector.WikiParser.Field = function()30{31 /** @type {string} */32 this.name;33 /** @type {?WebInspector.WikiParser.FieldValue} */34 this.value;35}36/** @typedef {(?WebInspector.WikiParser.ArticleElement|!Array.<!WebInspector.WikiParser.Section>)} */37WebInspector.WikiParser.FieldValue;38/** @typedef {?Object.<string, !WebInspector.WikiParser.FieldValue>} */39WebInspector.WikiParser.Values;40/** @typedef {(?WebInspector.WikiParser.Value|?WebInspector.WikiParser.ArticleElement)} */41WebInspector.WikiParser.Value;42/**43 * @package44 * @enum {string}45 */46WebInspector.WikiParser.TokenType = {47 Text: "Text",48 OpeningTable: "OpeningTable",49 ClosingTable: "ClosingTable",50 RowSeparator: "RowSeparator",51 CellSeparator: "CellSeparator",52 NameSeparator: "NameSeparator",53 OpeningCurlyBrackets: "OpeningCurlyBrackets",54 ClosingCurlyBrackets: "ClosingCurlyBrackets",55 Exclamation: "Exclamation",56 OpeningSquareBrackets: "OpeningSquareBrackets",57 ClosingBrackets: "ClosingBrackets",58 EqualSign: "EqualSign",59 EqualSignInCurlyBrackets: "EqualSignInCurlyBrackets",60 VerticalLine: "VerticalLine",61 DoubleQuotes: "DoubleQuotes",62 TripleQuotes: "TripleQuotes",63 OpeningCodeTag: "OpeningCodeTag",64 ClosingCodeTag: "ClosingCodeTag",65 Bullet: "Bullet",66 LineEnd: "LineEnd",67 CodeBlock: "CodeBlock",68 Space: "Space"69}70/**71 * @constructor72 * @param {string} result73 * @param {!WebInspector.WikiParser.TokenType} type74 */75WebInspector.WikiParser.Token = function(result, type)76{77 this._value = result;78 this._type = type;79}80WebInspector.WikiParser.Token.prototype = {81 /**82 * @return {string}83 */84 value: function()85 {86 return this._value;87 },88 /**89 * @return {!WebInspector.WikiParser.TokenType}90 */91 type: function()92 {93 return this._type;94 }95}96/**97 * @constructor98 * @param {string} str99 */100WebInspector.WikiParser.Tokenizer = function(str)101{102 this._text = str;103 this._oldText = str;104 this._token = this._internalNextToken();105 this._mode = WebInspector.WikiParser.Tokenizer.Mode.Normal;106}107/**108 * @package109 * @enum {string}110 */111WebInspector.WikiParser.Tokenizer.Mode = {112 Normal: "Normal",113 Link: "Link"114}115WebInspector.WikiParser.Tokenizer.prototype = {116 /**117 * @param {!WebInspector.WikiParser.Tokenizer.Mode} mode118 */119 _setMode: function(mode)120 {121 this._mode = mode;122 this._text = this._oldText;123 this._token = this._internalNextToken();124 },125 /**126 * @return {boolean}127 */128 _isNormalMode: function()129 {130 return this._mode === WebInspector.WikiParser.Tokenizer.Mode.Normal;131 },132 /**133 * @return {!WebInspector.WikiParser.Token}134 */135 peekToken: function()136 {137 return this._token;138 },139 /**140 * @return {!WebInspector.WikiParser.Token}141 */142 nextToken: function()143 {144 var token = this._token;145 this._oldText = this._text;146 this._token = this._internalNextToken();147 return token;148 },149 /**150 * @return {!WebInspector.WikiParser.Token}151 */152 _internalNextToken: function()153 {154 if (WebInspector.WikiParser.newLineWithSpace.test(this._text)) {155 var result = WebInspector.WikiParser.newLineWithSpace.exec(this._text);156 var begin = result.index;157 var end = this._text.length;158 var lineEnd = WebInspector.WikiParser.newLineWithoutSpace.exec(this._text);159 if (lineEnd)160 end = lineEnd.index;161 var token = this._text.substring(begin, end).replace(/\n /g, "\n").replace(/{{=}}/g, "=");162 this._text = this._text.substring(end + 1);163 return new WebInspector.WikiParser.Token(token, WebInspector.WikiParser.TokenType.CodeBlock);164 }165 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length; ++i) {166 if (this._isNormalMode() && WebInspector.WikiParser._tokenDescriptors[i].type === WebInspector.WikiParser.TokenType.Space)167 continue;168 var result = WebInspector.WikiParser._tokenDescriptors[i].regex.exec(this._text);169 if (result) {170 this._text = this._text.substring(result.index + result[0].length);171 return new WebInspector.WikiParser.Token(result[0], WebInspector.WikiParser._tokenDescriptors[i].type);172 }173 }174 for (var lastIndex = 0; lastIndex < this._text.length; ++lastIndex) {175 var testString = this._text.substring(lastIndex);176 for (var i = 0; i < WebInspector.WikiParser._tokenDescriptors.length; ++i) {177 if (this._isNormalMode() && WebInspector.WikiParser._tokenDescriptors[i].type === WebInspector.WikiParser.TokenType.Space)178 continue;179 if (WebInspector.WikiParser._tokenDescriptors[i].regex.test(testString)) {180 var token = this._text.substring(0, lastIndex);181 this._text = this._text.substring(lastIndex);182 return new WebInspector.WikiParser.Token(token, WebInspector.WikiParser.TokenType.Text);183 }184 }185 }186 var token = this._text;187 this._text = "";188 return new WebInspector.WikiParser.Token(token, WebInspector.WikiParser.TokenType.Text);189 },190 /**191 * @return {!WebInspector.WikiParser.Tokenizer}192 */193 clone: function()194 {195 var tokenizer = new WebInspector.WikiParser.Tokenizer(this._text);196 tokenizer._token = this._token;197 tokenizer._text = this._text;198 tokenizer._oldText = this._oldText;199 tokenizer._mode = this._mode;200 return tokenizer;201 },202 /**203 * @return {boolean}204 */205 hasMoreTokens: function()206 {207 return !!this._text.length;208 }209}210WebInspector.WikiParser.openingTable = /^\n{{{!}}/;211WebInspector.WikiParser.closingTable = /^\n{{!}}}/;212WebInspector.WikiParser.cellSeparator = /^\n{{!}}/;213WebInspector.WikiParser.rowSeparator = /^\n{{!}}-/;214WebInspector.WikiParser.nameSeparator = /^\n!/;215WebInspector.WikiParser.exclamation = /^{{!}}/;216WebInspector.WikiParser.openingCurlyBrackets = /^{{/;217WebInspector.WikiParser.equalSign = /^=/;218WebInspector.WikiParser.equalSignInCurlyBrackets = /^{{=}}/;219WebInspector.WikiParser.closingCurlyBrackets = /^\s*}}/;220WebInspector.WikiParser.oneOpeningSquareBracket = /^\n*\[/;221WebInspector.WikiParser.twoOpeningSquareBrackets = /^\n*\[\[/;222WebInspector.WikiParser.oneClosingBracket = /^\n*\]/;223WebInspector.WikiParser.twoClosingBrackets = /^\n*\]\]/;224WebInspector.WikiParser.tripleQuotes = /^\n*'''/;225WebInspector.WikiParser.doubleQuotes = /^\n*''/;226WebInspector.WikiParser.openingCodeTag = /^<code\s*>/;227WebInspector.WikiParser.closingCodeTag = /^<\/code\s*>/;228WebInspector.WikiParser.closingBullet = /^\*/;229WebInspector.WikiParser.lineEnd = /^\n/;230WebInspector.WikiParser.verticalLine = /^\n*\|/;231WebInspector.WikiParser.newLineWithSpace = /^\n [^ ]/;232WebInspector.WikiParser.newLineWithoutSpace = /\n[^ ]/;233WebInspector.WikiParser.space = /^ /;234/**235 * @constructor236 * @param {!RegExp} regex237 * @param {!WebInspector.WikiParser.TokenType} type238 */239WebInspector.WikiParser.TokenDescriptor = function(regex, type)240{241 this.regex = regex;242 this.type = type;243}244WebInspector.WikiParser._tokenDescriptors = [245 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingTable, WebInspector.WikiParser.TokenType.ClosingTable),246 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingTable, WebInspector.WikiParser.TokenType.OpeningTable),247 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.rowSeparator, WebInspector.WikiParser.TokenType.RowSeparator),248 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.cellSeparator, WebInspector.WikiParser.TokenType.CellSeparator),249 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.nameSeparator, WebInspector.WikiParser.TokenType.NameSeparator),250 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.exclamation, WebInspector.WikiParser.TokenType.Exclamation),251 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.equalSignInCurlyBrackets, WebInspector.WikiParser.TokenType.EqualSignInCurlyBrackets),252 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.equalSign, WebInspector.WikiParser.TokenType.EqualSign),253 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingTable, WebInspector.WikiParser.TokenType.OpeningTable),254 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingCurlyBrackets, WebInspector.WikiParser.TokenType.OpeningCurlyBrackets),255 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.verticalLine, WebInspector.WikiParser.TokenType.VerticalLine),256 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingCurlyBrackets, WebInspector.WikiParser.TokenType.ClosingCurlyBrackets),257 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoOpeningSquareBrackets, WebInspector.WikiParser.TokenType.OpeningSquareBrackets),258 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.twoClosingBrackets, WebInspector.WikiParser.TokenType.ClosingBrackets),259 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneOpeningSquareBracket, WebInspector.WikiParser.TokenType.OpeningSquareBrackets),260 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.oneClosingBracket, WebInspector.WikiParser.TokenType.ClosingBrackets),261 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.newLineWithSpace, WebInspector.WikiParser.TokenType.CodeBlock),262 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.tripleQuotes, WebInspector.WikiParser.TokenType.TripleQuotes),263 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.doubleQuotes, WebInspector.WikiParser.TokenType.DoubleQuotes),264 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.openingCodeTag, WebInspector.WikiParser.TokenType.OpeningCodeTag),265 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingCodeTag, WebInspector.WikiParser.TokenType.ClosingCodeTag),266 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.closingBullet, WebInspector.WikiParser.TokenType.Bullet),267 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.lineEnd, WebInspector.WikiParser.TokenType.LineEnd),268 new WebInspector.WikiParser.TokenDescriptor(WebInspector.WikiParser.space, WebInspector.WikiParser.TokenType.Space)269]270WebInspector.WikiParser.prototype = {271 /**272 * @return {!Object}273 */274 document: function()275 {276 return this._document;277 },278 /**279 * @return {?WebInspector.WikiParser.TokenType}280 */281 _secondTokenType: function()282 {283 var tokenizer = this._tokenizer.clone();284 if (!tokenizer.hasMoreTokens())285 return null;286 tokenizer.nextToken();287 if (!tokenizer.hasMoreTokens())288 return null;289 return tokenizer.nextToken().type();290 },291 /**292 * @return {!Object.<string, ?WebInspector.WikiParser.Value>}293 */294 _parse: function()295 {296 var obj = {};297 while (this._tokenizer.hasMoreTokens()) {298 var section = this._parseSection();299 if (section.title)300 obj[section.title] = section.singleValue || section.values;301 }302 return obj;303 },304 /**305 * @return {!WebInspector.WikiParser.Section}306 */307 _parseSection: function()308 {309 var section = new WebInspector.WikiParser.Section();310 if (!this._tokenizer.hasMoreTokens() || this._tokenizer.nextToken().type() !== WebInspector.WikiParser.TokenType.OpeningCurlyBrackets)311 return section;312 var title = this._deleteTrailingSpaces(this._parseSectionTitle());313 if (!title.length)314 return section;315 section.title = title;316 if (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.ClosingCurlyBrackets) {317 this._tokenizer.nextToken();318 return section;319 }320 var secondTokenType = this._secondTokenType();321 if (!secondTokenType || secondTokenType !== WebInspector.WikiParser.TokenType.EqualSign) {322 section.singleValue = this._parseMarkupText();323 } else {324 section.values = {};325 while (this._tokenizer.hasMoreTokens()) {326 var field = this._parseField();327 section.values[field.name] = field.value;328 if (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.ClosingCurlyBrackets) {329 this._tokenizer.nextToken();330 return section;331 }332 }333 }334 var token = this._tokenizer.nextToken();335 if (token.type() !== WebInspector.WikiParser.TokenType.ClosingCurlyBrackets)336 throw new Error("Two closing curly brackets expected; found " + token.value());337 return section;338 },339 /**340 * @return {!WebInspector.WikiParser.Field}341 */342 _parseField: function()343 {344 var field = new WebInspector.WikiParser.Field();345 field.name = this._parseFieldName();346 var token = this._tokenizer.peekToken();347 switch (token.type()) {348 case WebInspector.WikiParser.TokenType.OpeningCurlyBrackets:349 field.value = this._parseArray();350 break;351 case WebInspector.WikiParser.TokenType.LineEnd:352 this._tokenizer.nextToken();353 break;354 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:355 return field;356 default:357 if (field.name.toUpperCase() === "CODE")358 field.value = this._parseExampleCode();359 else360 field.value = this._parseMarkupText();361 }362 return field;363 },364 /**365 * @return {!Array.<!WebInspector.WikiParser.Section>}366 */367 _parseArray: function()368 {369 var array = [];370 while (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.OpeningCurlyBrackets)371 array.push(this._parseSection());372 if (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.VerticalLine)373 this._tokenizer.nextToken();374 return array;375 },376 /**377 * @return {string}378 */379 _parseSectionTitle: function()380 {381 var title = "";382 while (this._tokenizer.hasMoreTokens()) {383 var token = this._tokenizer.peekToken();384 switch (token.type()) {385 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:386 return title;387 case WebInspector.WikiParser.TokenType.VerticalLine:388 this._tokenizer.nextToken();389 return title;390 case WebInspector.WikiParser.TokenType.Text:391 title += this._tokenizer.nextToken().value();392 break;393 default:394 throw new Error("Title could not be parsed. Unexpected token " + token.value());395 }396 }397 return title;398 },399 /**400 * @return {string}401 */402 _parseFieldName: function()403 {404 var name = "";405 while (this._tokenizer.hasMoreTokens()) {406 var token = this._tokenizer.peekToken();407 switch (token.type()) {408 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:409 return name;410 case WebInspector.WikiParser.TokenType.EqualSign:411 this._tokenizer.nextToken();412 return name;413 case WebInspector.WikiParser.TokenType.VerticalLine:414 case WebInspector.WikiParser.TokenType.Text:415 name += this._tokenizer.nextToken().value();416 break;417 default:418 throw new Error("Name could not be parsed. Unexpected token " + token.value());419 }420 }421 return name;422 },423 /**424 * @return {!WebInspector.WikiParser.Block}425 */426 _parseExampleCode: function()427 {428 var code = "";429 /**430 * @return {!WebInspector.WikiParser.Block}431 */432 function wrapIntoArticleElement()433 {434 var plainText = new WebInspector.WikiParser.PlainText(code);435 var block = new WebInspector.WikiParser.Block([plainText])436 var articleElement = new WebInspector.WikiParser.Block([block]);437 return articleElement;438 }439 while (this._tokenizer.hasMoreTokens()) {440 var token = this._tokenizer.peekToken();441 switch (token.type()) {442 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:443 return wrapIntoArticleElement();444 case WebInspector.WikiParser.TokenType.VerticalLine:445 this._tokenizer.nextToken();446 return wrapIntoArticleElement();447 case WebInspector.WikiParser.TokenType.Exclamation:448 this._tokenizer.nextToken();449 code += "|";450 break;451 case WebInspector.WikiParser.TokenType.EqualSignInCurlyBrackets:452 this._tokenizer.nextToken();453 code += "=";454 break;455 default:456 this._tokenizer.nextToken();457 code += token.value();458 }459 }460 return wrapIntoArticleElement();461 },462 /**463 * @return {?WebInspector.WikiParser.Block}464 */465 _parseMarkupText: function()466 {467 var children = [];468 var blockChildren = [];469 var text = "";470 /**471 * @this {WebInspector.WikiParser}472 */473 function processSimpleText()474 {475 var currentText = this._deleteTrailingSpaces(text);476 if (!currentText.length)477 return;478 var simpleText = new WebInspector.WikiParser.PlainText(currentText);479 blockChildren.push(simpleText);480 text = "";481 }482 function processBlock()483 {484 if (blockChildren.length) {485 children.push(new WebInspector.WikiParser.Block(blockChildren));486 blockChildren = [];487 }488 }489 while (this._tokenizer.hasMoreTokens()) {490 var token = this._tokenizer.peekToken();491 switch (token.type()) {492 case WebInspector.WikiParser.TokenType.RowSeparator:493 case WebInspector.WikiParser.TokenType.NameSeparator:494 case WebInspector.WikiParser.TokenType.CellSeparator:495 case WebInspector.WikiParser.TokenType.ClosingTable:496 case WebInspector.WikiParser.TokenType.VerticalLine:497 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:498 if (token.type() === WebInspector.WikiParser.TokenType.VerticalLine)499 this._tokenizer.nextToken();500 processSimpleText.call(this);501 processBlock();502 return new WebInspector.WikiParser.Block(children);503 case WebInspector.WikiParser.TokenType.TripleQuotes:504 this._tokenizer.nextToken();505 processSimpleText.call(this);506 blockChildren.push(this._parseHighlight());507 break;508 case WebInspector.WikiParser.TokenType.DoubleQuotes:509 this._tokenizer.nextToken();510 processSimpleText.call(this);511 blockChildren.push(this._parseItalics());512 break;513 case WebInspector.WikiParser.TokenType.OpeningSquareBrackets:514 processSimpleText.call(this);515 blockChildren.push(this._parseLink());516 break;517 case WebInspector.WikiParser.TokenType.OpeningCodeTag:518 this._tokenizer.nextToken();519 processSimpleText.call(this);520 blockChildren.push(this._parseCode());521 break;522 case WebInspector.WikiParser.TokenType.Bullet:523 this._tokenizer.nextToken();524 processSimpleText.call(this);525 processBlock();526 children.push(this._parseBullet());527 break;528 case WebInspector.WikiParser.TokenType.CodeBlock:529 this._tokenizer.nextToken();530 processSimpleText.call(this);531 processBlock();532 var code = new WebInspector.WikiParser.CodeBlock(this._trimLeadingNewLines(token.value()));533 children.push(code);534 break;535 case WebInspector.WikiParser.TokenType.LineEnd:536 this._tokenizer.nextToken();537 processSimpleText.call(this);538 processBlock();539 break;540 case WebInspector.WikiParser.TokenType.EqualSignInCurlyBrackets:541 this._tokenizer.nextToken();542 text += "=";543 break;544 case WebInspector.WikiParser.TokenType.Exclamation:545 this._tokenizer.nextToken();546 text += "|";547 break;548 case WebInspector.WikiParser.TokenType.OpeningTable:549 this._tokenizer.nextToken();550 processSimpleText.call(this);551 processBlock();552 children.push(this._parseTable());553 break;554 case WebInspector.WikiParser.TokenType.ClosingBrackets:555 case WebInspector.WikiParser.TokenType.Text:556 case WebInspector.WikiParser.TokenType.EqualSign:557 this._tokenizer.nextToken();558 text += token.value();559 break;560 default:561 this._tokenizer.nextToken();562 return null;563 }564 }565 processSimpleText.call(this);566 processBlock();567 return new WebInspector.WikiParser.Block(children);568 },569 /**570 * @return {!WebInspector.WikiParser.ArticleElement}571 */572 _parseLink: function()573 {574 var tokenizer = this._tokenizer.clone();575 this._tokenizer.nextToken();576 this._tokenizer._setMode(WebInspector.WikiParser.Tokenizer.Mode.Link);577 var url = "";578 var children = [];579 /**580 * @return {!WebInspector.WikiParser.ArticleElement}581 * @this {WebInspector.WikiParser}582 */583 function finalizeLink()584 {585 this._tokenizer._setMode(WebInspector.WikiParser.Tokenizer.Mode.Normal);586 return new WebInspector.WikiParser.Link(url, children);587 }588 /**589 * @return {!WebInspector.WikiParser.ArticleElement}590 * @this {WebInspector.WikiParser}591 */592 function recoverAsText()593 {594 this._tokenizer = tokenizer;595 return this._parseTextUntilBrackets();596 }597 while (this._tokenizer.hasMoreTokens()) {598 var token = this._tokenizer.nextToken();599 switch (token.type()) {600 case WebInspector.WikiParser.TokenType.ClosingBrackets:601 if (this._isLink(url))602 return finalizeLink.call(this);603 return recoverAsText.call(this);604 case WebInspector.WikiParser.TokenType.VerticalLine:605 case WebInspector.WikiParser.TokenType.Space:606 case WebInspector.WikiParser.TokenType.Exclamation:607 if (this._isLink(url)) {608 children.push(this._parseLinkName());609 return finalizeLink.call(this);610 }611 return recoverAsText.call(this);612 default:613 url += token.value();614 }615 }616 return finalizeLink.call(this);617 },618 /**619 * @return {!WebInspector.WikiParser.Inline}620 */621 _parseLinkName: function()622 {623 var children = [];624 var text = "";625 /**626 * @this {WebInspector.WikiParser}627 */628 function processSimpleText()629 {630 text = this._deleteTrailingSpaces(text);631 if (!text.length)632 return;633 var simpleText = new WebInspector.WikiParser.PlainText(text);634 children.push(simpleText);635 text = "";636 }637 while (this._tokenizer.hasMoreTokens()) {638 var token = this._tokenizer.nextToken();639 switch (token.type()) {640 case WebInspector.WikiParser.TokenType.ClosingBrackets:641 processSimpleText.call(this);642 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.ArticleElement.Type.Inline, children);643 case WebInspector.WikiParser.TokenType.OpeningCodeTag:644 processSimpleText.call(this);645 children.push(this._parseCode());646 break;647 default:648 text += token.value();649 break;650 }651 }652 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.ArticleElement.Type.Inline, children);653 },654 /**655 * @return {!WebInspector.WikiParser.Inline}656 */657 _parseCode: function()658 {659 var children = [];660 var text = "";661 /**662 * @this {WebInspector.WikiParser}663 */664 function processSimpleText()665 {666 text = this._deleteTrailingSpaces(text);667 if (!text.length)668 return;669 var simpleText = new WebInspector.WikiParser.PlainText(text);670 children.push(simpleText);671 text = "";672 }673 while (this._tokenizer.hasMoreTokens()) {674 var token = this._tokenizer.peekToken();675 switch (token.type()) {676 case WebInspector.WikiParser.TokenType.ClosingCodeTag:677 this._tokenizer.nextToken();678 processSimpleText.call(this);679 var code = new WebInspector.WikiParser.Inline(WebInspector.WikiParser.ArticleElement.Type.Code, children);680 return code;681 case WebInspector.WikiParser.TokenType.OpeningSquareBrackets:682 processSimpleText.call(this);683 children.push(this._parseLink());684 break;685 default:686 this._tokenizer.nextToken();687 text += token.value();688 }689 }690 text = this._deleteTrailingSpaces(text);691 if (text.length)692 children.push(new WebInspector.WikiParser.PlainText(text));693 return new WebInspector.WikiParser.Inline(WebInspector.WikiParser.ArticleElement.Type.Code, children);694 },695 /**696 * @return {!WebInspector.WikiParser.Block}697 */698 _parseBullet: function()699 {700 var children = [];701 while (this._tokenizer.hasMoreTokens()) {702 var token = this._tokenizer.peekToken()703 switch (token.type()) {704 case WebInspector.WikiParser.TokenType.OpeningSquareBrackets:705 children.push(this._parseLink());706 break;707 case WebInspector.WikiParser.TokenType.OpeningCodeTag:708 this._tokenizer.nextToken();709 children.push(this._parseCode());710 break;711 case WebInspector.WikiParser.TokenType.LineEnd:712 this._tokenizer.nextToken();713 return new WebInspector.WikiParser.Block(children, true);714 default:715 this._tokenizer.nextToken();716 var text = this._deleteTrailingSpaces(token.value());717 if (text.length) {718 var simpleText = new WebInspector.WikiParser.PlainText(text);719 children.push(simpleText);720 text = "";721 }722 }723 }724 return new WebInspector.WikiParser.Block(children, true);725 },726 /**727 * @return {!WebInspector.WikiParser.PlainText}728 */729 _parseHighlight: function()730 {731 var text = "";732 while (this._tokenizer.hasMoreTokens()) {733 var token = this._tokenizer.nextToken();734 if (token.type() === WebInspector.WikiParser.TokenType.TripleQuotes) {735 text = this._deleteTrailingSpaces(text);736 return new WebInspector.WikiParser.PlainText(text, true);737 } else {738 text += token.value();739 }740 }741 return new WebInspector.WikiParser.PlainText(text, true);742 },743 /**744 * @return {!WebInspector.WikiParser.PlainText}745 */746 _parseItalics: function()747 {748 var text = "";749 while (this._tokenizer.hasMoreTokens) {750 var token = this._tokenizer.nextToken();751 if (token.type() === WebInspector.WikiParser.TokenType.DoubleQuotes) {752 text = this._deleteTrailingSpaces(text);753 return new WebInspector.WikiParser.PlainText(text, false, true);754 } else {755 text += token.value();756 }757 }758 return new WebInspector.WikiParser.PlainText(text, false, true);759 },760 /**761 * @return {!WebInspector.WikiParser.PlainText}762 */763 _parseTextUntilBrackets: function()764 {765 var text = this._tokenizer.nextToken().value();766 while (this._tokenizer.hasMoreTokens()) {767 var token = this._tokenizer.peekToken();768 switch (token.type()) {769 case WebInspector.WikiParser.TokenType.VerticalLine:770 this._tokenizer.nextToken();771 return new WebInspector.WikiParser.PlainText(text);772 case WebInspector.WikiParser.TokenType.ClosingCurlyBrackets:773 case WebInspector.WikiParser.TokenType.OpeningSquareBrackets:774 return new WebInspector.WikiParser.PlainText(text);775 default:776 this._tokenizer.nextToken();777 text += token.value();778 }779 }780 return new WebInspector.WikiParser.PlainText(text);781 },782 /**783 * @return {!WebInspector.WikiParser.Table}784 */785 _parseTable: function()786 {787 var columnNames = [];788 var rows = [];789 while (this._tokenizer.hasMoreTokens() && this._tokenizer.peekToken().type() !== WebInspector.WikiParser.TokenType.RowSeparator)790 this._tokenizer.nextToken();791 if (!this._tokenizer.hasMoreTokens())792 throw new Error("Table could not be parsed");793 this._tokenizer.nextToken();794 while (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.NameSeparator) {795 this._tokenizer.nextToken();796 columnNames.push(this._parseMarkupText());797 }798 while (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.RowSeparator) {799 this._tokenizer.nextToken();800 var row = [];801 while (this._tokenizer.peekToken().type() === WebInspector.WikiParser.TokenType.CellSeparator) {802 this._tokenizer.nextToken();803 row.push(this._parseMarkupText());804 }805 rows.push(row);806 }807 var token = this._tokenizer.nextToken();808 if (token.type() !== WebInspector.WikiParser.TokenType.ClosingTable)809 throw new Error("Table could not be parsed. {{!}}} expected; found " + token.value());810 for (var i = 0; i < rows.length; ++i) {811 if (rows[i].length !== columnNames.length)812 throw new Error(String.sprintf("Table could not be parsed. Row %d has %d cells; expected %d.", i, rows[i].length, columnNames[i].length));813 }814 return new WebInspector.WikiParser.Table(columnNames, rows);815 },816 /**817 * @param {string} str818 * @return {string}819 */820 _deleteTrailingSpaces: function(str)821 {822 return str.replace(/[\n\r]*$/gm, "");823 },824 /**825 * @param {string} str826 * @return {string}827 */828 _trimLeadingNewLines: function(str)829 {830 return str.replace(/^\n*/, "");831 },832 /**833 * @param {string} str834 * @return {boolean}835 */836 _isInternalLink: function(str)837 {838 var len = str.length;839 return /^[a-zA-Z\/-]+$/.test(str);840 },841 /**842 * @param {string} str843 * @return {boolean}844 */845 _isLink: function(str)846 {847 if (this._isInternalLink(str))848 return true;849 var url = new WebInspector.ParsedURL(str);850 return url.isValid;851 }852}853/**854 * @constructor855 * @param {!WebInspector.WikiParser.ArticleElement.Type} type856 */857WebInspector.WikiParser.ArticleElement = function(type)858{859 this._type = type;860}861WebInspector.WikiParser.ArticleElement.prototype = {862 /**863 * @return {!WebInspector.WikiParser.ArticleElement.Type}864 */865 type: function()866 {867 return this._type;868 }869}870/**871 * @enum {string}872 */873WebInspector.WikiParser.ArticleElement.Type = {874 PlainText: "PlainText",875 Link: "Link",876 Code: "Code",877 Block: "Block",878 CodeBlock: "CodeBlock",879 Inline: "Inline",880 Table: "Table"881};882/**883 * @constructor884 * @extends {WebInspector.WikiParser.ArticleElement}885 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} columnNames886 * @param {!Array.<!Array.<!WebInspector.WikiParser.ArticleElement>>} rows887 */888WebInspector.WikiParser.Table = function(columnNames, rows)889{890 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.ArticleElement.Type.Table);891 this._columnNames = columnNames;892 this._rows = rows;893}894WebInspector.WikiParser.Table.prototype = {895 /**896 * @return {!Array.<!WebInspector.WikiParser.ArticleElement>}897 */898 columnNames: function()899 {900 return this._columnNames;901 },902 /**903 * @return {!Array.<!Array.<!WebInspector.WikiParser.ArticleElement>>}904 */905 rows: function()906 {907 return this._rows;908 },909 __proto__: WebInspector.WikiParser.ArticleElement.prototype910}911/**912 * @constructor913 * @extends {WebInspector.WikiParser.ArticleElement}914 * @param {string} text915 * @param {boolean=} highlight916 * @param {boolean=} italic917 */918WebInspector.WikiParser.PlainText = function(text, highlight, italic)919{920 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.ArticleElement.Type.PlainText);921 this._text = text.unescapeHTML();922 this._isHighlighted = highlight || false;923 this._isItalic = italic || false;924}925WebInspector.WikiParser.PlainText.prototype = {926 /**927 * @return {string}928 */929 text: function()930 {931 return this._text;932 },933 /**934 * @return {boolean}935 */936 isHighlighted: function()937 {938 return this._isHighlighted;939 },940 __proto__: WebInspector.WikiParser.ArticleElement.prototype941}942/**943 * @constructor944 * @extends {WebInspector.WikiParser.ArticleElement}945 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} children946 * @param {boolean=} hasBullet947 */948WebInspector.WikiParser.Block = function(children, hasBullet)949{950 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.ArticleElement.Type.Block);951 this._children = children;952 this._hasBullet = hasBullet || false;953}954WebInspector.WikiParser.Block.prototype = {955 /**956 * @return {!Array.<!WebInspector.WikiParser.ArticleElement>}957 */958 children: function()959 {960 return this._children;961 },962 /**963 * @return {boolean}964 */965 hasChildren: function()966 {967 return !!this._children && !!this._children.length;968 },969 /**970 * @return {boolean}971 */972 hasBullet: function()973 {974 return this._hasBullet;975 },976 __proto__: WebInspector.WikiParser.ArticleElement.prototype977}978/**979 * @constructor980 * @extends {WebInspector.WikiParser.ArticleElement}981 * @param {string} text982 */983WebInspector.WikiParser.CodeBlock = function(text)984{985 WebInspector.WikiParser.ArticleElement.call(this, WebInspector.WikiParser.ArticleElement.Type.CodeBlock);986 this._code = text.unescapeHTML();987}988WebInspector.WikiParser.CodeBlock.prototype = {989 /**990 * @return {string}991 */992 code: function()993 {994 return this._code;995 },996 __proto__: WebInspector.WikiParser.ArticleElement.prototype997}998/**999 * @constructor1000 * @extends {WebInspector.WikiParser.ArticleElement}1001 * @param {!WebInspector.WikiParser.ArticleElement.Type} type1002 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} children1003 */1004WebInspector.WikiParser.Inline = function(type, children)1005{1006 WebInspector.WikiParser.ArticleElement.call(this, type)1007 this._children = children;1008}1009WebInspector.WikiParser.Inline.prototype = {1010 /**1011 * @return {!Array.<!WebInspector.WikiParser.ArticleElement>}1012 */1013 children: function()1014 {1015 return this._children;1016 },1017 __proto__: WebInspector.WikiParser.ArticleElement.prototype1018}1019/**1020 * @constructor1021 * @extends {WebInspector.WikiParser.Inline}1022 * @param {string} url1023 * @param {!Array.<!WebInspector.WikiParser.ArticleElement>} children1024 */1025WebInspector.WikiParser.Link = function(url, children)1026{1027 WebInspector.WikiParser.Inline.call(this, WebInspector.WikiParser.ArticleElement.Type.Link, children);1028 this._url = url;1029}1030WebInspector.WikiParser.Link.prototype = {1031 /**1032 * @return {string}1033 */1034 url : function()1035 {1036 return this._url;1037 },1038 __proto__: WebInspector.WikiParser.Inline.prototype...

Full Screen

Full Screen

SolidityListener.py

Source:SolidityListener.py Github

copy

Full Screen

1# Generated from solidity-antlr4/Solidity.g4 by ANTLR 4.7.22from antlr4 import *3if __name__ is not None and "." in __name__:4 from .SolidityParser import SolidityParser5else:6 from SolidityParser import SolidityParser7# This class defines a complete listener for a parse tree produced by SolidityParser.8class SolidityListener(ParseTreeListener):9 # Enter a parse tree produced by SolidityParser#sourceUnit.10 def enterSourceUnit(self, ctx:SolidityParser.SourceUnitContext):11 pass12 # Exit a parse tree produced by SolidityParser#sourceUnit.13 def exitSourceUnit(self, ctx:SolidityParser.SourceUnitContext):14 pass15 # Enter a parse tree produced by SolidityParser#pragmaDirective.16 def enterPragmaDirective(self, ctx:SolidityParser.PragmaDirectiveContext):17 pass18 # Exit a parse tree produced by SolidityParser#pragmaDirective.19 def exitPragmaDirective(self, ctx:SolidityParser.PragmaDirectiveContext):20 pass21 # Enter a parse tree produced by SolidityParser#pragmaName.22 def enterPragmaName(self, ctx:SolidityParser.PragmaNameContext):23 pass24 # Exit a parse tree produced by SolidityParser#pragmaName.25 def exitPragmaName(self, ctx:SolidityParser.PragmaNameContext):26 pass27 # Enter a parse tree produced by SolidityParser#pragmaValue.28 def enterPragmaValue(self, ctx:SolidityParser.PragmaValueContext):29 pass30 # Exit a parse tree produced by SolidityParser#pragmaValue.31 def exitPragmaValue(self, ctx:SolidityParser.PragmaValueContext):32 pass33 # Enter a parse tree produced by SolidityParser#version.34 def enterVersion(self, ctx:SolidityParser.VersionContext):35 pass36 # Exit a parse tree produced by SolidityParser#version.37 def exitVersion(self, ctx:SolidityParser.VersionContext):38 pass39 # Enter a parse tree produced by SolidityParser#versionOperator.40 def enterVersionOperator(self, ctx:SolidityParser.VersionOperatorContext):41 pass42 # Exit a parse tree produced by SolidityParser#versionOperator.43 def exitVersionOperator(self, ctx:SolidityParser.VersionOperatorContext):44 pass45 # Enter a parse tree produced by SolidityParser#versionConstraint.46 def enterVersionConstraint(self, ctx:SolidityParser.VersionConstraintContext):47 pass48 # Exit a parse tree produced by SolidityParser#versionConstraint.49 def exitVersionConstraint(self, ctx:SolidityParser.VersionConstraintContext):50 pass51 # Enter a parse tree produced by SolidityParser#importDeclaration.52 def enterImportDeclaration(self, ctx:SolidityParser.ImportDeclarationContext):53 pass54 # Exit a parse tree produced by SolidityParser#importDeclaration.55 def exitImportDeclaration(self, ctx:SolidityParser.ImportDeclarationContext):56 pass57 # Enter a parse tree produced by SolidityParser#importDirective.58 def enterImportDirective(self, ctx:SolidityParser.ImportDirectiveContext):59 pass60 # Exit a parse tree produced by SolidityParser#importDirective.61 def exitImportDirective(self, ctx:SolidityParser.ImportDirectiveContext):62 pass63 # Enter a parse tree produced by SolidityParser#contractDefinition.64 def enterContractDefinition(self, ctx:SolidityParser.ContractDefinitionContext):65 pass66 # Exit a parse tree produced by SolidityParser#contractDefinition.67 def exitContractDefinition(self, ctx:SolidityParser.ContractDefinitionContext):68 pass69 # Enter a parse tree produced by SolidityParser#inheritanceSpecifier.70 def enterInheritanceSpecifier(self, ctx:SolidityParser.InheritanceSpecifierContext):71 pass72 # Exit a parse tree produced by SolidityParser#inheritanceSpecifier.73 def exitInheritanceSpecifier(self, ctx:SolidityParser.InheritanceSpecifierContext):74 pass75 # Enter a parse tree produced by SolidityParser#contractPart.76 def enterContractPart(self, ctx:SolidityParser.ContractPartContext):77 pass78 # Exit a parse tree produced by SolidityParser#contractPart.79 def exitContractPart(self, ctx:SolidityParser.ContractPartContext):80 pass81 # Enter a parse tree produced by SolidityParser#stateVariableDeclaration.82 def enterStateVariableDeclaration(self, ctx:SolidityParser.StateVariableDeclarationContext):83 pass84 # Exit a parse tree produced by SolidityParser#stateVariableDeclaration.85 def exitStateVariableDeclaration(self, ctx:SolidityParser.StateVariableDeclarationContext):86 pass87 # Enter a parse tree produced by SolidityParser#usingForDeclaration.88 def enterUsingForDeclaration(self, ctx:SolidityParser.UsingForDeclarationContext):89 pass90 # Exit a parse tree produced by SolidityParser#usingForDeclaration.91 def exitUsingForDeclaration(self, ctx:SolidityParser.UsingForDeclarationContext):92 pass93 # Enter a parse tree produced by SolidityParser#structDefinition.94 def enterStructDefinition(self, ctx:SolidityParser.StructDefinitionContext):95 pass96 # Exit a parse tree produced by SolidityParser#structDefinition.97 def exitStructDefinition(self, ctx:SolidityParser.StructDefinitionContext):98 pass99 # Enter a parse tree produced by SolidityParser#constructorDefinition.100 def enterConstructorDefinition(self, ctx:SolidityParser.ConstructorDefinitionContext):101 pass102 # Exit a parse tree produced by SolidityParser#constructorDefinition.103 def exitConstructorDefinition(self, ctx:SolidityParser.ConstructorDefinitionContext):104 pass105 # Enter a parse tree produced by SolidityParser#modifierDefinition.106 def enterModifierDefinition(self, ctx:SolidityParser.ModifierDefinitionContext):107 pass108 # Exit a parse tree produced by SolidityParser#modifierDefinition.109 def exitModifierDefinition(self, ctx:SolidityParser.ModifierDefinitionContext):110 pass111 # Enter a parse tree produced by SolidityParser#modifierInvocation.112 def enterModifierInvocation(self, ctx:SolidityParser.ModifierInvocationContext):113 pass114 # Exit a parse tree produced by SolidityParser#modifierInvocation.115 def exitModifierInvocation(self, ctx:SolidityParser.ModifierInvocationContext):116 pass117 # Enter a parse tree produced by SolidityParser#functionDefinition.118 def enterFunctionDefinition(self, ctx:SolidityParser.FunctionDefinitionContext):119 pass120 # Exit a parse tree produced by SolidityParser#functionDefinition.121 def exitFunctionDefinition(self, ctx:SolidityParser.FunctionDefinitionContext):122 pass123 # Enter a parse tree produced by SolidityParser#returnParameters.124 def enterReturnParameters(self, ctx:SolidityParser.ReturnParametersContext):125 pass126 # Exit a parse tree produced by SolidityParser#returnParameters.127 def exitReturnParameters(self, ctx:SolidityParser.ReturnParametersContext):128 pass129 # Enter a parse tree produced by SolidityParser#modifierList.130 def enterModifierList(self, ctx:SolidityParser.ModifierListContext):131 pass132 # Exit a parse tree produced by SolidityParser#modifierList.133 def exitModifierList(self, ctx:SolidityParser.ModifierListContext):134 pass135 # Enter a parse tree produced by SolidityParser#eventDefinition.136 def enterEventDefinition(self, ctx:SolidityParser.EventDefinitionContext):137 pass138 # Exit a parse tree produced by SolidityParser#eventDefinition.139 def exitEventDefinition(self, ctx:SolidityParser.EventDefinitionContext):140 pass141 # Enter a parse tree produced by SolidityParser#enumValue.142 def enterEnumValue(self, ctx:SolidityParser.EnumValueContext):143 pass144 # Exit a parse tree produced by SolidityParser#enumValue.145 def exitEnumValue(self, ctx:SolidityParser.EnumValueContext):146 pass147 # Enter a parse tree produced by SolidityParser#enumDefinition.148 def enterEnumDefinition(self, ctx:SolidityParser.EnumDefinitionContext):149 pass150 # Exit a parse tree produced by SolidityParser#enumDefinition.151 def exitEnumDefinition(self, ctx:SolidityParser.EnumDefinitionContext):152 pass153 # Enter a parse tree produced by SolidityParser#parameterList.154 def enterParameterList(self, ctx:SolidityParser.ParameterListContext):155 pass156 # Exit a parse tree produced by SolidityParser#parameterList.157 def exitParameterList(self, ctx:SolidityParser.ParameterListContext):158 pass159 # Enter a parse tree produced by SolidityParser#parameter.160 def enterParameter(self, ctx:SolidityParser.ParameterContext):161 pass162 # Exit a parse tree produced by SolidityParser#parameter.163 def exitParameter(self, ctx:SolidityParser.ParameterContext):164 pass165 # Enter a parse tree produced by SolidityParser#eventParameterList.166 def enterEventParameterList(self, ctx:SolidityParser.EventParameterListContext):167 pass168 # Exit a parse tree produced by SolidityParser#eventParameterList.169 def exitEventParameterList(self, ctx:SolidityParser.EventParameterListContext):170 pass171 # Enter a parse tree produced by SolidityParser#eventParameter.172 def enterEventParameter(self, ctx:SolidityParser.EventParameterContext):173 pass174 # Exit a parse tree produced by SolidityParser#eventParameter.175 def exitEventParameter(self, ctx:SolidityParser.EventParameterContext):176 pass177 # Enter a parse tree produced by SolidityParser#functionTypeParameterList.178 def enterFunctionTypeParameterList(self, ctx:SolidityParser.FunctionTypeParameterListContext):179 pass180 # Exit a parse tree produced by SolidityParser#functionTypeParameterList.181 def exitFunctionTypeParameterList(self, ctx:SolidityParser.FunctionTypeParameterListContext):182 pass183 # Enter a parse tree produced by SolidityParser#functionTypeParameter.184 def enterFunctionTypeParameter(self, ctx:SolidityParser.FunctionTypeParameterContext):185 pass186 # Exit a parse tree produced by SolidityParser#functionTypeParameter.187 def exitFunctionTypeParameter(self, ctx:SolidityParser.FunctionTypeParameterContext):188 pass189 # Enter a parse tree produced by SolidityParser#variableDeclaration.190 def enterVariableDeclaration(self, ctx:SolidityParser.VariableDeclarationContext):191 pass192 # Exit a parse tree produced by SolidityParser#variableDeclaration.193 def exitVariableDeclaration(self, ctx:SolidityParser.VariableDeclarationContext):194 pass195 # Enter a parse tree produced by SolidityParser#typeName.196 def enterTypeName(self, ctx:SolidityParser.TypeNameContext):197 pass198 # Exit a parse tree produced by SolidityParser#typeName.199 def exitTypeName(self, ctx:SolidityParser.TypeNameContext):200 pass201 # Enter a parse tree produced by SolidityParser#userDefinedTypeName.202 def enterUserDefinedTypeName(self, ctx:SolidityParser.UserDefinedTypeNameContext):203 pass204 # Exit a parse tree produced by SolidityParser#userDefinedTypeName.205 def exitUserDefinedTypeName(self, ctx:SolidityParser.UserDefinedTypeNameContext):206 pass207 # Enter a parse tree produced by SolidityParser#mapping.208 def enterMapping(self, ctx:SolidityParser.MappingContext):209 pass210 # Exit a parse tree produced by SolidityParser#mapping.211 def exitMapping(self, ctx:SolidityParser.MappingContext):212 pass213 # Enter a parse tree produced by SolidityParser#functionTypeName.214 def enterFunctionTypeName(self, ctx:SolidityParser.FunctionTypeNameContext):215 pass216 # Exit a parse tree produced by SolidityParser#functionTypeName.217 def exitFunctionTypeName(self, ctx:SolidityParser.FunctionTypeNameContext):218 pass219 # Enter a parse tree produced by SolidityParser#storageLocation.220 def enterStorageLocation(self, ctx:SolidityParser.StorageLocationContext):221 pass222 # Exit a parse tree produced by SolidityParser#storageLocation.223 def exitStorageLocation(self, ctx:SolidityParser.StorageLocationContext):224 pass225 # Enter a parse tree produced by SolidityParser#stateMutability.226 def enterStateMutability(self, ctx:SolidityParser.StateMutabilityContext):227 pass228 # Exit a parse tree produced by SolidityParser#stateMutability.229 def exitStateMutability(self, ctx:SolidityParser.StateMutabilityContext):230 pass231 # Enter a parse tree produced by SolidityParser#block.232 def enterBlock(self, ctx:SolidityParser.BlockContext):233 pass234 # Exit a parse tree produced by SolidityParser#block.235 def exitBlock(self, ctx:SolidityParser.BlockContext):236 pass237 # Enter a parse tree produced by SolidityParser#statement.238 def enterStatement(self, ctx:SolidityParser.StatementContext):239 pass240 # Exit a parse tree produced by SolidityParser#statement.241 def exitStatement(self, ctx:SolidityParser.StatementContext):242 pass243 # Enter a parse tree produced by SolidityParser#expressionStatement.244 def enterExpressionStatement(self, ctx:SolidityParser.ExpressionStatementContext):245 pass246 # Exit a parse tree produced by SolidityParser#expressionStatement.247 def exitExpressionStatement(self, ctx:SolidityParser.ExpressionStatementContext):248 pass249 # Enter a parse tree produced by SolidityParser#ifStatement.250 def enterIfStatement(self, ctx:SolidityParser.IfStatementContext):251 pass252 # Exit a parse tree produced by SolidityParser#ifStatement.253 def exitIfStatement(self, ctx:SolidityParser.IfStatementContext):254 pass255 # Enter a parse tree produced by SolidityParser#whileStatement.256 def enterWhileStatement(self, ctx:SolidityParser.WhileStatementContext):257 pass258 # Exit a parse tree produced by SolidityParser#whileStatement.259 def exitWhileStatement(self, ctx:SolidityParser.WhileStatementContext):260 pass261 # Enter a parse tree produced by SolidityParser#simpleStatement.262 def enterSimpleStatement(self, ctx:SolidityParser.SimpleStatementContext):263 pass264 # Exit a parse tree produced by SolidityParser#simpleStatement.265 def exitSimpleStatement(self, ctx:SolidityParser.SimpleStatementContext):266 pass267 # Enter a parse tree produced by SolidityParser#forStatement.268 def enterForStatement(self, ctx:SolidityParser.ForStatementContext):269 pass270 # Exit a parse tree produced by SolidityParser#forStatement.271 def exitForStatement(self, ctx:SolidityParser.ForStatementContext):272 pass273 # Enter a parse tree produced by SolidityParser#inlineAssemblyStatement.274 def enterInlineAssemblyStatement(self, ctx:SolidityParser.InlineAssemblyStatementContext):275 pass276 # Exit a parse tree produced by SolidityParser#inlineAssemblyStatement.277 def exitInlineAssemblyStatement(self, ctx:SolidityParser.InlineAssemblyStatementContext):278 pass279 # Enter a parse tree produced by SolidityParser#doWhileStatement.280 def enterDoWhileStatement(self, ctx:SolidityParser.DoWhileStatementContext):281 pass282 # Exit a parse tree produced by SolidityParser#doWhileStatement.283 def exitDoWhileStatement(self, ctx:SolidityParser.DoWhileStatementContext):284 pass285 # Enter a parse tree produced by SolidityParser#continueStatement.286 def enterContinueStatement(self, ctx:SolidityParser.ContinueStatementContext):287 pass288 # Exit a parse tree produced by SolidityParser#continueStatement.289 def exitContinueStatement(self, ctx:SolidityParser.ContinueStatementContext):290 pass291 # Enter a parse tree produced by SolidityParser#breakStatement.292 def enterBreakStatement(self, ctx:SolidityParser.BreakStatementContext):293 pass294 # Exit a parse tree produced by SolidityParser#breakStatement.295 def exitBreakStatement(self, ctx:SolidityParser.BreakStatementContext):296 pass297 # Enter a parse tree produced by SolidityParser#returnStatement.298 def enterReturnStatement(self, ctx:SolidityParser.ReturnStatementContext):299 pass300 # Exit a parse tree produced by SolidityParser#returnStatement.301 def exitReturnStatement(self, ctx:SolidityParser.ReturnStatementContext):302 pass303 # Enter a parse tree produced by SolidityParser#throwStatement.304 def enterThrowStatement(self, ctx:SolidityParser.ThrowStatementContext):305 pass306 # Exit a parse tree produced by SolidityParser#throwStatement.307 def exitThrowStatement(self, ctx:SolidityParser.ThrowStatementContext):308 pass309 # Enter a parse tree produced by SolidityParser#emitStatement.310 def enterEmitStatement(self, ctx:SolidityParser.EmitStatementContext):311 pass312 # Exit a parse tree produced by SolidityParser#emitStatement.313 def exitEmitStatement(self, ctx:SolidityParser.EmitStatementContext):314 pass315 # Enter a parse tree produced by SolidityParser#variableDeclarationStatement.316 def enterVariableDeclarationStatement(self, ctx:SolidityParser.VariableDeclarationStatementContext):317 pass318 # Exit a parse tree produced by SolidityParser#variableDeclarationStatement.319 def exitVariableDeclarationStatement(self, ctx:SolidityParser.VariableDeclarationStatementContext):320 pass321 # Enter a parse tree produced by SolidityParser#variableDeclarationList.322 def enterVariableDeclarationList(self, ctx:SolidityParser.VariableDeclarationListContext):323 pass324 # Exit a parse tree produced by SolidityParser#variableDeclarationList.325 def exitVariableDeclarationList(self, ctx:SolidityParser.VariableDeclarationListContext):326 pass327 # Enter a parse tree produced by SolidityParser#identifierList.328 def enterIdentifierList(self, ctx:SolidityParser.IdentifierListContext):329 pass330 # Exit a parse tree produced by SolidityParser#identifierList.331 def exitIdentifierList(self, ctx:SolidityParser.IdentifierListContext):332 pass333 # Enter a parse tree produced by SolidityParser#elementaryTypeName.334 def enterElementaryTypeName(self, ctx:SolidityParser.ElementaryTypeNameContext):335 pass336 # Exit a parse tree produced by SolidityParser#elementaryTypeName.337 def exitElementaryTypeName(self, ctx:SolidityParser.ElementaryTypeNameContext):338 pass339 # Enter a parse tree produced by SolidityParser#expression.340 def enterExpression(self, ctx:SolidityParser.ExpressionContext):341 pass342 # Exit a parse tree produced by SolidityParser#expression.343 def exitExpression(self, ctx:SolidityParser.ExpressionContext):344 pass345 # Enter a parse tree produced by SolidityParser#primaryExpression.346 def enterPrimaryExpression(self, ctx:SolidityParser.PrimaryExpressionContext):347 pass348 # Exit a parse tree produced by SolidityParser#primaryExpression.349 def exitPrimaryExpression(self, ctx:SolidityParser.PrimaryExpressionContext):350 pass351 # Enter a parse tree produced by SolidityParser#expressionList.352 def enterExpressionList(self, ctx:SolidityParser.ExpressionListContext):353 pass354 # Exit a parse tree produced by SolidityParser#expressionList.355 def exitExpressionList(self, ctx:SolidityParser.ExpressionListContext):356 pass357 # Enter a parse tree produced by SolidityParser#nameValueList.358 def enterNameValueList(self, ctx:SolidityParser.NameValueListContext):359 pass360 # Exit a parse tree produced by SolidityParser#nameValueList.361 def exitNameValueList(self, ctx:SolidityParser.NameValueListContext):362 pass363 # Enter a parse tree produced by SolidityParser#nameValue.364 def enterNameValue(self, ctx:SolidityParser.NameValueContext):365 pass366 # Exit a parse tree produced by SolidityParser#nameValue.367 def exitNameValue(self, ctx:SolidityParser.NameValueContext):368 pass369 # Enter a parse tree produced by SolidityParser#functionCallArguments.370 def enterFunctionCallArguments(self, ctx:SolidityParser.FunctionCallArgumentsContext):371 pass372 # Exit a parse tree produced by SolidityParser#functionCallArguments.373 def exitFunctionCallArguments(self, ctx:SolidityParser.FunctionCallArgumentsContext):374 pass375 # Enter a parse tree produced by SolidityParser#functionCall.376 def enterFunctionCall(self, ctx:SolidityParser.FunctionCallContext):377 pass378 # Exit a parse tree produced by SolidityParser#functionCall.379 def exitFunctionCall(self, ctx:SolidityParser.FunctionCallContext):380 pass381 # Enter a parse tree produced by SolidityParser#assemblyBlock.382 def enterAssemblyBlock(self, ctx:SolidityParser.AssemblyBlockContext):383 pass384 # Exit a parse tree produced by SolidityParser#assemblyBlock.385 def exitAssemblyBlock(self, ctx:SolidityParser.AssemblyBlockContext):386 pass387 # Enter a parse tree produced by SolidityParser#assemblyItem.388 def enterAssemblyItem(self, ctx:SolidityParser.AssemblyItemContext):389 pass390 # Exit a parse tree produced by SolidityParser#assemblyItem.391 def exitAssemblyItem(self, ctx:SolidityParser.AssemblyItemContext):392 pass393 # Enter a parse tree produced by SolidityParser#assemblyExpression.394 def enterAssemblyExpression(self, ctx:SolidityParser.AssemblyExpressionContext):395 pass396 # Exit a parse tree produced by SolidityParser#assemblyExpression.397 def exitAssemblyExpression(self, ctx:SolidityParser.AssemblyExpressionContext):398 pass399 # Enter a parse tree produced by SolidityParser#assemblyCall.400 def enterAssemblyCall(self, ctx:SolidityParser.AssemblyCallContext):401 pass402 # Exit a parse tree produced by SolidityParser#assemblyCall.403 def exitAssemblyCall(self, ctx:SolidityParser.AssemblyCallContext):404 pass405 # Enter a parse tree produced by SolidityParser#assemblyLocalDefinition.406 def enterAssemblyLocalDefinition(self, ctx:SolidityParser.AssemblyLocalDefinitionContext):407 pass408 # Exit a parse tree produced by SolidityParser#assemblyLocalDefinition.409 def exitAssemblyLocalDefinition(self, ctx:SolidityParser.AssemblyLocalDefinitionContext):410 pass411 # Enter a parse tree produced by SolidityParser#assemblyAssignment.412 def enterAssemblyAssignment(self, ctx:SolidityParser.AssemblyAssignmentContext):413 pass414 # Exit a parse tree produced by SolidityParser#assemblyAssignment.415 def exitAssemblyAssignment(self, ctx:SolidityParser.AssemblyAssignmentContext):416 pass417 # Enter a parse tree produced by SolidityParser#assemblyIdentifierOrList.418 def enterAssemblyIdentifierOrList(self, ctx:SolidityParser.AssemblyIdentifierOrListContext):419 pass420 # Exit a parse tree produced by SolidityParser#assemblyIdentifierOrList.421 def exitAssemblyIdentifierOrList(self, ctx:SolidityParser.AssemblyIdentifierOrListContext):422 pass423 # Enter a parse tree produced by SolidityParser#assemblyIdentifierList.424 def enterAssemblyIdentifierList(self, ctx:SolidityParser.AssemblyIdentifierListContext):425 pass426 # Exit a parse tree produced by SolidityParser#assemblyIdentifierList.427 def exitAssemblyIdentifierList(self, ctx:SolidityParser.AssemblyIdentifierListContext):428 pass429 # Enter a parse tree produced by SolidityParser#assemblyStackAssignment.430 def enterAssemblyStackAssignment(self, ctx:SolidityParser.AssemblyStackAssignmentContext):431 pass432 # Exit a parse tree produced by SolidityParser#assemblyStackAssignment.433 def exitAssemblyStackAssignment(self, ctx:SolidityParser.AssemblyStackAssignmentContext):434 pass435 # Enter a parse tree produced by SolidityParser#labelDefinition.436 def enterLabelDefinition(self, ctx:SolidityParser.LabelDefinitionContext):437 pass438 # Exit a parse tree produced by SolidityParser#labelDefinition.439 def exitLabelDefinition(self, ctx:SolidityParser.LabelDefinitionContext):440 pass441 # Enter a parse tree produced by SolidityParser#assemblySwitch.442 def enterAssemblySwitch(self, ctx:SolidityParser.AssemblySwitchContext):443 pass444 # Exit a parse tree produced by SolidityParser#assemblySwitch.445 def exitAssemblySwitch(self, ctx:SolidityParser.AssemblySwitchContext):446 pass447 # Enter a parse tree produced by SolidityParser#assemblyCase.448 def enterAssemblyCase(self, ctx:SolidityParser.AssemblyCaseContext):449 pass450 # Exit a parse tree produced by SolidityParser#assemblyCase.451 def exitAssemblyCase(self, ctx:SolidityParser.AssemblyCaseContext):452 pass453 # Enter a parse tree produced by SolidityParser#assemblyFunctionDefinition.454 def enterAssemblyFunctionDefinition(self, ctx:SolidityParser.AssemblyFunctionDefinitionContext):455 pass456 # Exit a parse tree produced by SolidityParser#assemblyFunctionDefinition.457 def exitAssemblyFunctionDefinition(self, ctx:SolidityParser.AssemblyFunctionDefinitionContext):458 pass459 # Enter a parse tree produced by SolidityParser#assemblyFunctionReturns.460 def enterAssemblyFunctionReturns(self, ctx:SolidityParser.AssemblyFunctionReturnsContext):461 pass462 # Exit a parse tree produced by SolidityParser#assemblyFunctionReturns.463 def exitAssemblyFunctionReturns(self, ctx:SolidityParser.AssemblyFunctionReturnsContext):464 pass465 # Enter a parse tree produced by SolidityParser#assemblyFor.466 def enterAssemblyFor(self, ctx:SolidityParser.AssemblyForContext):467 pass468 # Exit a parse tree produced by SolidityParser#assemblyFor.469 def exitAssemblyFor(self, ctx:SolidityParser.AssemblyForContext):470 pass471 # Enter a parse tree produced by SolidityParser#assemblyIf.472 def enterAssemblyIf(self, ctx:SolidityParser.AssemblyIfContext):473 pass474 # Exit a parse tree produced by SolidityParser#assemblyIf.475 def exitAssemblyIf(self, ctx:SolidityParser.AssemblyIfContext):476 pass477 # Enter a parse tree produced by SolidityParser#assemblyLiteral.478 def enterAssemblyLiteral(self, ctx:SolidityParser.AssemblyLiteralContext):479 pass480 # Exit a parse tree produced by SolidityParser#assemblyLiteral.481 def exitAssemblyLiteral(self, ctx:SolidityParser.AssemblyLiteralContext):482 pass483 # Enter a parse tree produced by SolidityParser#subAssembly.484 def enterSubAssembly(self, ctx:SolidityParser.SubAssemblyContext):485 pass486 # Exit a parse tree produced by SolidityParser#subAssembly.487 def exitSubAssembly(self, ctx:SolidityParser.SubAssemblyContext):488 pass489 # Enter a parse tree produced by SolidityParser#tupleExpression.490 def enterTupleExpression(self, ctx:SolidityParser.TupleExpressionContext):491 pass492 # Exit a parse tree produced by SolidityParser#tupleExpression.493 def exitTupleExpression(self, ctx:SolidityParser.TupleExpressionContext):494 pass495 # Enter a parse tree produced by SolidityParser#elementaryTypeNameExpression.496 def enterElementaryTypeNameExpression(self, ctx:SolidityParser.ElementaryTypeNameExpressionContext):497 pass498 # Exit a parse tree produced by SolidityParser#elementaryTypeNameExpression.499 def exitElementaryTypeNameExpression(self, ctx:SolidityParser.ElementaryTypeNameExpressionContext):500 pass501 # Enter a parse tree produced by SolidityParser#numberLiteral.502 def enterNumberLiteral(self, ctx:SolidityParser.NumberLiteralContext):503 pass504 # Exit a parse tree produced by SolidityParser#numberLiteral.505 def exitNumberLiteral(self, ctx:SolidityParser.NumberLiteralContext):506 pass507 # Enter a parse tree produced by SolidityParser#identifier.508 def enterIdentifier(self, ctx:SolidityParser.IdentifierContext):509 pass510 # Exit a parse tree produced by SolidityParser#identifier.511 def exitIdentifier(self, ctx:SolidityParser.IdentifierContext):...

Full Screen

Full Screen

test_dictionary.py

Source:test_dictionary.py Github

copy

Full Screen

1def WebIDLTest(parser, harness):2 parser.parse("""3 dictionary Dict2 : Dict1 {4 long child = 5;5 Dict1 aaandAnother;6 };7 dictionary Dict1 {8 long parent;9 double otherParent;10 };11 """)12 results = parser.finish()13 dict1 = results[1];14 dict2 = results[0];15 harness.check(len(dict1.members), 2, "Dict1 has two members")16 harness.check(len(dict2.members), 2, "Dict2 has four members")17 harness.check(dict1.members[0].identifier.name, "otherParent",18 "'o' comes before 'p'")19 harness.check(dict1.members[1].identifier.name, "parent",20 "'o' really comes before 'p'")21 harness.check(dict2.members[0].identifier.name, "aaandAnother",22 "'a' comes before 'c'")23 harness.check(dict2.members[1].identifier.name, "child",24 "'a' really comes before 'c'")25 # Now reset our parser26 parser = parser.reset()27 threw = False28 try:29 parser.parse("""30 dictionary Dict {31 long prop = 5;32 long prop;33 };34 """)35 results = parser.finish()36 except:37 threw = True38 harness.ok(threw, "Should not allow name duplication in a dictionary")39 # Now reset our parser again40 parser = parser.reset()41 threw = False42 try:43 parser.parse("""44 dictionary Dict1 : Dict2 {45 long prop = 5;46 };47 dictionary Dict2 : Dict3 {48 long prop2;49 };50 dictionary Dict3 {51 double prop;52 };53 """)54 results = parser.finish()55 except:56 threw = True57 harness.ok(threw, "Should not allow name duplication in a dictionary and "58 "its ancestor")59 # More reset60 parser = parser.reset()61 threw = False62 try:63 parser.parse("""64 interface Iface {};65 dictionary Dict : Iface {66 long prop;67 };68 """)69 results = parser.finish()70 except:71 threw = True72 harness.ok(threw, "Should not allow non-dictionary parents for dictionaries")73 # Even more reset74 parser = parser.reset()75 threw = False76 try:77 parser.parse("""78 dictionary A : B {};79 dictionary B : A {};80 """)81 results = parser.finish()82 except:83 threw = True84 harness.ok(threw, "Should not allow cycles in dictionary inheritance chains")85 parser = parser.reset()86 threw = False87 try:88 parser.parse("""89 dictionary A {90 [TreatNullAs=EmptyString] DOMString foo;91 };92 """)93 results = parser.finish()94 except:95 threw = True96 harness.ok(threw, "Should not allow [TreatNullAs] on dictionary members");97 parser = parser.reset()98 threw = False99 try:100 parser.parse("""101 dictionary A {102 };103 interface X {104 void doFoo(A arg);105 };106 """)107 results = parser.finish()108 except:109 threw = True110 harness.ok(threw, "Trailing dictionary arg must be optional")111 parser = parser.reset()112 threw = False113 try:114 parser.parse("""115 dictionary A {116 };117 interface X {118 void doFoo((A or DOMString) arg);119 };120 """)121 results = parser.finish()122 except:123 threw = True124 harness.ok(threw,125 "Trailing union arg containing a dictionary must be optional")126 parser = parser.reset()127 threw = False128 try:129 parser.parse("""130 dictionary A {131 };132 interface X {133 void doFoo(A arg1, optional long arg2);134 };135 """)136 results = parser.finish()137 except:138 threw = True139 harness.ok(threw, "Dictionary arg followed by optional arg must be optional")140 parser = parser.reset()141 threw = False142 try:143 parser.parse("""144 dictionary A {145 };146 interface X {147 void doFoo(A arg1, optional long arg2, long arg3);148 };149 """)150 results = parser.finish()151 except:152 threw = True153 harness.ok(not threw,154 "Dictionary arg followed by non-optional arg doesn't have to be optional")155 parser = parser.reset()156 threw = False157 try:158 parser.parse("""159 dictionary A {160 };161 interface X {162 void doFoo((A or DOMString) arg1, optional long arg2);163 };164 """)165 results = parser.finish()166 except:167 threw = True168 harness.ok(threw,169 "Union arg containing dictionary followed by optional arg must "170 "be optional")171 parser = parser.reset()172 parser.parse("""173 dictionary A {174 };175 interface X {176 void doFoo(A arg1, long arg2);177 };178 """)179 results = parser.finish()180 harness.ok(True, "Dictionary arg followed by required arg can be required")181 parser = parser.reset()182 threw = False183 try:184 parser.parse("""185 dictionary A {186 };187 interface X {188 void doFoo(optional A? arg1);189 };190 """)191 results = parser.finish()192 except:193 threw = True194 harness.ok(threw, "Dictionary arg must not be nullable")195 parser = parser.reset()196 threw = False197 try:198 parser.parse("""199 dictionary A {200 };201 interface X {202 void doFoo(optional (A or long)? arg1);203 };204 """)205 results = parser.finish()206 except:207 threw = True208 harness.ok(threw, "Dictionary arg must not be in a nullable union")209 parser = parser.reset()210 threw = False211 try:212 parser.parse("""213 dictionary A {214 };215 interface X {216 void doFoo(optional (A or long?) arg1);217 };218 """)219 results = parser.finish()220 except:221 threw = True222 harness.ok(threw,223 "Dictionary must not be in a union with a nullable type")224 parser = parser.reset()225 threw = False226 try:227 parser.parse("""228 dictionary A {229 };230 interface X {231 void doFoo(optional (long? or A) arg1);232 };233 """)234 results = parser.finish()235 except:236 threw = True237 harness.ok(threw,238 "A nullable type must not be in a union with a dictionary")239 parser = parser.reset()240 parser.parse("""241 dictionary A {242 };243 interface X {244 A? doFoo();245 };246 """)247 results = parser.finish()248 harness.ok(True, "Dictionary return value can be nullable")249 parser = parser.reset()250 parser.parse("""251 dictionary A {252 };253 interface X {254 void doFoo(optional A arg);255 };256 """)257 results = parser.finish()258 harness.ok(True, "Dictionary arg should actually parse")259 parser = parser.reset()260 parser.parse("""261 dictionary A {262 };263 interface X {264 void doFoo(optional (A or DOMString) arg);265 };266 """)267 results = parser.finish()268 harness.ok(True, "Union arg containing a dictionary should actually parse")269 parser = parser.reset()270 threw = False271 try:272 parser.parse("""273 dictionary Foo {274 Foo foo;275 };276 """)277 results = parser.finish()278 except:279 threw = True280 harness.ok(threw, "Member type must not be its Dictionary.")281 parser = parser.reset()282 threw = False283 try:284 parser.parse("""285 dictionary Foo3 : Foo {286 short d;287 };288 dictionary Foo2 : Foo3 {289 boolean c;290 };291 dictionary Foo1 : Foo2 {292 long a;293 };294 dictionary Foo {295 Foo1 b;296 };297 """)298 results = parser.finish()299 except:300 threw = True301 harness.ok(threw, "Member type must not be a Dictionary that "302 "inherits from its Dictionary.")303 parser = parser.reset()304 threw = False305 try:306 parser.parse("""307 dictionary Foo {308 (Foo or DOMString)[]? b;309 };310 """)311 results = parser.finish()312 except:313 threw = True314 harness.ok(threw, "Member type must not be a Nullable type "315 "whose inner type includes its Dictionary.")316 parser = parser.reset()317 threw = False318 try:319 parser.parse("""320 dictionary Foo {321 (DOMString or Foo) b;322 };323 """)324 results = parser.finish()325 except:326 threw = True327 harness.ok(threw, "Member type must not be a Union type, one of "328 "whose member types includes its Dictionary.")329 parser = parser.reset()330 threw = False331 try:332 parser.parse("""333 dictionary Foo {334 sequence<sequence<sequence<Foo>>> c;335 };336 """)337 results = parser.finish()338 except:339 threw = True340 harness.ok(threw, "Member type must not be a Sequence type "341 "whose element type includes its Dictionary.")342 parser = parser.reset()343 threw = False344 try:345 parser.parse("""346 dictionary Foo {347 (DOMString or Foo)[] d;348 };349 """)350 results = parser.finish()351 except:352 threw = True353 harness.ok(threw, "Member type must not be an Array type "354 "whose element type includes its Dictionary.")355 parser = parser.reset()356 threw = False357 try:358 parser.parse("""359 dictionary Foo {360 Foo1 b;361 };362 dictionary Foo3 {363 Foo d;364 };365 dictionary Foo2 : Foo3 {366 short c;367 };368 dictionary Foo1 : Foo2 {369 long a;370 };371 """)372 results = parser.finish()373 except:374 threw = True375 harness.ok(threw, "Member type must not be a Dictionary, one of whose "376 "members or inherited members has a type that includes "377 "its Dictionary.")378 parser = parser.reset();379 threw = False380 try:381 parser.parse("""382 dictionary Foo {383 };384 dictionary Bar {385 Foo? d;386 };387 """)388 results = parser.finish()389 except:390 threw = True391 harness.ok(threw, "Member type must not be a nullable dictionary")392 parser = parser.reset();393 parser.parse("""394 dictionary Foo {395 unrestricted float urFloat = 0;396 unrestricted float urFloat2 = 1.1;397 unrestricted float urFloat3 = -1.1;398 unrestricted float? urFloat4 = null;399 unrestricted float infUrFloat = Infinity;400 unrestricted float negativeInfUrFloat = -Infinity;401 unrestricted float nanUrFloat = NaN;402 unrestricted double urDouble = 0;403 unrestricted double urDouble2 = 1.1;404 unrestricted double urDouble3 = -1.1;405 unrestricted double? urDouble4 = null;406 unrestricted double infUrDouble = Infinity;407 unrestricted double negativeInfUrDouble = -Infinity;408 unrestricted double nanUrDouble = NaN;409 };410 """)411 results = parser.finish()412 harness.ok(True, "Parsing default values for unrestricted types succeeded.")413 parser = parser.reset();414 threw = False415 try:416 parser.parse("""417 dictionary Foo {418 double f = Infinity;419 };420 """)421 results = parser.finish()422 except:423 threw = True424 harness.ok(threw, "Only unrestricted values can be initialized to Infinity")425 parser = parser.reset();426 threw = False427 try:428 parser.parse("""429 dictionary Foo {430 double f = -Infinity;431 };432 """)433 results = parser.finish()434 except:435 threw = True436 harness.ok(threw, "Only unrestricted values can be initialized to -Infinity")437 parser = parser.reset();438 threw = False439 try:440 parser.parse("""441 dictionary Foo {442 double f = NaN;443 };444 """)445 results = parser.finish()446 except:447 threw = True448 harness.ok(threw, "Only unrestricted values can be initialized to NaN")449 parser = parser.reset();450 threw = False451 try:452 parser.parse("""453 dictionary Foo {454 float f = Infinity;455 };456 """)457 results = parser.finish()458 except:459 threw = True460 harness.ok(threw, "Only unrestricted values can be initialized to Infinity")461 parser = parser.reset();462 threw = False463 try:464 parser.parse("""465 dictionary Foo {466 float f = -Infinity;467 };468 """)469 results = parser.finish()470 except:471 threw = True472 harness.ok(threw, "Only unrestricted values can be initialized to -Infinity")473 parser = parser.reset();474 threw = False475 try:476 parser.parse("""477 dictionary Foo {478 float f = NaN;479 };480 """)481 results = parser.finish()482 except:483 threw = True...

Full Screen

Full Screen

dslListener.py

Source:dslListener.py Github

copy

Full Screen

1# Generated from dsl.g4 by ANTLR 4.82from antlr4 import *3if __name__ is not None and "." in __name__:4 from .dslParser import dslParser5else:6 from dslParser import dslParser7# This class defines a complete listener for a parse tree produced by dslParser.8class dslListener(ParseTreeListener):9 # Enter a parse tree produced by dslParser#twitbot.10 def enterTwitbot(self, ctx:dslParser.TwitbotContext):11 pass12 # Exit a parse tree produced by dslParser#twitbot.13 def exitTwitbot(self, ctx:dslParser.TwitbotContext):14 pass15 # Enter a parse tree produced by dslParser#stat.16 def enterStat(self, ctx:dslParser.StatContext):17 pass18 # Exit a parse tree produced by dslParser#stat.19 def exitStat(self, ctx:dslParser.StatContext):20 pass21 # Enter a parse tree produced by dslParser#action.22 def enterAction(self, ctx:dslParser.ActionContext):23 pass24 # Exit a parse tree produced by dslParser#action.25 def exitAction(self, ctx:dslParser.ActionContext):26 pass27 # Enter a parse tree produced by dslParser#tweet.28 def enterTweet(self, ctx:dslParser.TweetContext):29 pass30 # Exit a parse tree produced by dslParser#tweet.31 def exitTweet(self, ctx:dslParser.TweetContext):32 pass33 # Enter a parse tree produced by dslParser#tweet_required_parameter.34 def enterTweet_required_parameter(self, ctx:dslParser.Tweet_required_parameterContext):35 pass36 # Exit a parse tree produced by dslParser#tweet_required_parameter.37 def exitTweet_required_parameter(self, ctx:dslParser.Tweet_required_parameterContext):38 pass39 # Enter a parse tree produced by dslParser#tweet_optional_parameters.40 def enterTweet_optional_parameters(self, ctx:dslParser.Tweet_optional_parametersContext):41 pass42 # Exit a parse tree produced by dslParser#tweet_optional_parameters.43 def exitTweet_optional_parameters(self, ctx:dslParser.Tweet_optional_parametersContext):44 pass45 # Enter a parse tree produced by dslParser#tweetImage.46 def enterTweetImage(self, ctx:dslParser.TweetImageContext):47 pass48 # Exit a parse tree produced by dslParser#tweetImage.49 def exitTweetImage(self, ctx:dslParser.TweetImageContext):50 pass51 # Enter a parse tree produced by dslParser#tweet_image_required_parameter.52 def enterTweet_image_required_parameter(self, ctx:dslParser.Tweet_image_required_parameterContext):53 pass54 # Exit a parse tree produced by dslParser#tweet_image_required_parameter.55 def exitTweet_image_required_parameter(self, ctx:dslParser.Tweet_image_required_parameterContext):56 pass57 # Enter a parse tree produced by dslParser#reply.58 def enterReply(self, ctx:dslParser.ReplyContext):59 pass60 # Exit a parse tree produced by dslParser#reply.61 def exitReply(self, ctx:dslParser.ReplyContext):62 pass63 # Enter a parse tree produced by dslParser#reply_required_parameters.64 def enterReply_required_parameters(self, ctx:dslParser.Reply_required_parametersContext):65 pass66 # Exit a parse tree produced by dslParser#reply_required_parameters.67 def exitReply_required_parameters(self, ctx:dslParser.Reply_required_parametersContext):68 pass69 # Enter a parse tree produced by dslParser#retweet.70 def enterRetweet(self, ctx:dslParser.RetweetContext):71 pass72 # Exit a parse tree produced by dslParser#retweet.73 def exitRetweet(self, ctx:dslParser.RetweetContext):74 pass75 # Enter a parse tree produced by dslParser#retweet_required_parameter.76 def enterRetweet_required_parameter(self, ctx:dslParser.Retweet_required_parameterContext):77 pass78 # Exit a parse tree produced by dslParser#retweet_required_parameter.79 def exitRetweet_required_parameter(self, ctx:dslParser.Retweet_required_parameterContext):80 pass81 # Enter a parse tree produced by dslParser#favourite.82 def enterFavourite(self, ctx:dslParser.FavouriteContext):83 pass84 # Exit a parse tree produced by dslParser#favourite.85 def exitFavourite(self, ctx:dslParser.FavouriteContext):86 pass87 # Enter a parse tree produced by dslParser#favourite_required_parameter.88 def enterFavourite_required_parameter(self, ctx:dslParser.Favourite_required_parameterContext):89 pass90 # Exit a parse tree produced by dslParser#favourite_required_parameter.91 def exitFavourite_required_parameter(self, ctx:dslParser.Favourite_required_parameterContext):92 pass93 # Enter a parse tree produced by dslParser#scheduleTweet.94 def enterScheduleTweet(self, ctx:dslParser.ScheduleTweetContext):95 pass96 # Exit a parse tree produced by dslParser#scheduleTweet.97 def exitScheduleTweet(self, ctx:dslParser.ScheduleTweetContext):98 pass99 # Enter a parse tree produced by dslParser#schedule_tweet_required_parameter.100 def enterSchedule_tweet_required_parameter(self, ctx:dslParser.Schedule_tweet_required_parameterContext):101 pass102 # Exit a parse tree produced by dslParser#schedule_tweet_required_parameter.103 def exitSchedule_tweet_required_parameter(self, ctx:dslParser.Schedule_tweet_required_parameterContext):104 pass105 # Enter a parse tree produced by dslParser#date_time_parameter.106 def enterDate_time_parameter(self, ctx:dslParser.Date_time_parameterContext):107 pass108 # Exit a parse tree produced by dslParser#date_time_parameter.109 def exitDate_time_parameter(self, ctx:dslParser.Date_time_parameterContext):110 pass111 # Enter a parse tree produced by dslParser#minute.112 def enterMinute(self, ctx:dslParser.MinuteContext):113 pass114 # Exit a parse tree produced by dslParser#minute.115 def exitMinute(self, ctx:dslParser.MinuteContext):116 pass117 # Enter a parse tree produced by dslParser#hour.118 def enterHour(self, ctx:dslParser.HourContext):119 pass120 # Exit a parse tree produced by dslParser#hour.121 def exitHour(self, ctx:dslParser.HourContext):122 pass123 # Enter a parse tree produced by dslParser#day_of_month.124 def enterDay_of_month(self, ctx:dslParser.Day_of_monthContext):125 pass126 # Exit a parse tree produced by dslParser#day_of_month.127 def exitDay_of_month(self, ctx:dslParser.Day_of_monthContext):128 pass129 # Enter a parse tree produced by dslParser#month.130 def enterMonth(self, ctx:dslParser.MonthContext):131 pass132 # Exit a parse tree produced by dslParser#month.133 def exitMonth(self, ctx:dslParser.MonthContext):134 pass135 # Enter a parse tree produced by dslParser#numeric_month.136 def enterNumeric_month(self, ctx:dslParser.Numeric_monthContext):137 pass138 # Exit a parse tree produced by dslParser#numeric_month.139 def exitNumeric_month(self, ctx:dslParser.Numeric_monthContext):140 pass141 # Enter a parse tree produced by dslParser#numeric_day.142 def enterNumeric_day(self, ctx:dslParser.Numeric_dayContext):143 pass144 # Exit a parse tree produced by dslParser#numeric_day.145 def exitNumeric_day(self, ctx:dslParser.Numeric_dayContext):146 pass147 # Enter a parse tree produced by dslParser#numeric_hour.148 def enterNumeric_hour(self, ctx:dslParser.Numeric_hourContext):149 pass150 # Exit a parse tree produced by dslParser#numeric_hour.151 def exitNumeric_hour(self, ctx:dslParser.Numeric_hourContext):152 pass153 # Enter a parse tree produced by dslParser#numeric_minute.154 def enterNumeric_minute(self, ctx:dslParser.Numeric_minuteContext):155 pass156 # Exit a parse tree produced by dslParser#numeric_minute.157 def exitNumeric_minute(self, ctx:dslParser.Numeric_minuteContext):158 pass159 # Enter a parse tree produced by dslParser#directMessage.160 def enterDirectMessage(self, ctx:dslParser.DirectMessageContext):161 pass162 # Exit a parse tree produced by dslParser#directMessage.163 def exitDirectMessage(self, ctx:dslParser.DirectMessageContext):164 pass165 # Enter a parse tree produced by dslParser#direct_message_required_parameters.166 def enterDirect_message_required_parameters(self, ctx:dslParser.Direct_message_required_parametersContext):167 pass168 # Exit a parse tree produced by dslParser#direct_message_required_parameters.169 def exitDirect_message_required_parameters(self, ctx:dslParser.Direct_message_required_parametersContext):170 pass171 # Enter a parse tree produced by dslParser#autoFavouriteRetweet.172 def enterAutoFavouriteRetweet(self, ctx:dslParser.AutoFavouriteRetweetContext):173 pass174 # Exit a parse tree produced by dslParser#autoFavouriteRetweet.175 def exitAutoFavouriteRetweet(self, ctx:dslParser.AutoFavouriteRetweetContext):176 pass177 # Enter a parse tree produced by dslParser#autoFollowFollowers.178 def enterAutoFollowFollowers(self, ctx:dslParser.AutoFollowFollowersContext):179 pass180 # Exit a parse tree produced by dslParser#autoFollowFollowers.181 def exitAutoFollowFollowers(self, ctx:dslParser.AutoFollowFollowersContext):182 pass183 # Enter a parse tree produced by dslParser#autoReplyMentions.184 def enterAutoReplyMentions(self, ctx:dslParser.AutoReplyMentionsContext):185 pass186 # Exit a parse tree produced by dslParser#autoReplyMentions.187 def exitAutoReplyMentions(self, ctx:dslParser.AutoReplyMentionsContext):188 pass189 # Enter a parse tree produced by dslParser#automateReplyParameter.190 def enterAutomateReplyParameter(self, ctx:dslParser.AutomateReplyParameterContext):191 pass192 # Exit a parse tree produced by dslParser#automateReplyParameter.193 def exitAutomateReplyParameter(self, ctx:dslParser.AutomateReplyParameterContext):194 pass195 # Enter a parse tree produced by dslParser#keyword.196 def enterKeyword(self, ctx:dslParser.KeywordContext):197 pass198 # Exit a parse tree produced by dslParser#keyword.199 def exitKeyword(self, ctx:dslParser.KeywordContext):200 pass201 # Enter a parse tree produced by dslParser#stringValue.202 def enterStringValue(self, ctx:dslParser.StringValueContext):203 pass204 # Exit a parse tree produced by dslParser#stringValue.205 def exitStringValue(self, ctx:dslParser.StringValueContext):206 pass207 # Enter a parse tree produced by dslParser#number.208 def enterNumber(self, ctx:dslParser.NumberContext):209 pass210 # Exit a parse tree produced by dslParser#number.211 def exitNumber(self, ctx:dslParser.NumberContext):212 pass213 # Enter a parse tree produced by dslParser#unary_operator.214 def enterUnary_operator(self, ctx:dslParser.Unary_operatorContext):215 pass216 # Exit a parse tree produced by dslParser#unary_operator.217 def exitUnary_operator(self, ctx:dslParser.Unary_operatorContext):218 pass219 # Enter a parse tree produced by dslParser#unsigned_number.220 def enterUnsigned_number(self, ctx:dslParser.Unsigned_numberContext):221 pass222 # Exit a parse tree produced by dslParser#unsigned_number.223 def exitUnsigned_number(self, ctx:dslParser.Unsigned_numberContext):224 pass225 # Enter a parse tree produced by dslParser#boolean.226 def enterBoolean(self, ctx:dslParser.BooleanContext):227 pass228 # Exit a parse tree produced by dslParser#boolean.229 def exitBoolean(self, ctx:dslParser.BooleanContext):230 pass...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest(url, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status:', data.statusText);6 console.log('Waiting for test results...');7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('Test results:', data);10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org');14wpt.runTest(url, function(err, data) {15 if (err) return console.error(err);16 console.log('Test status:', data.statusText);17 console.log('Waiting for test results...');18 wpt.getTestResults(data.data.testId, function(err, data) {19 if (err) return console.error(err);20 console.log('Test results:', data);21 });22});23Test results: { responseCode: 200,24 { testId: '150505_6B_2',25 statusText: 'Ok' }26Test results: { responseCode: 200,27 { testId: '150505_6B_3',

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Albert Einstein');3wp.get(function(err, info) {4 if (err) {5 console.log(err);6 } else {7 console.log(info);8 }9});10var wptools = require('wptools');11var wp = wptools.page('Albert Einstein').get(function(err, info) {12 if (err) {13 console.log(err);14 } else {15 console.log(info);16 }17});18var wptools = require('wptools');19var wp = wptools.page('Albert Einstein').get(function(err, info) {20 if (err) {21 console.log(err);22 } else {23 console.log(info);24 }25});26var wptools = require('wptools');27var wp = wptools.page('Albert_Einstein').get(function(err, info) {28 if (err) {29 console.log(err);30 } else {31 console.log(info);32 }33});34var wptools = require('wptools');35var wp = wptools.page('Albert Einstein').get(function(err, info) {36 if (err) {37 console.log(err);38 } else {39 console.log(info);40 }41});42var wptools = require('wptools');43var wp = wptools.page('Albert Einstein').get(function(err, info) {44 if (err) {45 console.log(err);46 } else {47 console.log(info);48 }49});50var wptools = require('wptools');51var wp = wptools.page('Albert Einstein').get(function(err, info) {52 if (err) {53 console.log(err);54 } else {55 console.log(info);56 }57});58var wptools = require('wptools');

Full Screen

Using AI Code Generation

copy

Full Screen

1var Parser = require('wptoolkit').Parser;2var parser = new Parser();3parser.parse('test.wiki', function(err, result) {4 if (err) {5 console.log(err);6 } else {7 console.log(result);8 }9});10var Parser = require('wptoolkit').Parser;11var parser = new Parser();12parser.parse('test.wiki', function(err, result) {13 if (err) {14 console.log(err);15 } else {16 console.log(result);17 }18});19var Parser = require('wptoolkit').Parser;20var parser = new Parser();21parser.parse('test.wiki', function(err, result) {22 if (err) {23 console.log(err);24 } else {25 console.log(result);26 }27});28var Parser = require('wptoolkit').Parser;29var parser = new Parser();30parser.parse('test.wiki', function(err, result) {31 if (err) {32 console.log(err);33 } else {34 console.log(result);35 }36});37var Parser = require('wptoolkit').Parser;38var parser = new Parser();39parser.parse('test.wiki', function(err, result) {40 if (err) {41 console.log(err);42 } else {43 console.log(result);44 }45});46var Parser = require('wptoolkit').Parser;47var parser = new Parser();48parser.parse('test.wiki', function(err, result) {49 if (err) {50 console.log(err);51 } else {52 console.log(result);53 }54});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var page = wptools.page('Albert Einstein');4page.get(function(err, infobox) {5 if (err) {6 console.log(err);7 } else {8 fs.writeFile("test.json", JSON.stringify(infobox), function(err) {9 if (err) {10 return console.log(err);11 }12 console.log("The file was saved!");13 });14 }15});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var parser = new wptools.Parser();3var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');4console.log(data);5var wptools = require('wptools');6var parser = new wptools.Parser();7var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');8console.log(data);9var wptools = require('wptools');10var parser = new wptools.Parser();11var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');12console.log(data);13var wptools = require('wptools');14var parser = new wptools.Parser();15var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');16console.log(data);17var wptools = require('wptools');18var parser = new wptools.Parser();19var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');20console.log(data);21var wptools = require('wptools');22var parser = new wptools.Parser();23var data = parser.parse('[[File:Example.jpg|thumb|alt=|left|caption]]');24console.log(data);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpToolkit = require('wptoolkit');2var parser = new wpToolkit.Parser('en');3parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {4 console.log(data);5});6var wpToolkit = require('wptoolkit');7var parser = new wpToolkit.Parser('en');8parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {9 console.log(data);10});11var wpToolkit = require('wptoolkit');12var parser = new wpToolkit.Parser('en');13parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {14 console.log(data);15});16var wpToolkit = require('wptoolkit');17var parser = new wpToolkit.Parser('en');18parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {19 console.log(data);20});21var wpToolkit = require('wptoolkit');22var parser = new wpToolkit.Parser('en');23parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {24 console.log(data);25});26var wpToolkit = require('wptoolkit');27var parser = new wpToolkit.Parser('en');28parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function(err, data) {29 console.log(data);30});31var wpToolkit = require('wptoolkit');32var parser = new wpToolkit.Parser('en');33parser.parse('[[File:Wikipedia-logo-v2.svg|thumb|right|220px|Wikipedia]]', function

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful