Skip to content
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

Stipped leading whitespace characters in lexer() #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tcumby
Copy link

@tcumby tcumby commented Mar 7, 2018

Stripped any and all whitespace characters from the line in lexer(line) before we try to find preprocessor directives. I believe insensitivity to leading whitespace is standard for modern C preprocessors.

Stripped any and all whitespace characters from the line in lexer(line) before we try to find preprocessor directives.
Moved the lstrip() call to the start of lexer() to improve reliability.
Copy link
Member

@cxw42 cxw42 left a comment

Choose a reason for hiding this comment

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

Style suggestion

# 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()

@hendiol
Copy link
Contributor

hendiol commented Mar 29, 2018

This allow indented (by whitespace) directives in python? That would be great I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants