-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import unicode_literals | ||
from os.path import join, abspath, dirname | ||
from textx import metamodel_for_language, get_children_of_type | ||
|
||
|
||
def test_textx_rrel_multi(): | ||
|
||
textx_mm = metamodel_for_language('textx') | ||
grammar_model = textx_mm.grammar_model_from_file( | ||
join(abspath(dirname(__file__)), 'textx_rrel_test.tx')) | ||
|
||
rrels = get_children_of_type('RRELExpression', grammar_model) | ||
|
||
# Multi | ||
assert rrels[0].multi | ||
|
||
# Multi with parent | ||
assert rrels[1].multi \ | ||
and rrels[1].sequence.paths[0].parts[0].__class__.__name__ == 'RRELParent' | ||
|
||
# Dots | ||
dots = get_children_of_type('RRELPath', rrels[3]) | ||
assert any([x.dots == '..' for x in dots]) | ||
|
||
# Brackets | ||
brackets = get_children_of_type('RRELBrackets', rrels[4]) | ||
assert len(brackets) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* Grammar for testing textX RREL parsing | ||
This grammar is loaded for analysis, thus references and RREL expressions | ||
are just syntactically valid to assert that grammar_model_from_file can | ||
properly parse RRELs. | ||
*/ | ||
|
||
Multi: ref=[Target|ID|+m:^some_rule]; | ||
MultiParent: ref=[Target|ID|+m:parent(SomeType).some_rule]; | ||
Parent: ref=[Target|ID|parent(SomeRule).obj.ref.~extension*.methods]; | ||
Dots: ref=[Target|ID|(..)*.(pkg)*.cls]; | ||
Brackets: ref=[Target|ID|obj.ref.(~extension)*.methods]; | ||
WhiteSpace: ref=[Target|ID|obj. ref.(~extension ) *. methods]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters