Parse a source an return a valid javascript source injectable in an nway define() template. This method call the first valid parser defined by user (options.parsers) or in the default parsers
542061
function parse(src, module, makeModule, options) {
		// Find the first valid parser :
		debug('Find a parser for :', module.path)
		var result = _.find(parsers, function(def) {
			// debug('    Check parser match :', def.match)
			if(def.match instanceof RegExp) {
				return def.match.test(module.path);
			} else if ('string'   == typeof def.match) {
				return minimatch(module.path, def.match);
			} else if ('function' == typeof def.match) {
				return def.match(src, module, makeModule, options);
			} else {
				return false;
			}
		});
		if(!result) {
			debug('Warning: No valid parser found for %s. Json string is exported', module.path)
			return 'module.exports = ' + JSON.stringify(src);
		} else {
			debug('Ok parser match :', result.match);
			return result.parse(src, module, makeModule, options);
		}
	}
1302864
def _parse():
    
    if not args["reparse"]:
        settings.use_filesystem_cache = False

    c = CodeParser()    
    if args["verbose"]:
        c.verbose = True

    if args["reparse"]:
        c.reparse(args["source"])
    else:
        c.parse(args["source"])

    return c
1064370
function(input) {
  var code = 'var $_parsers = {\n';
  var parsernames = Object.keys(parsers);
  for (var i = 0; i < parsernames.length; i++) {
    code += '  ' + JSON.stringify(parsernames[i]) + ': ' +
      parsers[parsernames[i]].toString() + ',\n';
  };
  code += '}\n';
  code += compile(input) + '\nif (typeof $_end === "function") {$_end();}';
  var script = new vm.Script(code, {timeout: 4 * 60 * 1000});
  var runner = function(scope) {
    var output = '';
    var pipeOpen = false;
    var ended = false;
    var stream = new Readable({
      encoding: 'utf8',
      read: function() {
        pipeOpen = true;
        if (ended && output === '') {
          pipeOpen = this.push(null);
        } else if (output !== '') {
          pipeOpen = this.push(output);
          output = '';
        }
      },
    });
    scope.$_scope = scope;
    scope.$_write = function(data) {
      output += '' + data;
      if (pipeOpen && output !== '') {
        pipeOpen = stream.push(output);
        output = '';
      }
    };
    scope.$_end = function() {
      ended = true;
      if (pipeOpen) { stream.push(null); }
    };
    script.runInNewContext(scope)
    return stream;
  };
  runner.code = code;
  return runner;
}
681247
function compileJSSource(ComponentClass) {
    var sourceBuffer = new CompileSourceBuffer();
    var contextId = genSSRId();

    sourceBuffer.addRendererStart();
    var renderId = compileComponentSource(sourceBuffer, ComponentClass, contextId);
    sourceBuffer.addRaw('return componentRenderers.' + renderId + '(data, noDataOutput)');
    sourceBuffer.addRendererEnd();

    return sourceBuffer.toCode();
}
906173
function interpret(source) {
  var tree = parser.parse(source);
  var js = [
    'module.exports = function (out, globals) {',
    '  var end = false;',
    '  if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {',
    '    out = new module.xjs.XjsStream(out);',
    '    end = true;',
    '  }',
    '  if (globals && typeof globals.length === "number" && typeof globals !== "string") {',
    '    var callee = arguments.callee;',
    '    for (var i in globals) {',
    '      callee.call(this, out, globals[i]);',
    '    }',
    '    return;',
    '  }',
    '  globals = globals || {};',
    '  with (globals) {'
  ];
  interpretChildren(js, tree, '    ');
  js.push(
    '  }',
    '  if (end) {',
    '    out.end();',
    '  }',
    '}'
  );
  js = js.join('\n');
  return js;
}
84349
def _get_source(self):
        
        logger.debug('Getting module source for webhook2lambda2sqs.lambda_func')
        orig = getsourcelines(lambda_func)
        src = ''
        in_docstr = False
        have_docstr = False
        for line in orig[0]:
            if line.strip() == '"""' and not in_docstr and not have_docstr:
                in_docstr = True
                continue
            if line.strip() == '"""' and in_docstr:
                in_docstr = False
                have_docstr = True
                continue
            if not in_docstr:
                src += line
        return src
274754
function parse_markdown(file, options, callback) { 
  fs.readFile(file, 'utf8', function (err, source) {
    if (err) {
      callback(err);
      return;
    }
    var sourceLines = source.split("\n");
    var metaExpr = /\{(([\"\']).+\1\s*:\s*[\"\'].+\1)\}/g;
    var metaString;

    var firstClass = {
        found: false,
        name: ""
    };
    var re;

    if (re = sourceLines[0].match(/^\#{1}\s+(.+)/)) { // if #, it's a title
        var metaString = sourceLines[1].match(metaExpr);

        if (!metaString) {
            console.error("Error".red + ": on " + file + " you started with #, but provided no context--that's bad.");
            process.exit(1);
        }

        var metaJson = JSON.parse(metaString);

        if (metaJson.type == 'misc') {
            var title = sourceLines[0].substr(2).replace(/(\w) /g, "$1");
            sourceLines[0] = "/** section: " + title + "\n";
            sourceLines[1] = "* class " + title;

            for (l = 2; l < sourceLines.length; l++) {
                sourceLines[l] = "* " + sourceLines[l];
            }
            sourceLines.push("**/");
            return pdoc_parser("", {registered: true, source: sourceLines.join("\n"), file: file, options: options, callback: callback});
        }
        else {
            console.error("In " + file + " I did not understand the type '" + metaJson.type + "'");
        }
    }
    else if (re = sourceLines[0].match(/^\#{2}\s+(.+)/)) { // if ##, it's a class
        if (!firstClass.found) {
            firstClass.found = true;
            firstClass.name = re[1];
            sourceLines[0] = "/**\n* " + "class " + firstClass.name;
            if ( (metaString = sourceLines[1].match(metaExpr) ) ) {
                var metaString = metaString[0].replace("(", "").replace(")", "");
                sourceLines[0] = "/** " + metaString + "\n* " + "class " + firstClass.name;
                sourceLines[1] = "* ";
            }
            else
                sourceLines[1] = "* ";
        }
    }
    else {
        console.error("Error".red + ": first line in " + file + " is neither # or ##--that's bad.");
        process.exit(1);
    }

    for (var l = 2; l < sourceLines.length; l++) {
        if (re = sourceLines[l].match(/^\#{2}\s+(.+)/)) { // if ##, it's a class
            if (!firstClass.found) {
                firstClass.found = true;
                firstClass.name = re[1];
                sourceLines[l] = "/**\n* " + sourceLines[l].replace("##", "class " + firstClass.name);
            }
            else {
                if (re[1].indexOf("<") < 0) {
                    sourceLines[l] = "**/\n\n/**\n* " + "class " + re[1] + " < " + firstClass.name;
                }
                else {
                    sourceLines[l] = "**/\n\n/**\n* " + "class " + re[1];
                }
            }
        }
        else if (sourceLines[l].match(/^\#{3}\s+/)) { // if ###, it's a member
            var startingDefPos = l;
            sourceLines[l] = "**/\n\n/**\n* " + sourceLines[l].replace("###", "");
            var n = l + 1;

            while (sourceLines[n].match(/^\#{3}\s+/)) { // it has aliases
                sourceLines[n] = " " + sourceLines[n].replace("###", "");
                n++;
            }

            var tagRE = sourceLines[n].match(/^(\((.+)\))$/);
            if (tagRE) { // if it's got tags, add them appropriately to the starting /**
                sourceLines[l] = sourceLines[l].replace("/**", "/** " + tagRE[2]);
                sourceLines[n] = "";
                n++;
            }
           // while (sourceLines[n].match(/[-|*|+]\s*.+?\s*{.+?}\s*/)) {
             //   sourceLines[n] = sourceLines[n].replace("{", "(").replace("}", "):");
             /*   n++;
            } */
        }
        else { // catch tags after param lists
            var tagRE = sourceLines[l].match(/^(\((.+)\))$/);
            var indentedParam = sourceLines[l].match(/^\s+[*|-]/);
            
            if (tagRE) { // if it's got tags, add them appropriately to the starting /**
                sourceLines[startingDefPos] = sourceLines[startingDefPos].replace("/**", "/** " + tagRE[2]);
                sourceLines[l] = "";
            }
            else if (indentedParam) {
                // noop
            }
            else { // everything else just prefix with a "*"
                 sourceLines[l] = "*" + sourceLines[l];
            }
        }
    }

    sourceLines.push("**/");

    pdoc_parser("", {registered: true, source: sourceLines.join("\n"), file: file, options: options, callback: callback});
  });
}
997469
function Parser(options) {
  options = options || {};
  this.tokens = [];
  this.token = null;
  this.options = options || defaults;
  this.options.renderer = this.options.renderer || new Renderer;
  this.renderer = this.options.renderer;
  this.renderer.options = this.options;
  this.options.sanitize = false;
  this.renderer.parser = this;
}
488606
function parse(source) {

	var moduleDefinitions = {},
		moduleReferences = [];

    estraverse.traverse(esprima.parse(source), {
        leave: function (node, parent) {
			
			if(!isAngular(node)) {
				return;
			}
			
            //console.log('node:', JSON.stringify(node, null, 3));
            //console.log('parent:', JSON.stringify(parent, null, 3));
			
			var moduleName = parent.arguments[0].value;
			
			// if a second argument exists
			// this is a module definition
			if(parent.arguments[1]) {
				if(parent.arguments[1].type === 'ArrayExpression') {
					moduleDefinitions[moduleName] = parent.arguments[1].elements.map(function(item){
						return item['value'];
					});
				} else {
					throw 'Argument must be an ArrayExpression, not a variable';
				}
			} else {
				// is a module reference
				pushDistinct(moduleReferences, moduleName);
			}
					          
        }
    });
		
	return {
		modules: moduleDefinitions,
		references: moduleReferences
	}	
}
1003847
function parse (input, opts) {
  // Wrap parser.parse to allow specifying the start rule
  // as a shorthand option
  if (!opts) {
    opts = {}
  }
  else if (typeof opts == 'string') {
    opts = { startRule: opts }
  }
  return parser.parse(input, opts)
}
48570
function script(source, options) {
  var tokens

  /* Make sure the require to the main module
   * is showed as if it was a require from
   * `./node_modules`.
   *
   * For example, when the example file
   * (`test/example.js`) requires the main file (as
   * listed in `test/package.json`, `main: "module.js"`)
   * as `./module`, it is replaced with `test`. */
  source = source.replace(EXPRESSION_REQUIRE, replace)

  /* Transform comments into markdown: */
  tokens = []

  source.split('\n').forEach(each)

  return tokens

  function replace($0, $1, $2, $3) {
    var filepath = resolveFrom.silent(
      path.dirname(options.example),
      unquote($2)
    )
    var quote

    if (options.main === filepath && options.name) {
      /* Honour quote style. */
      quote = $2.charAt(0)

      return $1 + quote + options.name + quote + $3
    }

    return $0
  }

  function each(line) {
    var match = line.match(EXPRESSION_COMMENT)

    tokens.push({
      type: match ? 'markdown' : 'javascript',
      value: match ? match[4] : line
    })
  }
}
219912
def source(self, format='xml', accessible=False):
        
        if accessible:
            return self.http.get('/wda/accessibleSource').value
        return self.http.get('source?format='+format).value
1303515
function tag (chrSource) {
      var program
      var replacements

      // Examine caller format
      if (typeof chrSource === 'object' && chrSource.type && chrSource.type === 'Program') {
        // called with already parsed source code
        // e.g. tag({ type: 'Program', body: [ ... ] })
        program = chrSource
        replacements = []

        // allow to specify replacements as second argument
        if (arguments[1] && typeof arguments[1] === 'object' && arguments[1] instanceof Array) {
          replacements = arguments[1]
        }
      } else if (typeof chrSource === 'object' && chrSource instanceof Array && typeof chrSource[0] === 'string') {
        // called as template tag
        // e.g. tag`a ==> b`
        // or   tag`a ==> ${ function() { console.log('Replacement test') } }`
        var combined = [
          chrSource[0]
        ]
        Array.prototype.slice.call(arguments, 1).forEach(function (repl, ix) {
          combined.push(repl)
          combined.push(chrSource[ix + 1])
        })
        chrSource = joinParts(combined)
        replacements = Array.prototype.slice.call(arguments, 1)
        program = parse(chrSource)
      } else if (typeof chrSource === 'string' && arguments[1] && arguments[1] instanceof Array) {
        // called with program and replacements array
        // e.g. tag(
        //        'a ==> ${ function() { console.log("Replacement test") } }',
        //        [ eval('( function() { console.log("Replacement test") } )') ]
        //      )
        // this is useful to ensure the scope of the given replacements
        program = parse(chrSource)
        replacements = arguments[1]
      } else if (typeof chrSource === 'string') {
        // called as normal function
        // e.g. tag('a ==> b')
        // or   tag('a ==> ', function() { console.log('Replacement test') })
        replacements = Array.prototype.filter.call(arguments, isFunction)
        chrSource = joinParts(Array.prototype.slice.call(arguments))
        program = parse(chrSource)
      }

      var rules = program.body
      rules.forEach(function (rule) {
        tag.Rules.Add(rule, replacements)
      })
    }
667613
def parse(input_: Union[str, FileStream], source: str) -> Optional[str]:
    

    # Step 1: Tokenize the input stream
    error_listener = ParseErrorListener()
    if not isinstance(input_, FileStream):
        input_ = InputStream(input_)
    lexer = jsgLexer(input_)
    lexer.addErrorListener(error_listener)
    tokens = CommonTokenStream(lexer)
    tokens.fill()
    if error_listener.n_errors:
        return None

    # Step 2: Generate the parse tree
    parser = jsgParser(tokens)
    parser.addErrorListener(error_listener)
    parse_tree = parser.doc()
    if error_listener.n_errors:
        return None

    # Step 3: Transform the results the results
    parser = JSGDocParser()
    parser.visit(parse_tree)

    if parser.undefined_tokens():
        for tkn in parser.undefined_tokens():
            print("Undefined token: " + tkn)
        return None

    return parser.as_python(source)
575443
def define_source(name, url, &block)
      source = Source.new(name, url)
      source.instance_eval(&block)

      @source = source
    end
577233
function loadParser (parserName) {
  var parser = parsers[parserName]

  if (parser !== undefined) {
    return parser
  }

  // this uses a switch for static require analysis
  switch (parserName) {
    case 'json':
      parser = require('./lib/types/json')
      break
    case 'raw':
      parser = require('./lib/types/raw')
      break
    case 'text':
      parser = require('./lib/types/text')
      break
    case 'urlencoded':
      parser = require('./lib/types/urlencoded')
      break
  }

  // store to prevent invoking require()
  return (parsers[parserName] = parser)
}
832999
function Parser(tokens, options) {
  options = options || {};
  if (!Array.isArray(tokens)) {
    throw new Error('Expected tokens to be an Array but got "' + (typeof tokens) + '"');
  }
  if (typeof options !== 'object') {
    throw new Error('Expected "options" to be an object but got "' + (typeof options) + '"');
  }
  this.tokens = new TokenStream(tokens);
  this.filename = options.filename;
  this.src = options.src;
  this.inMixin = 0;
  this.plugins = options.plugins || [];
}