UNPKG

@bablr/language-en-es6

Version:
82 lines 3.48 kB
/* @macrome * @generatedby @bablr/macrome-generator-bablr * @generatedfrom ./class.macro.js#4e159ba9b4b2272a008a11039caf5d564355a414 * This file is autogenerated. Please do not edit it directly. * When editing run `npx macrome watch` then change the file this is generated from. */ import _applyDecs from "@babel/runtime/helpers/applyDecs2305"; import { spam as m } from '@bablr/boot'; import { CoveredBy, Node } from '@bablr/helpers/decorators'; import { o, eat, eatMatch, fail } from '@bablr/helpers/grammar'; export const mixin = Base => { let _initProto, _ClassExpressionDecs, _ClassMethodDecs, _SuperExpressionDecs, _ThisExpressionDecs; return class ES6ClassGrammar extends Base { static { [_initProto] = _applyDecs(this, [[Node, 2, "ClassDeclaration"], [_ClassExpressionDecs, 2, "ClassExpression"], [Node, 2, "ClassBody"], [_ClassMethodDecs, 2, "ClassMethod"], [_SuperExpressionDecs, 2, "SuperExpression"], [_ThisExpressionDecs, 2, "ThisExpression"]], [], 0, void 0, Base).e; } constructor(...args) { super(...args); _initProto(this); } *[(_ClassExpressionDecs = [CoveredBy('Expression'), Node], _ClassMethodDecs = [CoveredBy('ClassMember'), Node], _SuperExpressionDecs = [CoveredBy('Expression'), Node], _ThisExpressionDecs = [CoveredBy('Expression'), Node], "ClassDeclaration")]() { yield eat(m`sigilToken: <*Keyword 'class' />`); yield eat(m`name$: <Identifier />`); if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`, o({}), o({ bind: true }))) { yield eat(m`superClass$: <__Expression>`); } else { yield eat(m`superClass$: null`); } yield eat(m`body: <ClassBody />`); } *ClassExpression() { yield eat(m`sigilToken: <*Keyword 'class' />`); yield eatMatch(m`name$: <Identifier />`); if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`)) { yield eat(m`superClass$: <__Expression>`); } else { yield eat(m`superClass$: null`); } yield eat(m`body: <ClassBody />`); } *ClassBody() { yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`); while (yield eatMatch(m`members[]: <__ClassMember />`)) {} yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`); } *ClassMember() { yield eat(m`<ClassMethod />`); } *ClassMethod() { yield eatMatch(m`staticToken: <*Keyword 'static' />`); let acc, a, gen; acc = yield eatMatch(m`kindToken: <*Keyword /get|set/ />`); if (!acc) { a = yield eatMatch(m`asyncToken: <*Keyword 'async' />`); gen = yield eatMatch(m`starToken: <*Punctuator '*' />`); } else { yield eatMatch(m`asyncToken: null`); yield eatMatch(m`starToken: null`); } if (a && gen) yield fail(); yield eatMatch(m`id: <Identifier />`, o({}), o({ bind: true })); yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`); yield eat(m`params[]: <_List />`, o({ element: m`<Identifier />`, allowTrailingSeparator: false, separator: m`separatorTokens[]: <*Punctuator ',' />` })); yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`); yield eat(m`body: <BlockStatement />`); } *SuperExpression() { yield eat(m`sigilToken: <*Keyword 'super' />`); } *ThisExpression() { yield eat(m`sigilToken: <*Keyword 'this' />`); } }; };