Skip to content

Stipped leading whitespace characters in lexer() #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pypreprocessor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def __if(self):

# evaluate
def lexer(self, line):
# return values are (squelch, metadata)
# strip any and all leading whitespace characters
line = line.lstrip()
# return values are (squelch, metadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of docstrings, I would suggest the other way around:

"""Returns (squelch, metadata)."""
# strip leading whitespace characters for compatibility with the C preprocessor.
line = line.lstrip()

if not (self.__ifblocks or self.__excludeblock):
if 'pypreprocessor.parse()' in line:
return True, True
Expand Down