MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / parse_shell

Function parse_shell

src/packagedcode/bashparse.py:379–405  ·  view source on GitHub ↗

Return a pygmars parse Tree built from a ``text`` string.

(text, grammar=variables_grammar, loop=1, trace=TRACE, validate=VALIDATE)

Source from the content-addressed store, hash-verified

377
378
379def parse_shell(text, grammar=variables_grammar, loop=1, trace=TRACE, validate=VALIDATE):
380 """
381 Return a pygmars parse Tree built from a ``text`` string.
382 """
383 tokens = get_tokens(text)
384
385 # then build a parse parse_tree based on tagged tokens
386 parser = parse.Parser(
387 grammar=grammar,
388 trace=trace,
389 validate=validate,
390 loop=loop,
391 )
392
393 if TRACE:
394 tokens = list(tokens)
395 logger_debug(f'parse_shell: parsing tokens #: {len(tokens)}')
396
397 if TRACE:
398 logger_debug(f'parse_shell: calling parser.parse')
399
400 parse_tree = parser.parse(tokens)
401
402 if TRACE:
403 logger_debug(f'parse_shell: got parse_tree: {parse_tree}')
404
405 return parse_tree
406
407
408if __name__ == '__main__':

Callers 1

Calls 3

get_tokensFunction · 0.70
logger_debugFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected