Skip to content

Commit

Permalink
[codegen] use None for whitespace when not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed May 2, 2024
1 parent afecc15 commit 4e0d5f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tatsu/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UndefinedStr(str):
pass


_undefined_str = UndefinedStr()
_undefined_str = UndefinedStr('>>undefined<<')


@dataclasses.dataclass
Expand Down
3 changes: 3 additions & 0 deletions tatsu/ngcodegen/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .. import grammars
from ..collections import OrderedSet as oset
from ..exceptions import CodegenError
from ..infos import UndefinedStr
from ..mixins.indent import IndentPrintMixin
from ..util import compress_seq, safe_name
from ..walkers import NodeWalker
Expand Down Expand Up @@ -308,6 +309,8 @@ def _gen_init(self, grammar: grammars.Grammar):
start = grammar.config.start or grammar.rules[0].name

whitespace = grammar.config.whitespace
if isinstance(whitespace, UndefinedStr): # the default value
whitespace = None
whitespace = repr(whitespace)

self.print(
Expand Down

0 comments on commit 4e0d5f1

Please sign in to comment.