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

Object processors on terminal match rules not called #182

Closed
igordejanovic opened this issue Apr 27, 2019 · 0 comments · Fixed by #183
Closed

Object processors on terminal match rules not called #182

igordejanovic opened this issue Apr 27, 2019 · 0 comments · Fixed by #183
Assignees
Labels

Comments

@igordejanovic
Copy link
Member

igordejanovic commented Apr 27, 2019

Issue found in SO post

To reproduce:

from textx import metamodel_from_str

grammar = '''
Model: commands*=Command;
Command: MyNumber;
MyNumber: MyFloat | INT;
MyFloat: /[+-]?(((\d+\.(\d*)?|\.\d+)([eE][+-]?\d+)?)|((\d+)([eE][+-]?\d+)))(?<=[\w\.])(?![\w\.])/;
'''

mm = metamodel_from_str(grammar)
mm.register_obj_processors({'MyFloat': lambda x: float(x)})

model = mm.model_from_str('''
10
10.5
''')
assert type(model.commands[0]) is int
assert type(model.commands[1]) is float
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant