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

expose the "apply" rule #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions ometa/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ def digit(self):
rule_end = end
rule_ws = eatWhitespace
rule_exactly = exactly
rule_apply = apply

#Deprecated.
rule_spaces = eatWhitespace
Expand Down
11 changes: 11 additions & 0 deletions ometa/test/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ def test_exactlyFail(self):
self.assertEquals(exc.args[0], 0)


def test_apply(self):
"""
L{OMetaBase.rule_apply} applies the given rule with arguments.
"""
data = "foo"
o = OMetaBase(data)
v, e = o.rule_apply("exactly", "f")
self.assertEqual(v, "f")
self.assertEqual(e.args[0], 0)
self.assertRaises(NameError, o.rule_apply, "foo")


def test_token(self):
"""
Expand Down