Skip to content

Fix rule parsing grammar to support additional syntax patterns - #59

Open
joshi-07 wants to merge 1 commit into
googlefonts:mainfrom
joshi-07:issue-34-rule-parsing-fix
Open

joshi-07 wants to merge 1 commit into
googlefonts:mainfrom
joshi-07:issue-34-rule-parsing-fix

Conversation

@joshi-07

Copy link
Copy Markdown

This commit addresses issue #34 - Rule parsing is broken in prod.

The grammar now supports:

  • Parenthesized expressions for grouping
  • "or" operator in addition to "and"
  • Bitwise OR operator (|)
  • Font table access syntax (font["key"]["subkey"])
  • Function call syntax (e.g., tag_covers_100_percent())
  • Comprehension syntax (any() for loops)

These changes allow the parser to handle the rules that were previously failing:

  • not tag_covers_100_percent()
  • any(tag_value > 100 for tag_value in tag.values())
  • )
  • tag["/Expressive/Active"] > 0 and not font["OS/2"]["fsSelection"] & 0x1

The parser now gracefully handles these patterns, returning appropriate values for the supported cases and undefined for patterns that need additional implementation.

@google-cla

google-cla Bot commented Sep 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This commit addresses issue googlefonts#34 - Rule parsing is broken in prod.

The grammar now supports:
- Parenthesized expressions for grouping
- "or" operator in addition to "and"
- Bitwise OR operator (|)
- Font table access syntax (font["key"]["subkey"])
- Function call syntax (e.g., tag_covers_100_percent())
- Comprehension syntax (any() for loops)

These changes allow the parser to handle the rules that were previously failing:
- not tag_covers_100_percent()
- any(tag_value > 100 for tag_value in tag.values())
- )
- tag["/Expressive/Active"] > 0 and not font["OS/2"]["fsSelection"] & 0x1

The parser now gracefully handles these patterns, returning appropriate values
for the supported cases and undefined for patterns that need additional implementation.
@joshi-07
joshi-07 force-pushed the issue-34-rule-parsing-fix branch from 16cd84e to 7c1358f Compare September 20, 2026 05:34
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.

1 participant