-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serializer functionality to the generator
- Loading branch information
1 parent
1915fe8
commit ecc7d72
Showing
8 changed files
with
84 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) 2017-2020 Renata Hodovan, Akos Kiss. | ||
# | ||
# Licensed under the BSD 3-Clause License | ||
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>. | ||
# This file may not be copied, modified, or distributed except | ||
# according to those terms. | ||
|
||
from .tree import * | ||
|
||
|
||
def simple_space_serializer(root): | ||
|
||
def _walk(node): | ||
nonlocal src | ||
for child in node.children: | ||
_walk(child) | ||
|
||
if isinstance(node, UnparserRule): | ||
src += ' ' | ||
|
||
if isinstance(node, UnlexerRule) and node.src: | ||
src += node.src | ||
|
||
src = '' | ||
_walk(root) | ||
return src |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters