New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lc2-compiler

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lc2-compiler - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

12

dist/bundle.js

@@ -8,20 +8,20 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.LCP = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

},{}],3:[function(require,module,exports){
'use strict';const reserve=['in','by','to'],actions=['click','input','rclick','dblclick','movein','moveout','scroll','select','check','uncheck','jumpto','refresh'],macros=['TIMES','INTERVAL','SCREEN','AUTOWAIT','AUTOCAPTURE'],keywords=['wait','assert','log','console','process','return','true','false','if','else','while'].concat(reserve).concat(actions),keywordRegexp=new RegExp('^('+keywords.join('|')+')$'),macroRegexp=new RegExp('^('+macros.join('|')+')$');function isIdentifierStart(a){return 65>a?36==a:!!(91>a)||(97>a?95==a:123>a)}function isIdentifierChar(a){return 48>a?36==a:!!(58>a)||!(65>a)&&(!!(91>a)||(97>a?95==a:123>a))}module.exports={keywordRegexp,macroRegexp,isIdentifierStart,isIdentifierChar};
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.isIdentifierStart=isIdentifierStart;exports.isIdentifierChar=isIdentifierChar;const reserve=['in','by','to'],actions=['click','input','rclick','dblclick','movein','moveout','scroll','select','check','uncheck','jumpto','refresh'],macros=['TIMES','INTERVAL','SCREEN','AUTOWAIT','AUTOCAPTURE'],keywords=['wait','assert','log','console','process','return','true','false','if','else','while'].concat(reserve).concat(actions);const keywordRegexp=exports.keywordRegexp=new RegExp('^('+keywords.join('|')+')$');const macroRegexp=exports.macroRegexp=new RegExp('^('+macros.join('|')+')$');function isIdentifierStart(a){return 65>a?36==a:!!(91>a)||(97>a?95==a:123>a)}function isIdentifierChar(a){return 48>a?36==a:!!(58>a)||!(65>a)&&(!!(91>a)||(97>a?95==a:123>a))}
},{}],4:[function(require,module,exports){
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.Parser=exports.pluginTable=void 0;var _options=require('./options'),_locutil=require('./locutil'),_tokentype=require('./tokentype'),_identifier=require('./identifier'),_whitespace=require('./whitespace'),_ast=require('./ast'),_ast2=_interopRequireDefault(_ast);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}const pluginTable=exports.pluginTable={};class Parser{constructor(a,b){this.options=a=(0,_options.getOptions)(a),this.keywords=_identifier.keywordRegexp,this.macros=_identifier.macroRegexp,this.input=b+'',this.loadPlugins(a.pluginList),this.pos=0,this.type=_tokentype.types.eof,this.value=null,this.start=this.end=this.pos,this.lastTokStart=this.lastTokEnd=this.pos,this.exprAllowed=!1,this.genAllowed=!1,this.labels=[],this.conf={},this.keys={},this.nextID=0,this.pcs={},this.pcsTable={},this.inTag=!1}extend(a,b){this[a]=b(this[a])}loadPlugins(a){a.forEach(b=>{const c=pluginTable[b];if(!c)throw new Error('Plugin ['+b+'] not found');c(this,b)})}parse(){this.nextToken();let a={CONFIG:this.conf,DATA_KEYS:this.keys,PROCESSES:this.pcs};return this.parseTopLevel(a)}raise(a,b){const c=(0,_locutil.getLineInfo)(this.input,a);b+=' ('+c.line+':'+c.column+')';const d=this.options.left,f=this.options.right;b=d||f?d+b+f:(0,_locutil.empowerErrMsg)(this.input,c,b);const g=this.pos;throw new _locutil.Lc2SyntaxError(b,a,c,g)}next(){this.lastTokEnd=this.end,this.lastTokStart=this.start,this.nextToken()}nextToken(){return this.skipSpace(),this.start=this.pos,this.pos>=this.input.length?this.finishToken(_tokentype.types.eof):void this.readToken(this.fullCharCodeAtPos())}readToken(a){return(0,_identifier.isIdentifierStart)(a)?this.readWord():this.getTokenFromCode(a)}fullCharCodeAtPos(){const a=this.input.charCodeAt(this.pos);if(55295>=a||57344<=a)return a;const b=this.input.charCodeAt(this.pos+1);return(a<<10)+b-56613888}skipBlockComment(){let a=this.pos,b=this.input.indexOf('*/',this.pos+=2);-1===b&&this.raise(this.pos-2,'unterminated comment'),this.pos=b+2,this.options.onComment&&this.options.onComment(!0,this.input.slice(a+2,b),a,this.pos)}skipLineComment(a){let b=this.pos,c=this.input.charCodeAt(this.pos+=a);for(;this.pos<this.input.length&&10!==c&&13!==c&&8232!==c&&8233!==c;)++this.pos,c=this.input.charCodeAt(this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(b+=a,this.pos),b,this.pos)}skipSpace(){loop:for(;this.pos<this.input.length;){let a=this.input.charCodeAt(this.pos);switch(a){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++this.pos;case 10:case 8232:case 8233:++this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:}break;default:if(8<a&&14>a)++this.pos;else break loop;}}}readTokenSlash(){const a=this.input.charCodeAt(this.pos+1);return this.exprAllowed||this.genAllowed?(++this.pos,this.readRegexp(this.genAllowed)):61===a?this.finishOp(_tokentype.types.assign,2):62===a?this.finishOp(_tokentype.types.tagR,2):this.finishOp(_tokentype.types.slash,1)}readTokenMultModuloExp(a){const b=this.input.charCodeAt(this.pos+1),c=1,d=42===a?_tokentype.types.star:_tokentype.types.modulo;return 61===b?this.finishOp(_tokentype.types.assign,c+1):this.finishOp(d,c)}readTokenPipeAmp(a){const b=this.input.charCodeAt(this.pos+1);return b===a?this.finishOp(124===a?_tokentype.types.logicalOR:_tokentype.types.logicalAND,2):124===a?this.finishOp(_tokentype.types.pipe,1):void this.raise(this.pos,'bitwise operator is not allowed')}readTokenPlusMin(a){const b=this.input.charCodeAt(this.pos+1);return b===a?this.finishOp(_tokentype.types.incDec,2):61===b?this.finishOp(_tokentype.types.assign,2):this.finishOp(_tokentype.types.plusMin,1)}readTokenLtGt(a){const b=this.input.charCodeAt(this.pos+1);let c=1;if(b===a&&this.raise(this.pos,'bitwise operator is not allowed'),60===a){if(35===b)return this.finishOp(_tokentype.types.tagNumL,2);if(64===b)return this.finishOp(_tokentype.types.tagAtL,2);if(33===b)return this.finishOp(_tokentype.types.tagFacL,2)}return 61===b&&(c=2),this.finishOp(_tokentype.types.relational,c)}readTokenEqExcl(a){const b=this.input.charCodeAt(this.pos+1);return 126===b&&33===a?this.finishOp(_tokentype.types.match,2):61===b?this.finishOp(_tokentype.types.equality,61===this.input.charCodeAt(this.pos+2)?3:2):this.finishOp(61===a?_tokentype.types.eq:_tokentype.types.prefix,1)}getTokenFromCode(a){switch(a){case 35:return++this.pos,this.readMacro();case 40:return++this.pos,this.finishToken(_tokentype.types.parenL);case 41:return++this.pos,this.finishToken(_tokentype.types.parenR);case 59:return++this.pos,this.finishToken(_tokentype.types.semi);case 44:return++this.pos,this.finishToken(_tokentype.types.comma);case 91:return++this.pos,this.finishToken(_tokentype.types.bracketL);case 93:return++this.pos,this.finishToken(_tokentype.types.bracketR);case 123:return++this.pos,this.finishToken(_tokentype.types.braceL);case 125:return++this.pos,this.finishToken(_tokentype.types.braceR);case 58:return++this.pos,this.finishToken(_tokentype.types.colon);case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(a);case 47:return this.readTokenSlash();case 37:case 42:return this.readTokenMultModuloExp(a);case 124:case 38:return this.readTokenPipeAmp(a);case 43:case 45:return this.readTokenPlusMin(a);case 60:case 62:return this.readTokenLtGt(a);case 61:case 33:return this.readTokenEqExcl(a);case 126:var b=this.input.charCodeAt(this.pos+1);return 126!==b&&this.raise(this.pos,'bitwise operator is not allowed'),this.finishOp(_tokentype.types.match,2);default:this.raise(this.pos,'Unexpected character "'+this.input[this.pos]+'"');}}finishOp(a,b){const c=this.input.slice(this.pos,this.pos+=b);return this.finishToken(a,c)}finishToken(a,b){this.end=this.pos,this.type=a,this.value=b,this.genAllowed=a.beforeGen,this.exprAllowed=a.beforeExpr}readRegexp(a){let b,c,d=this.pos;for(;;){this.pos>=this.input.length&&this.raise(d,'Unterminated regular expression');let h=this.input.charAt(this.pos);if(_whitespace.lineBreak.test(h)&&this.raise(d,'Unterminated regular expression'),b)b=!1;else{if('['===h)c=!0;else if(']'===h&&c)c=!1;else if('/'===h&&!c)break;b='\\'===h}++this.pos}const f=this.input.slice(d,this.pos);++this.pos;const g=this.readWord1();if(g){let h=/^[gim]*$/;h.test(g)||this.raise(d,'Invalid regular expression flag')}return this.finishToken(_tokentype.types.regexp,{pattern:f,flags:g,isGenerate:a})}readInt(a,b=null){let c=this.pos,d=0;for(let f=0,g=null===b?1/0:b;f<g;++f){let j,h=this.fullCharCodeAtPos();if(j=97<=h?h-97+10:65<=h?h-65+10:48<=h&&57>=h?h-48:1/0,j>=a)break;++this.pos,d=d*a+j}return this.pos===c||null!==b&&this.pos-c!==b?null:d}readNumber(a){let b=this.pos,c=!1;a||null!==this.readInt(10)||this.raise(b,'Invalid Number');let d=this.fullCharCodeAtPos();46===d&&(++this.pos,this.readInt(10),c=!0,d=this.fullCharCodeAtPos()),(69===d||101===d)&&(d=this.input.charCodeAt(++this.pos),(43===d||45===d)&&++this.pos,null===this.readInt(10)&&this.raise(b,'Invalid number'),c=!0),(0,_identifier.isIdentifierStart)(this.fullCharCodeAtPos())&&this.raise(this.pos,'Identifier directly after number');let g,f=this.input.slice(b,this.pos);return g=c?parseFloat(f):parseInt(f,10),this.finishToken(_tokentype.types.num,g)}readString(a){let b='',c=this.start,d=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(c,'Unterminated string');let f=this.fullCharCodeAtPos();if(f===a)break;92===f?(b+=this.input.slice(d,this.pos),b+=this.readEscapedChar(),d=this.pos):((0,_whitespace.isNewLine)(f)&&this.raise(c,'Unterminated string'),++this.pos)}return b+=this.input.slice(d,this.pos++),this.finishToken(_tokentype.types.string,b)}readEscapedChar(){const a=this.input.charCodeAt(++this.pos);switch(++this.pos,a){case 110:return'\n';case 114:return'\r';case 116:return'\t';case 98:return'\b';case 118:return'\x0B';case 102:return'\f';case 13:10===this.fullCharCodeAtPos()&&++this.pos;case 10:return'';default:return String.fromCharCode(a);}}readWord1(){let a='',b=this.pos;for(;this.pos<this.input.length;){let c=this.fullCharCodeAtPos();if((0,_identifier.isIdentifierChar)(c))++this.pos;else break}return a+=this.input.slice(b,this.pos),a}readWord(){const a=this.readWord1(),b=this.keywords.test(a)?_tokentype.keywordTypes[a]:_tokentype.types.name;return this.finishToken(b,a)}readMacro(){var a=this.pos,b=this.readWord1();this.macros.test(b)||this.raise(a,'invalid macros');for(var c=_tokentype.keywordTypes[b],d=this.pos,f=this.fullCharCodeAtPos();this.pos<this.input.length&&10!==f&&13!==f&&8232!==f&&8233!==f;)++this.pos,f=this.input.charCodeAt(this.pos);var g=this.input.slice(d,this.pos).trim();return this.finishToken(c,g)}parseTopLevel(a){let b=this.pcsTable;for(b.main={pos:0};this.type!==_tokentype.types.eof;)this.parseStructure();for(var c in b)b[c]&&this.raise(b[c].pos,'Invalid process call at');return a}parseStructure(){const a=this.type;return a.macro?this.parseSet():a===_tokentype.types._process?this.parseProcess():void this.raise(this.start,'Expect a macro or process')}parseSet(){const a=this.type;a.macro||this.unexpected();const b=a.label.toLowerCase();this.writeConfig(b),this.next()}writeConfig(a){let b;const c=this.conf;c[a]&&this.raise(this.start,this.type.keyword+' was defined already');let d,f,g=this.value.split(',');'screen'===a?(2!==g.length&&this.raise('Invalid arguments'),d=~~parseInt(g[0],10),f=~~parseInt(g[1],10),b={width:d,height:f}):'autoscroll'===a||'autocapture'===a||'autowait'===a?b=!0:b=parseInt(this.value,10);c[a]=b}parseProcess(){let a={LINE:(0,_locutil.getLineInfo)(this.input,this.start),TYPE:_ast2.default.PROCESS,BODY:{}},b=this.pcs,c=this.pcsTable;this.next();const d=this.parseIndent().name;b[d]&&this.raise(this.start,d+' process was defined already'),b[d]=a,c[d]=!1,this.parsePcParam(a),this.parsePcBlock(a)}parsePcParam(a){this.eat(_tokentype.types.parenL)&&(a.BODY.params=this.parseBindingList(_tokentype.types.parenR,!1,!1))}parsePcBlock(a){const b=this.parseBlock();b.push({LINE:-1,TYPE:_ast2.default.RETURN}),a.BODY.segment=b}parseBlock(){this.expect(_tokentype.types.braceL);const a=[];for(;!this.eat(_tokentype.types.braceR);){const b=this.parseStatement(!0);a.push(b)}return a}parseStatement(){let a=this.type,b=this.startNode();return a===_tokentype.types._click||a===_tokentype.types._rclick||a===_tokentype.types._dblclick||a===_tokentype.types._movein||a===_tokentype.types._moveout?this.parseMouseAction(b,a.keyword):a===_tokentype.types._select?this.parseSelectAction(b):a===_tokentype.types._scroll?this.parseScrollAction(b,a.keyword):a===_tokentype.types._input?this.parseInputAction(b,a.keyword):a===_tokentype.types._check||a===_tokentype.types._uncheck?this.parseCheck(b,a.keyword):a===_tokentype.types._return?this.parseReturnStatement(b):a===_tokentype.types._wait?this.parseWaitStatement(b):a===_tokentype.types._assert?this.parseAssertStatement(b):a===_tokentype.types._log||a===_tokentype.types._console?this.parseLogStatement(b,_ast2.default.LOG):a===_tokentype.types._jumpto?this.parseGotoStatement(b):a===_tokentype.types._refresh?this.parseRefreshStatement(b):a===_tokentype.types.name?this.parseExprStatement(b):a===_tokentype.types._if?this.parseIfStatement(b):a===_tokentype.types._while?this.parseWhileStatement(b):a===_tokentype.types.braceL?this.parseBlock():this.parseEvaluation(b)}parseReturnStatement(a){return this.next(),this.eat(_tokentype.types.semi),this.finishNode(a,_ast2.default.RETURN)}parseVarStatement(a){return this.next(),this.parseVar(a),this.semicolon(),this.finishNode(a,_ast2.default.EXPRESSION)}parseVar(a){const b=[];for(;;){let c={};if(c.id=this.parseIndent().name,c.init=this.eat(_tokentype.types.eq)?this.parseMaybeAssign():null,b.push(c),!this.eat(_tokentype.types.comma))break}a.BODY.raw={declarations:b,type:'varDecl'}}parseExprStatement(a){const b=this.parseExpression();if(this.semicolon(),'CallExpr'===b.type){var c=b.callee.name;return!1!==this.pcsTable[c]&&(this.pcsTable[c]={pos:this.lastTokStart}),a.BODY.identifier=c,this.finishNode(a,_ast2.default.CALL)}return a.BODY.raw=b,this.finishNode(a,_ast2.default.EXPRESSION)}parseEvaluation(a){const b=this.parseExpression();return this.semicolon(),a.BODY.raw=b,this.finishNode(a,_ast2.default.EXPRESSION)}parseWaitStatement(a){return this.next(),a.BODY.raw=this.parseExpression(),this.semicolon(),this.finishNode(a,_ast2.default.WAIT)}parseMouseAction(a,b){if(this.next(),a.BODY.raw=this.parseExpression(),a.BODY.action=b,this.eat(_tokentype.types._to)){let c,d;c=this.parseMaybeAssign(),this.expect(_tokentype.types.comma),d=this.parseMaybeAssign(),a.BODY.posX=c,a.BODY.posY=d}return this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseScrollAction(a,b){return this.next(),a.BODY.raw=this.parseExpression(),this.expect(_tokentype.types._by),a.BODY.raw1=this.parseExpression(),a.BODY.action=b,this.finishNode(a,_ast2.default.TRIGGER)}parseSelectAction(a){return this.next(),a.BODY.raw=this.parseExpression(),this.expect(_tokentype.types._by),a.BODY.raw1=this.parseExpression(),a.BODY.action='select',this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseInputAction(a,b){return this.next(),a.BODY.raw=this.parseExpression(),this.expect(_tokentype.types._by),a.BODY.raw1=this.parseExpression(),a.BODY.action=b,this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseCheck(a,b){return this.next(),a.BODY.raw=this.parseExpression(),a.BODY.action=b,this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseAssertStatement(a){return this.next(),a.BODY.raw=this.parseExpression(),this.eat(_tokentype.types._in)&&(this.type===_tokentype.types.num?a.BODY.timeout=this.value:this.unexpected(),this.next()),this.semicolon(),a.BODY.key=this.getUID('#'),this.keys[a.BODY.key]=!!a.BODY.timeout,this.finishNode(a,_ast2.default.ASSERT)}parseGotoStatement(a){return this.next(),a.BODY.raw=this.parseExpression(),this.semicolon(),this.finishNode(a,_ast2.default.JUMPTO)}parseRefreshStatement(a){return this.next(),this.semicolon(),this.finishNode(a,_ast2.default.REFRESH)}parseLogStatement(a,b){return this.next(),a.BODY.raw=this.parseExpression(),this.semicolon(),this.finishNode(a,b)}parseIfStatement(a){return this.next(),a.test=this.parseExpression(),a.consequent=this.parseBlock(),a.alternate=this.eat(_tokentype.types._else)?this.parseStatement():null,this.finishNode(a,'If')}parseWhileStatement(a){return this.next(),a.test=this.parseExpression(),a.body=this.parseStatement(),this.finishNode(a,'While')}startNode(){return{LINE:(0,_locutil.getLineInfo)(this.input,this.start).line,TYPE:0,BODY:{},start:this.start,end:0}}finishNode(a,b){return a.TYPE=b,a.end=this.lastTokEnd,a}eat(a){return this.type===a&&(this.next(),!0)}semicolon(){this.eat(_tokentype.types.semi)||this.expected(_tokentype.types.semi)}expect(a){return this.eat(a)||this.expected(a)}unexpected(a=this.start){this.raise(a,'Unexpected token')}expected(a){this.raise(this.lastTokEnd,'Expect a "'+a.label+'" after')}getUID(a){return a+this.nextID++}parseExpression(){var a=this.parseMaybeAssign();if(this.type===_tokentype.types.comma){var b={type:'SequenceExpr'};for(b.expressions=[a];this.eat(_tokentype.types.comma);){var c=this.parseMaybeAssign();b.expressions.push(c)}return b}return a}parseMaybeAssign(){var a=this.parseMaybeConditional();if(this.type.isAssign){var b={type:'AssignmentExpr',left:a,operator:this.value};return this.next(),b.right=this.parseMaybeAssign(),b}return a}parseMaybeConditional(){return this.parseExprOps()}parseExprOps(){var a=this.start,b=this.parseMaybeUnary(!1);return this.parseExprOp(b,a,-1)}parseExprOp(a,b,c){var d=this.type.binop;if(null!==d&&d>c){var f=this.type,g=this.value;this.next();var h=this.start,j=this.parseExprOp(this.parseMaybeUnary(!1),h,d),k=this.buildBinary(a,j,g,f);return this.parseExprOp(k,b,c)}return a}buildBinary(a,b,c,d){var f={left:a,operator:c,right:b};return f.type=d===_tokentype.types.logicalAND||d===_tokentype.types.logicalOR?'LogicalExpr':d===_tokentype.types.match?'MatchExpr':'BinaryExpr',f}parseMaybeUnary(){let a;if(this.type.prefix){const b={},c=this.type===_tokentype.types.incDec;b.operator=this.value,b.prefix=!0,this.next(),b.argument=this.parseMaybeUnary(!1),b.type=c?'UpdateExpr':'UnaryExpr',a=b}else for(a=this.parseExprSubscripts();this.type.postfix;){let b={};b.operator=this.value,b.prefix=!1,b.argument=a,this.next(),b.type='UpdateExpr',a=b}return a}parseExprSubscripts(){var a=this.parseExprAtom();return this.parseSubscripts(a)}parseSubscripts(a){for(;;){if(this.eat(_tokentype.types.parenL)){let b={type:'CallExpr',callee:a};return this.expect(_tokentype.types.parenR),b}if(this.eat(_tokentype.types.pipe)){let b={type:'FilterExpr',object:a,filter:this.parseIndent().name};this.expect(_tokentype.types.parenL),b.params=this.parseExprList(_tokentype.types.parenR,!1,!1),a=b}else return a}}parseExprAtom(){let a;switch(this.type){case _tokentype.types.name:return this.parseIndent(this.type!==_tokentype.types.name);case _tokentype.types.regexp:var b=this.value;return a=this.parseLiteral('regexp'),a.regexp=b,a;case _tokentype.types.num:case _tokentype.types.string:return this.parseLiteral('literal',this.value);case _tokentype.types._true:case _tokentype.types._false:return this.parseLiteral('literal',this.value);case _tokentype.types.objectAt:case _tokentype.types.dict:return this.parseExtLiteral(this.type);case _tokentype.types.parenL:return this.parseParenExpression();case _tokentype.types.tagAtL:case _tokentype.types.tagNumL:case _tokentype.types.tagFacL:return this.parseTagExpression();default:return this.inTag?this.raise(this.lastTokStart,'(missing `/` before `>` ?) Unexpected token'):this.unexpected();}}parseLiteral(a,b){var c={type:a,value:b,raw:this.input.slice(this.start,this.end)};return this.next(),c}parseExtLiteral(a){var b={type:a.label,value:this.value};return this.next(),b}parseParenExpression(){this.expect(_tokentype.types.parenL);var a=this.parseExpression();return this.expect(_tokentype.types.parenR),{type:'ParenthesizedExpr',expression:a}}parseTagExpression(){var a={type:this.type.label};return this.inTag=!0,this.next(),a.val=this.parseExpression(),this.expect(_tokentype.types.tagR),this.inTag=!1,a}parseExprList(a,b){const c=[];for(let d=!0;!this.eat(a);)if(d?d=!1:this.expect(_tokentype.types.comma),b&&this.type===_tokentype.types.comma)c.push(null);else{var f=this.parseMaybeAssign();c.push(f)}return c}parseIndent(){var a;return this.type===_tokentype.types.name?a=this.value:this.unexpected(),this.next(),{type:'Identifier',name:a}}parseBindingList(a,b,c){const d=[];for(let f=!0;!this.eat(a);)if(f?f=!1:this.expect(_tokentype.types.comma),b&&this.type===_tokentype.types.comma)d.push(null);else if(c)break;else{var g=this.parseIndent();d.push(g)}return d}}exports.Parser=Parser;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.Parser=exports.pluginTable=void 0;var _options=require('./options'),_locutil=require('./locutil'),_tokentype=require('./tokentype'),_identifier=require('./identifier'),_whitespace=require('./whitespace'),_ast=require('./ast'),_ast2=_interopRequireDefault(_ast);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}const pluginTable=exports.pluginTable={};class Parser{constructor(a,b){this.options=a=(0,_options.getOptions)(a),this.keywords=_identifier.keywordRegexp,this.macros=_identifier.macroRegexp,this.input=b+'',this.loadPlugins(a.pluginList),this.pos=0,this.type=_tokentype.types.eof,this.value=null,this.start=this.end=this.pos,this.lastTokStart=this.lastTokEnd=this.pos,this.exprAllowed=!1,this.genAllowed=!1,this.labels=[],this.conf={},this.keys={},this.nextID=0,this.pcs={},this.pcsTable={},this.inTag=!1}extend(a,b){this[a]=b(this[a])}loadPlugins(a){a.forEach(b=>{const c=pluginTable[b];if(!c)throw new Error('Plugin ['+b+'] not found');c(this,b)})}parse(){this.nextToken();let a={CONFIG:this.conf,DATA_KEYS:this.keys,PROCESSES:this.pcs};return this.parseTopLevel(a)}raise(a,b){const c=(0,_locutil.getLineInfo)(this.input,a);b+=' ('+c.line+':'+c.column+')';const d=this.options.left,f=this.options.right;b=d||f?d+b+f:(0,_locutil.empowerErrMsg)(this.input,c,b);const g=this.pos;throw new _locutil.Lc2SyntaxError(b,a,c,g)}next(){this.lastTokEnd=this.end,this.lastTokStart=this.start,this.nextToken()}nextToken(){return this.skipSpace(),this.start=this.pos,this.pos>=this.input.length?this.finishToken(_tokentype.types.eof):void this.readToken(this.fullCharCodeAtPos())}readToken(a){return(0,_identifier.isIdentifierStart)(a)?this.readWord():this.getTokenFromCode(a)}fullCharCodeAtPos(){const a=this.input.charCodeAt(this.pos);if(55295>=a||57344<=a)return a;const b=this.input.charCodeAt(this.pos+1);return(a<<10)+b-56613888}skipBlockComment(){let a=this.pos,b=this.input.indexOf('*/',this.pos+=2);-1===b&&this.raise(this.pos-2,'unterminated comment'),this.pos=b+2,this.options.onComment&&this.options.onComment(!0,this.input.slice(a+2,b),a,this.pos)}skipLineComment(a){let b=this.pos,c=this.input.charCodeAt(this.pos+=a);for(;this.pos<this.input.length&&10!==c&&13!==c&&8232!==c&&8233!==c;)++this.pos,c=this.input.charCodeAt(this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(b+=a,this.pos),b,this.pos)}skipSpace(){loop:for(;this.pos<this.input.length;){let a=this.input.charCodeAt(this.pos);switch(a){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++this.pos;case 10:case 8232:case 8233:++this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:}break;default:if(8<a&&14>a)++this.pos;else break loop;}}}readTokenSlash(){const a=this.input.charCodeAt(this.pos+1);return this.exprAllowed||this.genAllowed?(++this.pos,this.readRegexp(this.genAllowed)):61===a?this.finishOp(_tokentype.types.assign,2):62===a?this.finishOp(_tokentype.types.tagR,2):this.finishOp(_tokentype.types.slash,1)}readTokenMultModuloExp(a){const b=this.input.charCodeAt(this.pos+1),c=1,d=42===a?_tokentype.types.star:_tokentype.types.modulo;return 61===b?this.finishOp(_tokentype.types.assign,c+1):this.finishOp(d,c)}readTokenPipeAmp(a){const b=this.input.charCodeAt(this.pos+1);return b===a?this.finishOp(124===a?_tokentype.types.logicalOR:_tokentype.types.logicalAND,2):124===a?this.finishOp(_tokentype.types.pipe,1):void this.raise(this.pos,'bitwise operator is not allowed')}readTokenPlusMin(a){const b=this.input.charCodeAt(this.pos+1);return b===a?this.finishOp(_tokentype.types.incDec,2):61===b?this.finishOp(_tokentype.types.assign,2):this.finishOp(_tokentype.types.plusMin,1)}readTokenLtGt(a){const b=this.input.charCodeAt(this.pos+1);let c=1;if(b===a&&this.raise(this.pos,'bitwise operator is not allowed'),60===a){if(35===b)return this.finishOp(_tokentype.types.tagNumL,2);if(64===b)return this.finishOp(_tokentype.types.tagAtL,2);if(33===b)return this.finishOp(_tokentype.types.tagFacL,2)}return 61===b&&(c=2),this.finishOp(_tokentype.types.relational,c)}readTokenEqExcl(a){const b=this.input.charCodeAt(this.pos+1);return 126===b&&33===a?this.finishOp(_tokentype.types.match,2):61===b?this.finishOp(_tokentype.types.equality,61===this.input.charCodeAt(this.pos+2)?3:2):this.finishOp(61===a?_tokentype.types.eq:_tokentype.types.prefix,1)}getTokenFromCode(a){switch(a){case 35:return++this.pos,this.readMacro();case 40:return++this.pos,this.finishToken(_tokentype.types.parenL);case 41:return++this.pos,this.finishToken(_tokentype.types.parenR);case 59:return++this.pos,this.finishToken(_tokentype.types.semi);case 44:return++this.pos,this.finishToken(_tokentype.types.comma);case 91:return++this.pos,this.finishToken(_tokentype.types.bracketL);case 93:return++this.pos,this.finishToken(_tokentype.types.bracketR);case 123:return++this.pos,this.finishToken(_tokentype.types.braceL);case 125:return++this.pos,this.finishToken(_tokentype.types.braceR);case 58:return++this.pos,this.finishToken(_tokentype.types.colon);case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(a);case 47:return this.readTokenSlash();case 37:case 42:return this.readTokenMultModuloExp(a);case 124:case 38:return this.readTokenPipeAmp(a);case 43:case 45:return this.readTokenPlusMin(a);case 60:case 62:return this.readTokenLtGt(a);case 61:case 33:return this.readTokenEqExcl(a);case 126:var b=this.input.charCodeAt(this.pos+1);return 126!==b&&this.raise(this.pos,'bitwise operator is not allowed'),this.finishOp(_tokentype.types.match,2);default:this.raise(this.pos,'Unexpected character "'+this.input[this.pos]+'"');}}finishOp(a,b){const c=this.input.slice(this.pos,this.pos+=b);return this.finishToken(a,c)}finishToken(a,b){this.end=this.pos,this.type=a,this.value=b,this.genAllowed=a.beforeGen,this.exprAllowed=a.beforeExpr}readRegexp(a){let b,c,d=this.pos;for(;;){this.pos>=this.input.length&&this.raise(d,'Unterminated regular expression');let h=this.input.charAt(this.pos);if(_whitespace.lineBreak.test(h)&&this.raise(d,'Unterminated regular expression'),b)b=!1;else{if('['===h)c=!0;else if(']'===h&&c)c=!1;else if('/'===h&&!c)break;b='\\'===h}++this.pos}const f=this.input.slice(d,this.pos);++this.pos;const g=this.readWord1();if(g){let h=/^[gim]*$/;h.test(g)||this.raise(d,'Invalid regular expression flag')}return this.finishToken(_tokentype.types.regexp,{pattern:f,flags:g,isGenerate:a})}readInt(a,b=null){let c=this.pos,d=0;for(let f=0,g=null===b?1/0:b;f<g;++f){let j,h=this.fullCharCodeAtPos();if(j=97<=h?h-97+10:65<=h?h-65+10:48<=h&&57>=h?h-48:1/0,j>=a)break;++this.pos,d=d*a+j}return this.pos===c||null!==b&&this.pos-c!==b?null:d}readNumber(a){let b=this.pos,c=!1;a||null!==this.readInt(10)||this.raise(b,'Invalid Number');let d=this.fullCharCodeAtPos();46===d&&(++this.pos,this.readInt(10),c=!0,d=this.fullCharCodeAtPos()),(69===d||101===d)&&(d=this.input.charCodeAt(++this.pos),(43===d||45===d)&&++this.pos,null===this.readInt(10)&&this.raise(b,'Invalid number'),c=!0),(0,_identifier.isIdentifierStart)(this.fullCharCodeAtPos())&&this.raise(this.pos,'Identifier directly after number');let g,f=this.input.slice(b,this.pos);return g=c?parseFloat(f):parseInt(f,10),this.finishToken(_tokentype.types.num,g)}readString(a){let b='',c=this.start,d=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(c,'Unterminated string');let f=this.fullCharCodeAtPos();if(f===a)break;92===f?(b+=this.input.slice(d,this.pos),b+=this.readEscapedChar(),d=this.pos):((0,_whitespace.isNewLine)(f)&&this.raise(c,'Unterminated string'),++this.pos)}return b+=this.input.slice(d,this.pos++),this.finishToken(_tokentype.types.string,b)}readEscapedChar(){const a=this.input.charCodeAt(++this.pos);switch(++this.pos,a){case 110:return'\n';case 114:return'\r';case 116:return'\t';case 98:return'\b';case 118:return'\x0B';case 102:return'\f';case 13:10===this.fullCharCodeAtPos()&&++this.pos;case 10:return'';default:return String.fromCharCode(a);}}readWord1(){let a='',b=this.pos;for(;this.pos<this.input.length;){let c=this.fullCharCodeAtPos();if((0,_identifier.isIdentifierChar)(c))++this.pos;else break}return a+=this.input.slice(b,this.pos),a}readWord(){const a=this.readWord1(),b=this.keywords.test(a)?_tokentype.keywords[a]:_tokentype.types.name;return this.finishToken(b,a)}readMacro(){var a=this.pos,b=this.readWord1();this.macros.test(b)||this.raise(a,'invalid macros');for(var c=_tokentype.keywords[b],d=this.pos,f=this.fullCharCodeAtPos();this.pos<this.input.length&&10!==f&&13!==f&&8232!==f&&8233!==f;)++this.pos,f=this.input.charCodeAt(this.pos);var g=this.input.slice(d,this.pos).trim();return this.finishToken(c,g)}parseTopLevel(a){let b=this.pcsTable;for(b.main={pos:0};this.type!==_tokentype.types.eof;)this.parseStructure();for(var c in b)b[c]&&this.raise(b[c].pos,'Invalid process call at');return a}parseStructure(){const a=this.type;return a.macro?this.parseSet():a===_tokentype.types._process?this.parseProcess():void this.raise(this.start,'Expect a macro or process')}parseSet(){const a=this.type;a.macro||this.unexpected();const b=a.label.toLowerCase();this.writeConfig(b),this.next()}writeConfig(a){let b;const c=this.conf;c[a]&&this.raise(this.start,this.type.keyword+' was defined already');let d,f,g=this.value.split(',');'screen'===a?(2!==g.length&&this.raise('Invalid arguments'),d=~~parseInt(g[0],10),f=~~parseInt(g[1],10),b={width:d,height:f}):'autoscroll'===a||'autocapture'===a||'autowait'===a?b=!0:b=parseInt(this.value,10);c[a]=b}parseProcess(){let a=this.startNode(),b=this.pcs,c=this.pcsTable;this.next();const d=this.parseIndent().name;a.BODY.IDENTIFIER=d,b[d]&&this.raise(this.start,d+' process was defined already'),b[d]=a,c[d]=!1,this.parsePcParam(a),this.parsePcBlock(a)}parsePcParam(a){this.eat(_tokentype.types.parenL)&&(a.BODY.params=this.parseBindingList(_tokentype.types.parenR,!1,!1))}parsePcBlock(a){const b=this.parseBlock();a.BODY.SEGMENT=b}parseBlock(){this.expect(_tokentype.types.braceL);const a=[];for(;!this.eat(_tokentype.types.braceR);){const b=this.parseStatement(!0);a.push(b)}return a}parseStatement(){let a=this.type,b=this.startNode();return a===_tokentype.types._click||a===_tokentype.types._rclick||a===_tokentype.types._dblclick||a===_tokentype.types._movein||a===_tokentype.types._moveout?this.parseMouseAction(b,a.keyword):a===_tokentype.types._scroll?this.parseScrollAction(b,a.keyword):a===_tokentype.types._input||a===_tokentype.types._select?this.parseInputAction(b,a.keyword):a===_tokentype.types._check||a===_tokentype.types._uncheck?this.parseCheck(b,a.keyword):a===_tokentype.types._return?this.parseReturnStatement(b):a===_tokentype.types._wait?this.parseWaitStatement(b):a===_tokentype.types._assert?this.parseAssertStatement(b):a===_tokentype.types._log||a===_tokentype.types._console?this.parseLogStatement(b,_ast2.default.LOG):a===_tokentype.types._jumpto?this.parseGotoStatement(b):a===_tokentype.types._refresh?this.parseRefreshStatement(b):a===_tokentype.types.name?this.parseExprStatement(b):a===_tokentype.types._if?this.parseIfStatement(b):a===_tokentype.types._while?this.parseWhileStatement(b):a===_tokentype.types.braceL?this.parseBlock():this.parseEvaluation(b)}parseReturnStatement(a){return this.next(),this.eat(_tokentype.types.semi),this.finishNode(a,_ast2.default.RETURN)}parseExprStatement(a){const b=this.parseExpression();if(this.semicolon(),'CallExpr'===b.type){var c=b.callee.name;return!1!==this.pcsTable[c]&&(this.pcsTable[c]={pos:this.lastTokStart}),a.BODY.IDENTIFIER=c,this.finishNode(a,_ast2.default.CALL)}return a.BODY.EXPRESSION=b,this.finishNode(a,_ast2.default.EXPRESSION)}parseEvaluation(a){const b=this.parseExpression();return this.semicolon(),a.BODY.EXPRESSION=b,this.finishNode(a,_ast2.default.EXPRESSION)}parseWaitStatement(a){return this.next(),a.BODY.WAIT=this.parseExpression(),this.semicolon(),this.finishNode(a,_ast2.default.WAIT)}parseMouseAction(a,b){if(this.next(),a.BODY.OBJECT=this.parseExpression(),a.BODY.ACTION=b,this.eat(_tokentype.types._to)){let c,d;c=this.parseMaybeAssign(),this.expect(_tokentype.types.comma),d=this.parseMaybeAssign(),a.BODY.posX=c,a.BODY.posY=d}return this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseScrollAction(a,b){return this.next(),a.BODY.OBJECT=this.parseExpression(),this.expect(_tokentype.types._by),a.BODY.PARAMS=this.parseExpression(),a.BODY.ACTION=b,this.finishNode(a,_ast2.default.TRIGGER)}parseInputAction(a,b){return this.next(),a.BODY.OBJECT=this.parseExpression(),this.expect(_tokentype.types._by),a.BODY.PARAMS=this.parseExpression(),a.BODY.ACTION=b,this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseCheck(a,b){return this.next(),a.BODY.OBJECT=this.parseExpression(),a.BODY.ACTION=b,this.semicolon(),this.finishNode(a,_ast2.default.TRIGGER)}parseAssertStatement(a){return this.next(),a.BODY.TEST=this.parseExpression(),this.eat(_tokentype.types._in)&&(this.type===_tokentype.types.num?a.BODY.TIMEOUT=this.value:this.unexpected(),this.next()),this.semicolon(),a.BODY.key=this.getUID('#'),this.keys[a.BODY.key]=!!a.BODY.TIMEOUT,this.finishNode(a,_ast2.default.ASSERT)}parseGotoStatement(a){return this.next(),a.BODY.URL=this.parseExpression(),this.semicolon(),this.finishNode(a,_ast2.default.JUMPTO)}parseRefreshStatement(a){return this.next(),this.semicolon(),this.finishNode(a,_ast2.default.REFRESH)}parseLogStatement(a,b){return this.next(),a.BODY.LOG=this.parseExpression(),this.semicolon(),this.finishNode(a,b)}parseIfStatement(a){return this.next(),a.CONDITION=this.parseExpression(),a.SEGMENT_TRUE=this.parseBlock(),a.SEGMENT_FALSE=this.eat(_tokentype.types._else)?this.parseStatement():null,this.finishNode(a,'BRANCH')}parseWhileStatement(a){return this.next(),a.CONDITION=this.parseExpression(),a.SEGMENT=this.parseStatement(),this.finishNode(a,'LOOP')}startNode(){return{POSITION:{LINE:(0,_locutil.getLineInfo)(this.input,this.start).line,start:this.start,end:0},BODY:{SYMBOL:''}}}finishNode(a,b){return a.BODY.SYMBOL=b,a.POSITION.end=this.lastTokEnd,a}eat(a){return this.type===a&&(this.next(),!0)}semicolon(){this.eat(_tokentype.types.semi)||this.expected(_tokentype.types.semi)}expect(a){return this.eat(a)||this.expected(a)}unexpected(a=this.start){this.raise(a,'Unexpected token')}expected(a){this.raise(this.lastTokEnd,'Expect a "'+a.label+'" after')}getUID(a){return a+this.nextID++}parseExpression(){var a=this.parseMaybeAssign();if(this.type===_tokentype.types.comma){var b={type:'SequenceExpr'};for(b.expressions=[a];this.eat(_tokentype.types.comma);){var c=this.parseMaybeAssign();b.expressions.push(c)}return b}return a}parseMaybeAssign(){var a=this.parseMaybeConditional();if(this.type.isAssign){var b={type:'AssignmentExpr',left:a,operator:this.value};return this.next(),b.right=this.parseMaybeAssign(),b}return a}parseMaybeConditional(){return this.parseExprOps()}parseExprOps(){var a=this.start,b=this.parseMaybeUnary(!1);return this.parseExprOp(b,a,-1)}parseExprOp(a,b,c){var d=this.type.binop;if(null!==d&&d>c){var f=this.type,g=this.value;this.next();var h=this.start,j=this.parseExprOp(this.parseMaybeUnary(!1),h,d),k=this.buildBinary(a,j,g,f);return this.parseExprOp(k,b,c)}return a}buildBinary(a,b,c,d){var f={left:a,operator:c,right:b};return f.type=d===_tokentype.types.logicalAND||d===_tokentype.types.logicalOR?'LogicalExpr':d===_tokentype.types.match?'MatchExpr':'BinaryExpr',f}parseMaybeUnary(){let a;if(this.type.prefix){const b={},c=this.type===_tokentype.types.incDec;b.operator=this.value,b.prefix=!0,this.next(),b.argument=this.parseMaybeUnary(!1),b.type=c?'UpdateExpr':'UnaryExpr',a=b}else for(a=this.parseExprSubscripts();this.type.postfix;){let b={};b.operator=this.value,b.prefix=!1,b.argument=a,this.next(),b.type='UpdateExpr',a=b}return a}parseExprSubscripts(){var a=this.parseExprAtom();return this.parseSubscripts(a)}parseSubscripts(a){for(;;){if(this.eat(_tokentype.types.parenL)){let b={type:'CallExpr',callee:a};return this.expect(_tokentype.types.parenR),b}if(this.eat(_tokentype.types.pipe)){let b={type:'FilterExpr',object:a,filter:this.parseIndent().name};this.expect(_tokentype.types.parenL),b.params=this.parseExprList(_tokentype.types.parenR,!1,!1),a=b}else return a}}parseExprAtom(){let a;switch(this.type){case _tokentype.types.name:return this.parseIndent(this.type!==_tokentype.types.name);case _tokentype.types.regexp:var b=this.value;return a=this.parseLiteral('regexp'),a.regexp=b,a;case _tokentype.types.num:case _tokentype.types.string:return this.parseLiteral('literal',this.value);case _tokentype.types._true:case _tokentype.types._false:return this.parseLiteral('literal',this.value);case _tokentype.types.objectAt:case _tokentype.types.dict:return this.parseExtLiteral(this.type);case _tokentype.types.parenL:return this.parseParenExpression();case _tokentype.types.tagAtL:case _tokentype.types.tagNumL:case _tokentype.types.tagFacL:return this.parseTagExpression();default:return this.inTag?this.raise(this.lastTokStart,'(missing `/` before `>` ?) Unexpected token'):this.unexpected();}}parseLiteral(a,b){var c={type:a,value:b,raw:this.input.slice(this.start,this.end)};return this.next(),c}parseExtLiteral(a){var b={type:a.label,value:this.value};return this.next(),b}parseParenExpression(){this.expect(_tokentype.types.parenL);var a=this.parseExpression();return this.expect(_tokentype.types.parenR),{type:'ParenthesizedExpr',expression:a}}parseTagExpression(){var a={type:this.type.label};return this.inTag=!0,this.next(),a.val=this.parseExpression(),this.expect(_tokentype.types.tagR),this.inTag=!1,a}parseExprList(a,b){const c=[];for(let d=!0;!this.eat(a);)if(d?d=!1:this.expect(_tokentype.types.comma),b&&this.type===_tokentype.types.comma)c.push(null);else{var f=this.parseMaybeAssign();c.push(f)}return c}parseIndent(){var a;return this.type===_tokentype.types.name?a=this.value:this.unexpected(),this.next(),{type:'Identifier',name:a}}parseBindingList(a,b,c){const d=[];for(let f=!0;!this.eat(a);)if(f?f=!1:this.expect(_tokentype.types.comma),b&&this.type===_tokentype.types.comma)d.push(null);else if(c)break;else{var g=this.parseIndent();d.push(g)}return d}}exports.Parser=Parser;
},{"./ast":2,"./identifier":3,"./locutil":5,"./options":6,"./tokentype":7,"./whitespace":8}],5:[function(require,module,exports){
'use strict';const lineBreakG=require('./whitespace').lineBreakG;class Position{constructor(a,b){this.line=a,this.column=b}offset(a){return new Position(this.line,this.column+a)}}function getLineInfo(a,b){for(let c=1,d=0;;){lineBreakG.lastIndex=d;let e=lineBreakG.exec(a);if(e&&e.index<b)++c,d=e.index+e[0].length;else return new Position(c,b-d)}}function empowerErrMsg(a,b,c){const d=a.split(lineBreakG)[b.line-1],e=d.substr(0,b.column),f=widthOf(e),g=genArrow(f),h=positionMsg(c,f);return'\n'+d+'\n'+g+'\n'+h}function genArrow(a){const b=' '.repeat(a)+'\u2191';return b+'\n'+b}function positionMsg(a,b){if(a.length/2>b)return a;let c=-1,d=b-Math.floor(a.length/2),e='';for(;++c<d;)e+=' ';return e+=a,e}function widthOf(a){const b=a.length;let c=0;for(let d=0,e='';d<b;d++)switch(e=a.charCodeAt(d),e){case 9:c+=4;break;default:c+=1;}return c}class Lc2SyntaxError extends Error{constructor(a,b,c,d){super(a),this.pos=b,this.loc=c,this.raisedAt=d}}module.exports={getLineInfo,empowerErrMsg,Position,Lc2SyntaxError};
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.Lc2SyntaxError=exports.Position=void 0;exports.getLineInfo=getLineInfo;exports.empowerErrMsg=empowerErrMsg;var _whitespace=require('./whitespace');class Position{constructor(a,b){this.line=a,this.column=b}offset(a){return new Position(this.line,this.column+a)}}exports.Position=Position;function getLineInfo(a,b){for(let c=1,d=0;;){_whitespace.lineBreakG.lastIndex=d;let e=_whitespace.lineBreakG.exec(a);if(e&&e.index<b)++c,d=e.index+e[0].length;else return new Position(c,b-d)}}function empowerErrMsg(a,b,c){const d=a.split(_whitespace.lineBreakG)[b.line-1],e=d.substr(0,b.column),f=widthOf(e),g=genArrow(f),h=positionMsg(c,f);return'\n'+d+'\n'+g+'\n'+h}function genArrow(a){const b=' '.repeat(a)+'\u2191';return b+'\n'+b}function positionMsg(a,b){if(a.length/2>b)return a;let c=-1,d=b-Math.floor(a.length/2),e='';for(;++c<d;)e+=' ';return e+=a,e}function widthOf(a){const b=a.length;let c=0;for(let d=0,e='';d<b;d++)switch(e=a.charCodeAt(d),e){case 9:c+=4;break;default:c+=1;}return c}class Lc2SyntaxError extends Error{constructor(a,b,c,d){super(a),this.pos=b,this.loc=c,this.raisedAt=d}}exports.Lc2SyntaxError=Lc2SyntaxError;
},{"./whitespace":8}],6:[function(require,module,exports){
'use strict';const defaultOptions={insertReturn:!0,onComment:function(){},left:'',right:'',pluginList:[]};function getOptions(a={}){return Object.assign({},defaultOptions,a)}module.exports={defaultOptions:defaultOptions,getOptions:getOptions};
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.getOptions=getOptions;const defaultOptions=exports.defaultOptions={insertReturn:!0,onComment:function(){},left:'',right:'',pluginList:[]};function getOptions(a={}){return Object.assign({},defaultOptions,a)}
},{}],7:[function(require,module,exports){
'use strict';class TokenType{constructor(a,b={}){this.label=a,this.keyword=b.keyword,this.beforeGen=!!b.beforeGen,this.beforeExpr=!!b.beforeExpr,this.isAssign=!!b.isAssign,this.prefix=!!b.prefix,this.postfix=!!b.postfix,this.binop=b.binop||null,this.macro=!!b.macro}}function binop(a,b){return new TokenType(a,{beforeGen:!0,binop:b})}const beforeGen={beforeGen:!0},macro={macro:!0},types={num:new TokenType('num'),regexp:new TokenType('regexp'),string:new TokenType('string'),name:new TokenType('name'),eof:new TokenType('eof'),bracketL:new TokenType('[',beforeGen),bracketR:new TokenType(']'),braceL:new TokenType('{',beforeGen),braceR:new TokenType('}'),parenL:new TokenType('(',beforeGen),parenR:new TokenType(')'),comma:new TokenType(',',beforeGen),semi:new TokenType(';',beforeGen),colon:new TokenType(':',beforeGen),tagNumL:new TokenType('CountExpr',beforeGen),tagAtL:new TokenType('TextExpr',beforeGen),tagFacL:new TokenType('VisibilityExpr',beforeGen),tagR:new TokenType('/>'),pipe:new TokenType('|'),eq:new TokenType('=',{beforeGen:!0,isAssign:!0}),assign:new TokenType('_=',{beforeGen:!0,isAssign:!0}),incDec:new TokenType('++/--',{prefix:!0,postfix:!0}),prefix:new TokenType('prefix',{beforeGen:!0,prefix:!0}),logicalOR:binop('||',1),logicalAND:binop('&&',2),equality:binop('==/!=',6),relational:binop('</>',7),plusMin:new TokenType('+/-',{beforeGen:!0,binop:9,prefix:!0}),modulo:binop('%',10),star:binop('*',10),slash:binop('/',10),match:new TokenType('~~',{beforeExpr:!0,binop:6})};let keywords={};function kw(a,b){b=b||{},b.keyword=a,keywords[a]=types['_'+a]=new TokenType(a,b)}kw('in'),kw('by',beforeGen),kw('to',beforeGen),kw('click',beforeGen),kw('input',beforeGen),kw('rclick',beforeGen),kw('dblclick',beforeGen),kw('movein',beforeGen),kw('moveout',beforeGen),kw('scroll',beforeGen),kw('select',beforeGen),kw('TIMES',macro),kw('INTERVAL',macro),kw('SCREEN',macro),kw('AUTOWAIT',macro),kw('AUTOCAPTURE',macro),kw('wait',beforeGen),kw('assert',beforeGen),kw('log',beforeGen),kw('console',beforeGen),kw('process'),kw('return',beforeGen),kw('true'),kw('false'),kw('if'),kw('else'),kw('while'),kw('jumpto'),kw('refresh'),kw('check'),kw('uncheck'),module.exports={TokenType:TokenType,types:types,keywordTypes:keywords};
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});class TokenType{constructor(a,b={}){this.label=a,this.keyword=b.keyword,this.beforeGen=!!b.beforeGen,this.beforeExpr=!!b.beforeExpr,this.isAssign=!!b.isAssign,this.prefix=!!b.prefix,this.postfix=!!b.postfix,this.binop=b.binop||null,this.macro=!!b.macro}}exports.TokenType=TokenType;function binop(a,b){return new TokenType(a,{beforeGen:!0,binop:b})}const beforeGen={beforeGen:!0},macro={macro:!0};const types=exports.types={num:new TokenType('num'),regexp:new TokenType('regexp'),string:new TokenType('string'),name:new TokenType('name'),eof:new TokenType('eof'),bracketL:new TokenType('[',beforeGen),bracketR:new TokenType(']'),braceL:new TokenType('{',beforeGen),braceR:new TokenType('}'),parenL:new TokenType('(',beforeGen),parenR:new TokenType(')'),comma:new TokenType(',',beforeGen),semi:new TokenType(';',beforeGen),colon:new TokenType(':',beforeGen),tagNumL:new TokenType('CountExpr',beforeGen),tagAtL:new TokenType('TextExpr',beforeGen),tagFacL:new TokenType('VisibilityExpr',beforeGen),tagR:new TokenType('/>'),pipe:new TokenType('|'),eq:new TokenType('=',{beforeGen:!0,isAssign:!0}),assign:new TokenType('_=',{beforeGen:!0,isAssign:!0}),incDec:new TokenType('++/--',{prefix:!0,postfix:!0}),prefix:new TokenType('prefix',{beforeGen:!0,prefix:!0}),logicalOR:binop('||',1),logicalAND:binop('&&',2),equality:binop('==/!=',6),relational:binop('</>',7),plusMin:new TokenType('+/-',{beforeGen:!0,binop:9,prefix:!0}),modulo:binop('%',10),star:binop('*',10),slash:binop('/',10),match:new TokenType('~~',{beforeExpr:!0,binop:6})};const keywords=exports.keywords={};function kw(a,b){b=b||{},b.keyword=a,keywords[a]=types['_'+a]=new TokenType(a,b)}kw('in'),kw('by',beforeGen),kw('to',beforeGen),kw('click',beforeGen),kw('input',beforeGen),kw('rclick',beforeGen),kw('dblclick',beforeGen),kw('movein',beforeGen),kw('moveout',beforeGen),kw('scroll',beforeGen),kw('select',beforeGen),kw('TIMES',macro),kw('INTERVAL',macro),kw('SCREEN',macro),kw('AUTOWAIT',macro),kw('AUTOCAPTURE',macro),kw('wait',beforeGen),kw('assert',beforeGen),kw('log',beforeGen),kw('console',beforeGen),kw('process'),kw('return',beforeGen),kw('true'),kw('false'),kw('if'),kw('else'),kw('while'),kw('jumpto'),kw('refresh'),kw('check'),kw('uncheck');
},{}],8:[function(require,module,exports){
'use strict';const lineBreak=/\r\n?|\n|\u2028|\u2029/;module.exports={lineBreak:lineBreak,lineBreakG:new RegExp(lineBreak.source,'g'),isNewLine(a){return 10===a||13===a||8232===a||8233===a}};
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});exports.isNewLine=isNewLine;const lineBreak=exports.lineBreak=/\r\n?|\n|\u2028|\u2029/;const lineBreakG=exports.lineBreakG=new RegExp(lineBreak.source,'g');function isNewLine(a){return 10===a||13===a||8232===a||8233===a}
},{}]},{},[1])(1)
});

@@ -12,6 +12,6 @@ const reserve = ['in', 'by', 'to'];

const keywordRegexp = new RegExp('^(' + keywords.join('|') + ')$');
const macroRegexp = new RegExp('^(' + macros.join('|') + ')$');
export const keywordRegexp = new RegExp('^(' + keywords.join('|') + ')$');
export const macroRegexp = new RegExp('^(' + macros.join('|') + ')$');
/* eslint-disable curly */
function isIdentifierStart(code) {
export function isIdentifierStart(code) {
if (code < 65) return code === 36; // $

@@ -23,3 +23,3 @@ if (code < 91) return true; // A-Z

function isIdentifierChar(code) {
export function isIdentifierChar(code) {
if (code < 48) return code === 36; // $

@@ -32,8 +32,2 @@ if (code < 58) return true; // 0-9

}
module.exports = {
keywordRegexp,
macroRegexp,
isIdentifierStart,
isIdentifierChar
};
/* eslint-enable curly */
import {getOptions} from './options';
import {getLineInfo, empowerErrMsg, Lc2SyntaxError} from './locutil';
import {types as tt, keywordTypes} from './tokentype';
import {types as tt, keywords} from './tokentype';
import {

@@ -555,3 +555,3 @@ keywordRegexp, macroRegexp, isIdentifierStart, isIdentifierChar

const word = this.readWord1();
const type = this.keywords.test(word) ? keywordTypes[word] : tt.name;
const type = this.keywords.test(word) ? keywords[word] : tt.name;

@@ -567,3 +567,3 @@ return this.finishToken(type, word);

}
var type = keywordTypes[word];
var type = keywords[word];
// read the rest of the line

@@ -674,7 +674,3 @@ var restStart = this.pos;

parseProcess() {
let node = {
LINE: getLineInfo(this.input, this.start),
TYPE: astType.PROCESS,
BODY: {}
};
let node = this.startNode();
let pcs = this.pcs;

@@ -686,2 +682,3 @@ let pcsTable = this.pcsTable;

const name = this.parseIndent().name;
node.BODY.IDENTIFIER = name;
// check for process name

@@ -709,8 +706,3 @@ if (pcs[name]) {

statements.push({
LINE: -1,
TYPE: astType.RETURN
});
node.BODY.segment = statements;
node.BODY.SEGMENT = statements;
}

@@ -739,7 +731,5 @@

return this.parseMouseAction(node, starttype.keyword);
case tt._select:
return this.parseSelectAction(node);
case tt._scroll:
return this.parseScrollAction(node, starttype.keyword);
case tt._input:
case tt._input: case tt._select:
return this.parseInputAction(node, starttype.keyword);

@@ -782,38 +772,2 @@ case tt._check: case tt._uncheck:

parseVarStatement(node) {
this.next();
this.parseVar(node);
this.semicolon();
return this.finishNode(node, astType.EXPRESSION);
}
parseVar(node) {
const declarations = [];
for (; ;) {
let decl = {};
decl.id = this.parseIndent().name;
if (this.eat(tt.eq)) {
decl.init = this.parseMaybeAssign();
} else {
decl.init = null;
}
declarations.push(decl);
if (!this.eat(tt.comma)) {
break;
}
}
node.BODY.raw = {
declarations: declarations,
type: 'varDecl'
};
}
parseExprStatement(node) {

@@ -832,3 +786,3 @@ const expr = this.parseExpression();

node.BODY.identifier = callee;
node.BODY.IDENTIFIER = callee;

@@ -838,3 +792,3 @@ return this.finishNode(node, astType.CALL);

node.BODY.raw = expr;
node.BODY.EXPRESSION = expr;

@@ -848,3 +802,3 @@ return this.finishNode(node, astType.EXPRESSION);

node.BODY.raw = expr;
node.BODY.EXPRESSION = expr;

@@ -857,3 +811,3 @@ return this.finishNode(node, astType.EXPRESSION);

node.BODY.raw = this.parseExpression();
node.BODY.WAIT = this.parseExpression();

@@ -868,4 +822,4 @@ this.semicolon();

node.BODY.raw = this.parseExpression();
node.BODY.action = keyword;
node.BODY.OBJECT = this.parseExpression();
node.BODY.ACTION = keyword;

@@ -891,9 +845,9 @@ // to expr, expr;

node.BODY.raw = this.parseExpression();
node.BODY.OBJECT = this.parseExpression();
this.expect(tt._by);
node.BODY.raw1 = this.parseExpression();
node.BODY.PARAMS = this.parseExpression();
node.BODY.action = keyword;
node.BODY.ACTION = keyword;

@@ -903,26 +857,11 @@ return this.finishNode(node, astType.TRIGGER);

parseSelectAction(node) {
this.next();
node.BODY.raw = this.parseExpression();
this.expect(tt._by);
node.BODY.raw1 = this.parseExpression();
node.BODY.action = 'select';
this.semicolon();
return this.finishNode(node, astType.TRIGGER);
}
parseInputAction(node, keyword) {
this.next();
node.BODY.raw = this.parseExpression();
node.BODY.OBJECT = this.parseExpression();
this.expect(tt._by);
node.BODY.raw1 = this.parseExpression();
node.BODY.action = keyword;
node.BODY.PARAMS = this.parseExpression();
node.BODY.ACTION = keyword;

@@ -937,4 +876,4 @@ this.semicolon();

node.BODY.raw = this.parseExpression();
node.BODY.action = keyword;
node.BODY.OBJECT = this.parseExpression();
node.BODY.ACTION = keyword;

@@ -949,7 +888,7 @@ this.semicolon();

node.BODY.raw = this.parseExpression();
node.BODY.TEST = this.parseExpression();
if (this.eat(tt._in)) {
if (this.type === tt.num) {
node.BODY.timeout = this.value;
node.BODY.TIMEOUT = this.value;
} else {

@@ -965,3 +904,3 @@ this.unexpected();

node.BODY.key = this.getUID('#');
this.keys[node.BODY.key] = Boolean(node.BODY.timeout);
this.keys[node.BODY.key] = Boolean(node.BODY.TIMEOUT);

@@ -974,3 +913,3 @@ return this.finishNode(node, astType.ASSERT);

node.BODY.raw = this.parseExpression();
node.BODY.URL = this.parseExpression();

@@ -993,3 +932,3 @@ this.semicolon();

node.BODY.raw = this.parseExpression();
node.BODY.LOG = this.parseExpression();

@@ -1003,7 +942,7 @@ this.semicolon();

this.next();
node.test = this.parseExpression();
node.consequent = this.parseBlock();
node.alternate = this.eat(tt._else) ? this.parseStatement() : null;
node.CONDITION = this.parseExpression();
node.SEGMENT_TRUE = this.parseBlock();
node.SEGMENT_FALSE = this.eat(tt._else) ? this.parseStatement() : null;
return this.finishNode(node, 'If');
return this.finishNode(node, 'BRANCH');
}

@@ -1013,6 +952,6 @@

this.next();
node.test = this.parseExpression();
node.body = this.parseStatement();
node.CONDITION = this.parseExpression();
node.SEGMENT = this.parseStatement();
return this.finishNode(node, 'While');
return this.finishNode(node, 'LOOP');
}

@@ -1022,7 +961,10 @@

return {
LINE: getLineInfo(this.input, this.start).line,
TYPE: 0,
BODY: {},
start: this.start,
end: 0
POSITION: {
LINE: getLineInfo(this.input, this.start).line,
start: this.start,
end: 0
},
BODY: {
SYMBOL: ''
}
};

@@ -1032,4 +974,4 @@ }

finishNode(node, type) {
node.TYPE = type;
node.end = this.lastTokEnd;
node.BODY.SYMBOL = type;
node.POSITION.end = this.lastTokEnd;

@@ -1036,0 +978,0 @@ return node;

@@ -1,4 +0,4 @@

const lineBreakG = require('./whitespace').lineBreakG;
import {lineBreakG} from './whitespace';
class Position {
export class Position {
constructor(line, col) {

@@ -15,3 +15,3 @@ this.line = line;

// determine the position of error
function getLineInfo(input, offset) {
export function getLineInfo(input, offset) {
for (let line = 1, cur = 0; ;) {

@@ -31,3 +31,3 @@ lineBreakG.lastIndex = cur;

// by draw an arrow point to the error position
function empowerErrMsg(input, loc, msg) {
export function empowerErrMsg(input, loc, msg) {
const errLine = input.split(lineBreakG)[loc.line - 1];

@@ -92,3 +92,3 @@ const strBeforeErr = errLine.substr(0, loc.column);

// add additional info to Error class
class Lc2SyntaxError extends Error {
export class Lc2SyntaxError extends Error {
constructor(msg, pos, loc, raisedAt) {

@@ -101,8 +101,1 @@ super(msg);

}
module.exports = {
getLineInfo,
empowerErrMsg,
Position,
Lc2SyntaxError
};

@@ -1,2 +0,2 @@

const defaultOptions = {
export const defaultOptions = {
insertReturn: true,

@@ -9,9 +9,4 @@ onComment: function () {},

function getOptions(options = {}) {
export function getOptions(options = {}) {
return Object.assign({}, defaultOptions, options);
}
module.exports = {
defaultOptions: defaultOptions,
getOptions: getOptions
};

@@ -13,3 +13,3 @@ // The assignment of fine-grained, information-carrying type objects

class TokenType {
export class TokenType {
constructor(label, conf = {}) {

@@ -35,3 +35,3 @@ this.label = label;

const types = {
export const types = {
num: new TokenType('num'),

@@ -88,3 +88,3 @@ regexp: new TokenType('regexp'),

let keywords = {};
export const keywords = {};

@@ -128,7 +128,1 @@ function kw(name, options) {

kw('uncheck');
module.exports = {
TokenType: TokenType,
types: types,
keywordTypes: keywords
};
// Matches a whole line break (where CRLF is considered a single
// line break). Used to count lines.
const lineBreak = /\r\n?|\n|\u2028|\u2029/;
module.exports = {
lineBreak: lineBreak,
lineBreakG: new RegExp(lineBreak.source, 'g'),
isNewLine(code) {
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
}
};
export const lineBreak = /\r\n?|\n|\u2028|\u2029/;
export const lineBreakG = new RegExp(lineBreak.source, 'g');
export function isNewLine(code) {
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
}
{
"name": "lc2-compiler",
"version": "1.1.0",
"version": "1.1.1",
"description": "lemoncase2 parser",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc