diff --git a/muppet/format.py b/muppet/format.py index 9e19576d4762405383583094d04f08f2a01457bd..b55d39711f2808232ce768861f76058417adf3cd 100644 --- a/muppet/format.py +++ b/muppet/format.py @@ -98,7 +98,7 @@ def parse_puppet(source: str, file: str) -> str: ast = build_ast(puppet_parser(source)) # logger.info("ast: %a", ast) # From the ast, build a parser combinator parser. - parser = ParserFormatter(source, file=file).serialize(ast) + parser = ParserFormatter().serialize(ast) # logger.warning("parser: %a", parser) # Run the generatefd parser, giving us a list of match objects match_objects = ParserCombinator(source, file).get(parser) diff --git a/muppet/puppet/format/parser.py b/muppet/puppet/format/parser.py index 68c80f4c9e25206faf0cc2584a724c30dfec15b1..aaffae36607ae85b4579a7107212063b0b8211db 100644 --- a/muppet/puppet/format/parser.py +++ b/muppet/puppet/format/parser.py @@ -201,25 +201,7 @@ class rich_char(ParseDirective): class ParserFormatter(Serializer[ParseDirective]): - """ - Reserialize AST by highlighting the original source code. - - :param source: - The original source code. *Must* be the exact same source as - used to construct the corresponinding Puppet ast object. - :param seek: - Current parsing position in the string. - - TODO make this private. - """ - - # parser: ParserCombinator - - # def __init__(self, source: str, file: Optional[str] = None): - def __init__(self, source: str, file: str): - # self.parser = ParserCombinator(source=source, file=file) - self.file = file - pass + """Reserialize AST by highlighting the original source code.""" def declaration_parameter(self, item: PuppetDeclarationParameter) -> ParseDirective: """Build parser for the given declaration parameter.""" @@ -683,7 +665,6 @@ class ParserFormatter(Serializer[ParseDirective]): parser = (single_quoted | double_quoted) else: parser = (raw_string | single_quoted | double_quoted) - # TODO should the whitespace really be here? return ws & tag('string', name(it.s, parser)) @override diff --git a/tests/test_parse_elsif.py b/tests/test_parse_elsif.py index cc02476ec57691f8ab196f42a799450c32bdb89d..9ef30aba532cd36687d3c8078fa5fead73861b3d 100644 --- a/tests/test_parse_elsif.py +++ b/tests/test_parse_elsif.py @@ -95,7 +95,7 @@ def parse_string(s: str, *, if ast: assert generated_ast == ast - parser = ParserFormatter(s, "s").serialize(generated_ast) + parser = ParserFormatter().serialize(generated_ast) print() pprint(parser)