Use by plugins to add grammar for an extension statement.
480907
def add_stmt(stmt, arg_rules):
    """"""
    (arg, rules) = arg_rules
    stmt_map[stmt] = (arg, rules)
201832
protected void generateDocumentationProviderImpl() {
		TypeReference etype = null;
		final LinkedList<Grammar> grammars = new LinkedList<>();
		grammars.addAll(getGrammar().getUsedGrammars());
		while (etype == null && !grammars.isEmpty()) {
			final Grammar grammar = grammars.removeFirst();
			grammars.addAll(grammar.getUsedGrammars());
			final String gbase = getNaming().getRuntimeBasePackage(grammar);
			final String providerClassname = gbase + ".documentation." //$NON-NLS-1$
					+ GrammarUtil.getSimpleName(grammar) + "DocumentationProvider"; //$NON-NLS-1$
			try {
				getClass().getClassLoader().loadClass(providerClassname);
				etype = new TypeReference(providerClassname);
			} catch (Throwable exception) {
				//
			}
		}
		if (etype == null) {
			etype = new TypeReference(MultiLineCommentDocumentationProvider.class);
		}
		final TypeReference extendType = etype;
		final TypeReference provider = getDocumentationProviderImpl();
		final StringConcatenationClient content = new StringConcatenationClient() {
			@Override
			protected void appendTo(TargetStringConcatenation it) {
				it.append("/** Provider a documentation string."); //$NON-NLS-1$
				it.newLine();
				it.append(" */"); //$NON-NLS-1$
				it.newLine();
				it.append("public class "); //$NON-NLS-1$
				it.append(provider.getSimpleName());
				it.append(" extends "); //$NON-NLS-1$
				it.append(extendType);
				it.append(" {"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
				it.append("\tpublic String getDocumentation("); //$NON-NLS-1$
				it.append(EObject.class);
				it.append(" o) {"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t// Get the documentation from the Xtext grammar hidden nodes."); //$NON-NLS-1$
				it.newLine();
				it.append("\t\tString text = super.getDocumentation(o);"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\tif (text == null) {"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t// Get the grammar from the Ecore model element."); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\tif (o instanceof "); //$NON-NLS-1$
				it.append(EModelElement.class);
				it.append(") {"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\ttext = "); //$NON-NLS-1$
				it.append(EcoreUtil.class);
				it.append(".getDocumentation(("); //$NON-NLS-1$
				it.append(EModelElement.class);
				it.append(") o);"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t}"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\tif (text == null) {"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\t// Get the grammar from the code builder extension."); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\t"); //$NON-NLS-1$
				it.append(DocumentationAdapter.class);
				it.append(" adapter = ("); //$NON-NLS-1$
				it.append(DocumentationAdapter.class);
				it.append(") "); //$NON-NLS-1$
				it.append(EcoreUtil.class);
				it.append(".getAdapter("); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\t\t\to.eAdapters(), "); //$NON-NLS-1$
				it.append(DocumentationAdapter.class);
				it.append(".class);"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\tif (adapter != null) {"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\t\treturn adapter.getDocumentation();"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t\t}"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t\t}"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\t}"); //$NON-NLS-1$
				it.newLine();
				it.append("\t\treturn text;"); //$NON-NLS-1$
				it.newLine();
				it.append("\t}"); //$NON-NLS-1$
				it.newLine();
				it.append("}"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
			}

		};
		final JavaFileAccess createJavaFile = getFileAccessFactory().createJavaFile(provider, content);
		createJavaFile.writeTo(getSrcGen());
	}
780071
protected function createTwigLintCommand() {
    $twig = new Environment(new FilesystemLoader());

    $repo_root = $this->getConfigValue('repo.root');
    $extension_file_contents = file_get_contents($repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigExtension.php');

    // Get any custom defined Twig filters to be ignored by linter.
    $twig_filters = (array) $this->getConfigValue('validate.twig.filters');

    // Add Twig filters from Drupal TwigExtension to be ignored.
    $drupal_filters = [];
    if ($matches_count = preg_match_all("#new \\\\Twig_SimpleFilter\('([^']+)',#", $extension_file_contents, $matches)) {
      $drupal_filters = $matches[1];
    }
    $twig_filters = array_merge($twig_filters, $drupal_filters);
    foreach ($twig_filters as $filter) {
      // Add two default arguments and set to variadic so that filters with
      // named arguments will be whitelisted.
      // @see \TwigNode_Expression_Call::getArguments
      // @see \TwigNode_Expression_Call::call()
      $twig->addFilter(new \Twig_SimpleFilter($filter, function ($node = '', array $args = []) {}, [
        'is_variadic' => TRUE,
      ]));
    }

    // Get any custom defined Twig functions to be ignored by linter.
    $twig_functions = (array) $this->getConfigValue('validate.twig.functions');

    // Add Twig functions from Drupal TwigExtension to be ignored.
    $drupal_functions = [];
    if ($matches_count = preg_match_all("#new \\\\Twig_SimpleFunction\('([^']+)',#", $extension_file_contents, $matches)) {
      $drupal_functions = $matches[1];
    }
    $twig_functions = array_merge($twig_functions, $drupal_functions);
    foreach ($twig_functions as $function) {
      // Add default argument and set to variadic so that functions with named
      // arguments will be whitelisted.
      // @see \TwigNode_Expression_Call::getArguments
      // @see \TwigNode_Expression_Call::call()
      $twig->addFunction(new \Twig_SimpleFunction($function, function (array $args = []) {}, [
        'is_variadic' => TRUE,
      ]));
    }

    // Add Drupal Twig parser to include trans tag.
    $token_parser_filename = $repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigTransTokenParser.php';
    if (file_exists($token_parser_filename)) {
      require_once $token_parser_filename;
      $twig->addTokenParser(new TwigTransTokenParser());
    }

    $command = new TwigLintCommand();
    $command->setTwigEnvironment($twig);

    return $command;
  }
595529
function(extensions) {
  var
    extensions = extensions || {},
    devExts = extensions.development || [],
    testExts = extensions.test || [],
    prodExts = extensions.production || [];

  gulp.task('default', ['development']);

  gulp.task('post-install-development', [
    'karma:dev',
    'styles',
    'bundle-js:dev:clean',
    'tpl-precompile',
    'watch'
  ].concat(devExts));
  gulp.task('development', ['install-dev-dep'], function() {
    gulp.start('post-install-development');
  });

  gulp.task('post-install-test', [
    'lint',
    'karma'
  ].concat(testExts), cleanTmp);
  gulp.task('test', ['install-dev-dep'], function() {
    gulp.start('post-install-test');
  });

  gulp.task('post-install-production', [
    'styles',
    'bundle-js:clean',
    'tpl-precompile'
  ].concat(prodExts));
  gulp.task('production', ['install-dep'], function() {
    gulp.start('post-install-production');
  });
}
1308077
function compile(grammar) {
  var compiler     = require('./compiler.js'),
      tree         = compiler.parser.matchAll(grammar, 'topLevel'),
	    parserString = compiler.translator.match(tree, 'trans');
  return parserString;
}
1084199
public void addProduction(Event event, Grammar grammar) {

		containers.add(new SchemaLessProduction(this, grammar, event,
				getNumberOfEvents()));
		// pre-calculate count for log2 (Note: always 2nd level productions
		// available)
		// Note: BuiltInDocContent and BuiltInFragmentContent do not use this
		// variable
		this.ec1Length = MethodsBag.getCodingLength(containers.size() + 1);
	}
467929
function extendFormatExtensions (extensionName, extensionValue) {
        if (typeof extensionName !== 'string' || !(extensionValue instanceof RegExp)) {
            throw new Error('extensionName or extensionValue undefined or not correct type');
        }

        if (revalidator.validate.formats.hasOwnProperty(extensionName) ||
            revalidator.validate.formats.hasOwnProperty(extensionName)) {
            var msg = 'extensionName: ' + extensionName + ' already exists in formatExtensions.';
            throw  new Error(msg);
        }

        revalidator.validate.formatExtensions[extensionName] = extensionValue;
    }
890447
function Extend(superGrammar, name, body) {
  this.superGrammar = superGrammar;
  this.name = name;
  this.body = body;
  var origBody = superGrammar.rules[name].body;
  this.terms = [body, origBody];
}
1089512
def added(self, context):
        """"""
        context.ansi = ANSIFormatter(self._enable)
        context.aprint = context.ansi.aprint
106776
private static void addPluralRules(TypeSpec.Builder type) {
    FieldSpec field = FieldSpec.builder(PLURAL_RULES, "pluralRules", PRIVATE, STATIC, FINAL)
        .initializer("new $T()", PLURAL_RULES)
        .build();
    
    MethodSpec method = MethodSpec.methodBuilder("getPluralRules")
        .addModifiers(PUBLIC)
        .returns(PLURAL_RULES)
        .addStatement("return pluralRules")
        .build();

    type.addField(field);
    type.addMethod(method);
  }
235108
def add_plugin_arguments(self, parser):
        
        for manager in self.hook_managers.values():
            if len(list(manager)) == 0:
                continue
            manager.map(self._add_hook_extension_arguments, parser)
        for namespace, manager in self.driver_managers.items():
            choices = list(sorted(manager.names()))
            if len(choices) == 0:
                continue
            option, dest = self._namespace_to_option(namespace)
            parser.add_argument(
                option, help=self._help[namespace], dest=dest,
                choices=choices, default='default')
            option_prefix = '{0}-'.format(option)
            dest_prefix = '{0}_'.format(dest)
            manager.map(self._add_driver_extension_arguments,
                        parser, option_prefix, dest_prefix)
969869
def remove_useless(self):
        """"""
        if not self.is_contextfree():
            raise ValueError("grammar must be context-free")
        by_lhs = collections.defaultdict(list)
        by_rhs = collections.defaultdict(list)
        for [lhs], rhs in self.rules:
            by_lhs[lhs].append((lhs, rhs))
            for y in rhs:
                if y in self.nonterminals:
                    by_rhs[y].append((lhs, rhs))
            
        agenda = collections.deque([self.start])
        reachable = set()
        while len(agenda) > 0:
            x = agenda.popleft()
            if x in reachable: continue
            reachable.add(x)
            for _, rhs in by_lhs[x]:
                for y in rhs:
                    if y in by_lhs:
                        agenda.append(y)

        agenda = collections.deque()
        productive = set()
        for [lhs], rhs in self.rules:
            if all(y not in self.nonterminals for y in rhs):
                agenda.append(lhs)
        while len(agenda) > 0:
            y = agenda.popleft()
            if y in productive: continue
            productive.add(y)
            for lhs, rhs in by_rhs[y]:
                if all(y not in self.nonterminals or y in productive for y in rhs):
                    agenda.append(lhs)

        g = Grammar()
        g.set_start(self.start)

        for [lhs], rhs in self.rules:
            if (lhs in reachable & productive and
                all(y not in self.nonterminals or y in reachable & productive for y in rhs)):
                g.add_rule([lhs], rhs)
        return g
940995
private void applyDefinitionsDocumentExtension(Context context) {
        extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.apply(context));
    }
23751
def add_plugin(self, plugin):
        
        self.plugin_by_name[plugin.get_plugin_name()] = plugin
        self.plugins.append(plugin)
675994
def _setup_log_prefix(self, plugin_id=''):
        """"""
        self._logger_console_fmtter.prefix = '%s: ' % plugin_id
        self._logger_console_fmtter.plugin_id = plugin_id
        self._logger_file_fmtter.prefix = '*'
        self._logger_file_fmtter.plugin_id = '%s: ' % plugin_id
81713
public function includeAceEditor()
    {
        if ($this->editorIncluded) {
            return;
        }

        if (!$this->environment->hasExtension(AssetExtension::class)) {
            throw new \LogicException('"asset" extension is mandatory if you don\'t include Ace editor by yourself.');
        }

        if (!$this->editorIncluded) {
            foreach (['ace', 'ext-language_tools'] as $file) {
                /** @var AssetExtension $extension */
                $extension = $this->environment->getExtension(AssetExtension::class);
                $jsPath = $extension->getAssetUrl($this->basePath.'/'.$this->mode.'/'.$file.'.js');

                printf('<script src="%s" charset="utf-8" type="text/javascript"></script>', $jsPath);
            }
            $this->editorIncluded = true;
        }
    }
1347924
def _at_extend(self, calculator, rule, scope, block):
        
        from scss.selector import Selector
        selectors = calculator.apply_vars(block.argument)
        rule.extends_selectors.extend(Selector.parse_many(selectors))