Skip to content

Commit

Permalink
Fix parsing of CRLF style line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
igordejanovic committed Nov 12, 2020
1 parent f2393db commit e729112
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Need for testing of proper CRLF parsing
tests/test_newlines_crlf.pf text eol=crlf
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ please take a look at related PRs and issues and see if the change affects you.

## [Unreleased]

### Fixed

- Parsing of CRLF line endings in condition tables. This problem was triggered
on Windows which uses CRLF line endings by default preventing condition tables
from being parsed ([]).

## [0.4.1] (released: 2020-11-09)

### Added
Expand Down
2 changes: 1 addition & 1 deletion pyflies/lang/pyflies.tx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ConditionsTable[noskipws]:
cond_specs+=Condition
;

WSWithNL: /[ \t]*\n/;
WSWithNL: /[ \t]*\r?\n/;
WSNoNL: /[ \t]*/;

TableVarName: WSNoNL- WORD WSNoNL-;
Expand Down
10 changes: 10 additions & 0 deletions tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,13 @@ def test_jinja_filters_in_screens():
"""
Test that Jinja filters are working as expected
"""


def test_crlf_line_endings():
"""
Test parsing of files using CRLF line endings.
"""
mm = metamodel_for_language('pyflies')
m = mm.model_from_file(join(this_folder, 'test_newlines_crlf.pf'))

assert len(m.flow.insts) == 2
28 changes: 28 additions & 0 deletions tests/test_newlines_crlf.pf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Model for testing parsing if CRLF line endings are used.
This file uses CRLF and is set so in .gitattributes
"""
a = 10
b = 5
test TestModel {

| direction | position | response |
|-----------+----------+----------|
| left | (0, 50) | left |

exec -> at a + 100 c1:circle(position 0, radius 5 + 15) for a + b * a + 140
at .+100 c2:circle(position 0, radius 20) for 200
at +100 c3:circle(position 0, radius 20) for 200
c4:circle(position 0, radius 20) for 200
at 100 c5:circle(position 0, radius 20)
}

flow {
repeat {
execute TestModel
} with
| just_testing |
|--------------|
| true |
| false |
}

0 comments on commit e729112

Please sign in to comment.