function e(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=!0;return t}var t=[`NULL`,`NA`,`Inf`,`NaN`,`NA_integer_`,`NA_real_`,`NA_complex_`,`NA_character_`,`TRUE`,`FALSE`],n=[`list`,`quote`,`bquote`,`eval`,`return`,`call`,`parse`,`deparse`],r=[`if`,`else`,`repeat`,`while`,`function`,`for`,`in`,`next`,`break`],i=[`if`,`else`,`repeat`,`while`,`function`,`for`],a=e(t),o=e(n),s=e(r),c=e(i),l=/[+\-*\/^<>=!&|~$:]/,u;function d(e,t){u=null;var n=e.next();if(n==`#`)return e.skipToEnd(),`comment`;if(n==`0`&&e.eat(`x`))return e.eatWhile(/[\da-f]/i),`number`;if(n==`.`&&e.eat(/\d/))return e.match(/\d*(?:e[+\-]?\d+)?/),`number`;if(/\d/.test(n))return e.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/),`number`;if(n==`'`||n==`"`)return t.tokenize=f(n),`string`;if(n=="`")return e.match(/[^`]+`/),`string.special`;if(n==`.`&&e.match(/.(?:[.]|\d+)/))return`keyword`;if(/[a-zA-Z\.]/.test(n)){e.eatWhile(/[\w\.]/);var r=e.current();return a.propertyIsEnumerable(r)?`atom`:s.propertyIsEnumerable(r)?(c.propertyIsEnumerable(r)&&!e.match(/\s*if(\s+|$)/,!1)&&(u=`block`),`keyword`):o.propertyIsEnumerable(r)?`builtin`:`variable`}else if(n==`%`)return e.skipTo(`%`)&&e.next(),`variableName.special`;else if(n==`<`&&e.eat(`-`)||n==`<`&&e.match(`<-`)||n==`-`&&e.match(/>>?/))return`operator`;else if(n==`=`&&t.ctx.argList)return`operator`;else if(l.test(n))return n==`$`||e.eatWhile(l),`operator`;else if(/[\(\){}\[\];]/.test(n))return u=n,n==`;`?`punctuation`:null;else return null}function f(e){return function(t,n){if(t.eat(`\\`)){var r=t.next();return r==`x`?t.match(/^[a-f0-9]{2}/i):(r==`u`||r==`U`)&&t.eat(`{`)&&t.skipTo(`}`)?t.next():r==`u`?t.match(/^[a-f0-9]{4}/i):r==`U`?t.match(/^[a-f0-9]{8}/i):/[0-7]/.test(r)&&t.match(/^[0-7]{1,2}/),`string.special`}else{for(var i;(i=t.next())!=null;){if(i==e){n.tokenize=d;break}if(i==`\\`){t.backUp(1);break}}return`string`}}}var p=1,m=2,h=4;function g(e,t,n){e.ctx={type:t,indent:e.indent,flags:0,column:n.column(),prev:e.ctx}}function _(e,t){var n=e.ctx;e.ctx={type:n.type,indent:n.indent,flags:n.flags|t,column:n.column,prev:n.prev}}function v(e){e.indent=e.ctx.indent,e.ctx=e.ctx.prev}var y={name:`r`,startState:function(e){return{tokenize:d,ctx:{type:`top`,indent:-e,flags:m},indent:0,afterIdent:!1}},token:function(e,t){if(e.sol()&&(t.ctx.flags&3||(t.ctx.flags|=m),t.ctx.flags&h&&v(t),t.indent=e.indentation()),e.eatSpace())return null;var n=t.tokenize(e,t);return n!=`comment`&&(t.ctx.flags&m)==0&&_(t,p),(u==`;`||u==`{`||u==`}`)&&t.ctx.type==`block`&&v(t),u==`{`?g(t,`}`,e):u==`(`?(g(t,`)`,e),t.afterIdent&&(t.ctx.argList=!0)):u==`[`?g(t,`]`,e):u==`block`?g(t,`block`,e):u==t.ctx.type?v(t):t.ctx.type==`block`&&n!=`comment`&&_(t,h),t.afterIdent=n==`variable`||n==`keyword`,n},indent:function(e,t,n){if(e.tokenize!=d)return 0;var r=t&&t.charAt(0),i=e.ctx,a=r==i.type;return i.flags&h&&(i=i.prev),i.type==`block`?i.indent+(r==`{`?0:n.unit):i.flags&p?i.column+ +!a:i.indent+(a?0:n.unit)},languageData:{wordChars:`.`,commentTokens:{line:`#`},autocomplete:t.concat(n,r)}};export{y as r};