Compile a language.
545546
function compileLanguage(language) {
  compileMode(language)

  // Compile a language mode, optionally with a parent.
  function compileMode(mode, parent) {
    var compiledKeywords = {}
    var terminators

    if (mode.compiled) {
      return
    }

    mode.compiled = true

    mode.keywords = mode.keywords || mode.beginKeywords

    if (mode.keywords) {
      if (typeof mode.keywords === 'string') {
        flatten('keyword', mode.keywords)
      } else {
        Object.keys(mode.keywords).forEach(function(className) {
          flatten(className, mode.keywords[className])
        })
      }

      mode.keywords = compiledKeywords
    }

    mode.lexemesRe = langRe(mode.lexemes || /\w+/, true)

    if (parent) {
      if (mode.beginKeywords) {
        mode.begin =
          '\\b(' + mode.beginKeywords.split(space).join(verticalBar) + ')\\b'
      }

      if (!mode.begin) {
        mode.begin = /\B|\b/
      }

      mode.beginRe = langRe(mode.begin)

      if (!mode.end && !mode.endsWithParent) {
        mode.end = /\B|\b/
      }

      if (mode.end) {
        mode.endRe = langRe(mode.end)
      }

      mode.terminatorEnd = source(mode.end) || ''

      if (mode.endsWithParent && parent.terminatorEnd) {
        mode.terminatorEnd +=
          (mode.end ? verticalBar : '') + parent.terminatorEnd
      }
    }

    if (mode.illegal) {
      mode.illegalRe = langRe(mode.illegal)
    }

    if (mode.relevance === undefined) {
      mode.relevance = 1
    }

    if (!mode.contains) {
      mode.contains = []
    }

    mode.contains = concat.apply(
      [],
      mode.contains.map(function(c) {
        return expandMode(c === 'self' ? mode : c)
      })
    )

    mode.contains.forEach(function(c) {
      compileMode(c, mode)
    })

    if (mode.starts) {
      compileMode(mode.starts, parent)
    }

    terminators = mode.contains
      .map(map)
      .concat([mode.terminatorEnd, mode.illegal])
      .map(source)
      .filter(Boolean)

    mode.terminators =
      terminators.length === 0
        ? {exec: execNoop}
        : langRe(terminators.join(verticalBar), true)

    function map(c) {
      return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin
    }

    // Flatten a classname.
    function flatten(className, value) {
      var pairs
      var pair
      var index
      var length

      if (language[keyInsensitive]) {
        value = value.toLowerCase()
      }

      pairs = value.split(space)
      length = pairs.length
      index = -1

      while (++index < length) {
        pair = pairs[index].split(verticalBar)

        compiledKeywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1]
      }
    }
  }

  // Create a regex for `value`.
  function langRe(value, global) {
    return new RegExp(
      source(value),
      'm' + (language[keyInsensitive] ? 'i' : '') + (global ? 'g' : '')
    )
  }

  // Get the source of an expression or string.
  function source(re) {
    return (re && re.source) || re
  }
}
496585
def compile(self):
        """"""
        return "{attribute}{sep}{value}".format(
            attribute=self.attribute,
            sep=self.sep,
            value=_quoted(self.value)
        )
235870
def compile_translations(markup)
      syntax_tree = @parser.parse(markup, root: :translations)
      if(syntax_tree.nil?)
        raise Exception, "Parse error: #{@parser.failure_reason}"
      end
      syntax_tree.value
    end
74610
def write_languages(f, l):
    """"""
    f.write("Languages = {%s" % os.linesep)
    for lang in sorted(l):
        f.write("    %r: %r,%s" % (lang, l[lang], os.linesep))
    f.write("}%s" % os.linesep)
1124242
def compile(self):
        """"""
        cs = ""
        for term in self.terms:
            if cs:
                cs += " "
            cs += term
        self.compiled_str = urllib.parse.quote(cs)
        return self
1037546
def cell_language(source):
    """"""
    if source:
        line = source[0]
        if line.startswith('%%'):
            magic = line[2:]
            if ' ' in magic:
                lang, magic_args = magic.split(' ', 1)
            else:
                lang = magic
                magic_args = ''

            if lang in _JUPYTER_LANGUAGES:
                source.pop(0)
                return lang, magic_args

    return None, None
1289155
function compileModes() {

    function compileMode(mode, language, is_default) {
      if (mode.compiled)
        return;

      if (!is_default) {
        mode.beginRe = langRe(language, mode.begin ? mode.begin : '\\B|\\b');
        if (!mode.end && !mode.endsWithParent)
          mode.end = '\\B|\\b'
        if (mode.end)
          mode.endRe = langRe(language, mode.end);
      }
      if (mode.illegal)
        mode.illegalRe = langRe(language, mode.illegal);
      if (mode.relevance == undefined)
        mode.relevance = 1;
      if (mode.keywords)
        mode.lexemsRe = langRe(language, mode.lexems || hljs.IDENT_RE, true);
      for (var key in mode.keywords) {
        if (!mode.keywords.hasOwnProperty(key))
          continue;
        if (mode.keywords[key] instanceof Object)
          mode.keywordGroups = mode.keywords;
        else
          mode.keywordGroups = {'keyword': mode.keywords};
        break;
      }
      if (!mode.contains) {
        mode.contains = [];
      }
      // compiled flag is set before compiling submodes to avoid self-recursion
      // (see lisp where quoted_list contains quoted_list)
      mode.compiled = true;
      for (var i = 0; i < mode.contains.length; i++) {
        compileMode(mode.contains[i], language, false);
      }
      if (mode.starts) {
        compileMode(mode.starts, language, false);
      }
    }

    for (var i in languages) {
      if (!languages.hasOwnProperty(i))
        continue;
      compileMode(languages[i].defaultMode, languages[i], true);
    }
  }
173680
protected function compile()
  {
    if (!\Input::get('ssoLogin'))
    {
      return;
    }

    $ssoHash = \Input::get('ssoLogin');

    $objSession = \Session::getInstance();

    if ($objSession)

      $objUser = \MemberModel::findBy('ssoHash', $ssoHash);

    if ($objUser !== null)
    {
      $time = time();

      $blnAccountError = false;

      // Check whether account is locked
      if (($objUser->locked + $GLOBALS['TL_CONFIG']['lockPeriod']) > $time)
      {
          $blnAccountError = true;
          $_SESSION['TL_ERROR'][] = sprintf($GLOBALS['TL_LANG']['ERR']['accountLocked'], ceil((($objUser->locked + $GLOBALS['TL_CONFIG']['lockPeriod']) - $time) / 60));
          $this->redirectTo403();
      }

      // Check whether account is disabled
      elseif ($objUser->disable)
      {
          $blnAccountError = true;

          $_SESSION['TL_ERROR'][] = $GLOBALS['TL_LANG']['ERR']['invalidLogin'];
          $this->log('The account has been disabled', __METHOD__, TL_ACCESS);
          $this->redirectTo403();
      }

      // Check wether login is allowed (front end only)
      elseif (!$objUser->login)
      {
          $blnAccountError = true;

          $_SESSION['TL_ERROR'][] = $GLOBALS['TL_LANG']['ERR']['invalidLogin'];
          $this->log('User "' . $objUser->username . '" is not allowed to log in', __METHOD__, TL_ACCESS);
          $this->redirectTo403();
      }

      // Check whether account is not active yet or anymore
      elseif (strlen($objUser->start) || strlen($objUser->stop))
      {
        if (strlen($objUser->start) && $objUser->start > $time)
        {
          $blnAccountError = true;

          $_SESSION['TL_ERROR'][] = $GLOBALS['TL_LANG']['ERR']['invalidLogin'];
          $this->log('The account was not active yet (activation date: ' . $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objUser->start) . ')', __METHOD__, TL_ACCESS);
          $this->redirectTo403();
        }

        if (strlen($objUser->stop) && $objUser->stop < $time)
        {
          $blnAccountError = true;

          $_SESSION['TL_ERROR'][] = $GLOBALS['TL_LANG']['ERR']['invalidLogin'];
          $this->log('The account was not active anymore (deactivation date: ' . $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objUser->stop) . ')', __METHOD__, TL_ACCESS);
          $this->redirectTo403();
        }
      }

      // Redirect to login screen if there is an error
      if ($blnAccountError)
      {
          return false;
      }

      $this->loginUser($objUser);

    }




  }
1262139
function compile(grammar) {
  var tree = ometa.parser.matchAll(grammar, 'topLevel', undefined) //, error_handler("Error while parsing OMeta grammar"));
	var parserString = ometa.translator.match(tree, 'trans', undefined)//, error_handler("Error while translating grammar"));
  return parserString;
}
496005
def compile(cls, code, path=None, libraries=None,
                contract_name='', extra_args=None):
        
        result = cls._code_or_path(
            code,
            path,
            contract_name,
            libraries,
            'bin',
            extra_args)
        return result['bin']
41875
def compile(self, source_code, post_treatment=''.join):
        
        # read structure
        structure = self._structure(source_code)
        values    = self._struct_to_values(structure, source_code)
        # create object code, translated in targeted language
        obj_code = langspec.translated(
            structure, values, 
            self.target_lang_spec
        )
        # apply post treatment and return
        return obj_code if post_treatment is None else post_treatment(obj_code)
1004623
public function actionCompile()
    {
        
        $extensionsToCreate = explode(',', $this->options['extension']);
        $extensionsToCreate = array_unique($extensionsToCreate);
        
		foreach ($extensionsToCreate as $extension){
			$language = $this->options['language'];
			$compiledTranslationFile = new tao_helpers_translation_TranslationFile();
			$compiledTranslationFile->setTargetLanguage($this->options['language']);
			
			$this->outVerbose("Compiling language '${language}' for extension '${extension}'...");
			
			// Get the dependencies of the target extension.
			// @todo Deal with dependencies at compilation time.
			$dependencies = array();
			if ($extension !== 'tao'){
				$dependencies[] = 'tao';
			}
			
			$this->outVerbose("Resolving Dependencies...");
			foreach ($dependencies as $depExtId){
				$this->outVerbose("Adding messages from extension '${depExtId}' in '${language}'...");
				// Does the locale exist for $depExtId?
				$depPath = $this->buildLanguagePath($depExtId, $language) . '/' . self::DEF_PO_FILENAME;
				if (!file_exists($depPath) || !is_readable($depPath)){
					$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist. Trying to resolve default language...");
					$depPath = $this->buildLanguagePath($depExtId, tao_helpers_translation_Utils::getDefaultLanguage() . '/' . self::DEF_PO_FILENAME);

					if (!file_exists($depPath) || !is_readable($depPath)){
						$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist.");
						continue;
					}
				}
				
				// Recompile the dependent extension (for the moment 'tao' meta-extension only).
				$oldVerbose = $this->options['verbose'];
				$this->parameters['verbose'] = false;
				$this->options['extension'] = $depExtId;
				$this->actionCompile();
				$this->options['extension'] = $extension;
				$this->parameters['verbose'] = $oldVerbose;
				
				$poFileReader = new tao_helpers_translation_POFileReader($depPath);
				$poFileReader->read();
				$poFile = $poFileReader->getTranslationFile();
				$poCount = $poFile->count();
				$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
				
				$this->outVerbose("${poCount} messages added.");
			}

			if (($extDirectories = scandir(ROOT_PATH)) !== false){
						
				// Get all public messages accross extensions.
				foreach ($extDirectories as $extDir){
					$extPath = ROOT_PATH . '/' . $extDir;
					
					if (is_dir($extPath) && is_readable($extPath) && $extDir[0] != '.' && !in_array($extDir, $dependencies) && $extDir != $extension && $extDir != 'generis'){
						$this->outVerbose("Adding public messages from extension '${extDir}' in '${language}'...");
						
						$poPath = $this->buildLanguagePath($extDir, $language) . '/' . self::DEF_PO_FILENAME;
						if (!file_exists($poPath) || !is_readable($poPath)){
							$this->outVerbose("Extension '${extDir}' is not translated in language '${language}'. Trying to retrieve default language...");
							$poPath = $this->buildLanguagePath($extDir, tao_helpers_translation_Utils::getDefaultLanguage()) . '/' . self::DEF_PO_FILENAME;
							
							if (!file_exists($poPath) || !is_readable($poPath)){
								$this->outVerbose("Extension '${extDir}' in '${language}' does not exist.");
								continue;
							}
						}

						$poFileReader = new tao_helpers_translation_POFileReader($poPath);
						$poFileReader->read();
						$poFile = $poFileReader->getTranslationFile();
						$poUnits = $poFile->getByFlag('tao-public');
						$poCount = count($poUnits);
						$compiledTranslationFile->addTranslationUnits($poUnits);
						$this->outVerbose("${poCount} public messages added.");
					}
				}                
				
				// Finally, add the translation units related to the target extension.
				$path = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_PO_FILENAME;
				if (file_exists($path) && is_readable($path)){
					$poFileReader = new tao_helpers_translation_POFileReader($path);
					$poFileReader->read();
					$poFile = $poFileReader->getTranslationFile();
					$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
					
					// Sort the TranslationUnits.
					$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
					$compiledTranslationFile->setTranslationUnits($compiledTranslationFile->sortBySource($sortingMethod));
					
					$jsPath = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_JS_FILENAME;
					$jsFileWriter = new tao_helpers_translation_JSFileWriter($jsPath, $compiledTranslationFile);
					$jsFileWriter->write();
					$this->outVerbose("JavaScript compiled translations for extension '${extension}' with '${language}' written.");
				}
				else{
					$this->err("PO file '${path}' for extension '${extension}' with language '${language}' cannot be read.", true);
				}
			}
			else{
				$this->err("Cannot list TAO Extensions from root path. Check your system rights.", true);    
			}

			$this->outVerbose("Translations for '${extension}' with language '${language}' gracefully compiled.");

		}
        
    }
943177
public void compileProgram() {
		program.inputs().forEach(var -> var.calculateFuzzySpace());
		program.outputs().forEach(var -> var.calculateFuzzySpace());

		program.rules().forEach(rule -> {
			updateMemberReferenceCount(rule.getCondition());
			rule.assignmentMembers().forEach(member -> member.incrReferenceCount());
		});
	}
818459
def compile(self):
        """"""
        result = TEMPLATE

        for rule in self.rules:
            if rule[2]:
                arrow = '=>'
            else:
                arrow = '->'
            repr_rule = repr(rule[0] + arrow + rule[1])

            result += "algo.add_rule({repr_rule})\n".format(repr_rule=repr_rule)

        result += "for line in stdin:\n"
        result += "    print(algo.execute(''.join(line.split())))"
        return result
432935
def _compile_pfgen(self):
        """"""
        string = '"""\n'
        string += 'system.dae.init_g()\n'
        for gcall, pflow, shunt, series, stagen, call in zip(
                self.gcall, self.pflow, self.shunt, self.series, self.stagen,
                self.gcalls):
            if gcall and pflow and (shunt or series) and not stagen:
                string += call
        string += '\n'
        string += 'system.dae.reset_small_g()\n'
        string += '"""'
        self.pfgen = compile(eval(string), '', 'exec')
148694
function compile(
  source,
  filename = '',
  includeModule = false,
  debugMode = false,
) {
  let res
  let resName
  let errors

  try {
    const [moduleName, bsCode, diagnosticErrors] = Retyped.compile(filename, source, debugMode)
    const fmtCode = format(bsCode)
    res = fmtCode
    resName = moduleName
    errors = diagnosticErrors
  } catch (e) {
    console.error(e)
    throw new Error(`${e[0][0]}`)
  }

  if (res.includes('SYNTAX ERROR>')) {
    throw new Error(res)
  }

  if (!includeModule) {
    return res
  } else {
    return {
      moduleName: resName,
      bsCode: res,
      diagnosticErrors: errors
    }
  }
}
557148
public function run()
    {
        $this->languages = ['ru', 'en'];

        foreach ($this->languages as $language) {
            Language::create(
                $this->languages()[$language]
            );
        }
    }