Skip to content

Commit 8a5349f

Browse files
committed
Fix whitespace in strings
1 parent 717aa11 commit 8a5349f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def build():
9898
omitted_parameter:STAR
9999
enumeration: "." keyword "."
100100
binary: "\"" ("0"|"1"|"2"|"3") (HEX)* "\""
101-
string: "'" (REVERSE_SOLIDUS REVERSE_SOLIDUS|SPECIAL|DIGIT|LOWER|UPPER|CONTROL_DIRECTIVE|"\\*\\")* "'"
101+
string: "'" (REVERSE_SOLIDUS REVERSE_SOLIDUS|SPECIAL|DIGIT|SPACE|LOWER|UPPER|CONTROL_DIRECTIVE|"\\*\\")* "'"
102102
103103
STAR: "*"
104104
SLASH: "/"
@@ -139,7 +139,7 @@ def build():
139139
INT: SIGN? DIGIT (DIGIT)*
140140
CONTROL_DIRECTIVE: PAGE | ALPHABET | EXTENDED2 | EXTENDED4 | ARBITRARY
141141
PAGE : REVERSE_SOLIDUS "S" REVERSE_SOLIDUS LATIN_CODEPOINT
142-
LATIN_CODEPOINT : DIGIT | LOWER | UPPER | SPECIAL | REVERSE_SOLIDUS | APOSTROPHE
142+
LATIN_CODEPOINT : SPACE | DIGIT | LOWER | UPPER | SPECIAL | REVERSE_SOLIDUS | APOSTROPHE
143143
ALPHABET : REVERSE_SOLIDUS "P" UPPER REVERSE_SOLIDUS
144144
EXTENDED2: REVERSE_SOLIDUS "X2" REVERSE_SOLIDUS (HEX_TWO)* END_EXTENDED
145145
EXTENDED4 :REVERSE_SOLIDUS "X4" REVERSE_SOLIDUS (HEX_FOUR)* END_EXTENDED
@@ -173,9 +173,9 @@ def build():
173173
ESCAPE : "\\" ( "$" | "\"" | CHAR )
174174
CHAR : /[^$"\n]/
175175
WORD : CHAR+
176-
WS: /[ \t\f\r\n]/+
176+
SPACE.10 : " "
177177
178-
%ignore WS
178+
%ignore /[ \t\f\r\n]/+
179179
"""
180180

181181

@@ -205,7 +205,7 @@ def id(self, s):
205205
return int(s[0][1:])
206206

207207
def string(self, s):
208-
word = "".join(s)
208+
word = "".join(s).replace("''", "'")
209209
return word
210210

211211
def keyword(self, s):

fixtures/pass_1.ifc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ FILE_NAME('','2022-05-04T08:08:30',(''),(''),'IfcOpenShell-0.7.0','IfcOpenShell-
55
FILE_SCHEMA(('IFC4'));
66
ENDSEC;
77
DATA;
8-
#1=IFCPERSON($,$,'',$,$,$,$,$);
8+
#1=IFCPERSON($, $,'',$,$,$,$,$);
99
#2=IFCORGANIZATION($,'',$,$,$);
1010
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
1111
#4=IFCAPPLICATION(#2,'0.7.0','IfcOpenShell-0.7.0','');
12+
#100=IFCAPPLICATION(#2,'0.7.0','Nested '' quotes','');
1213
#5=IFCOWNERHISTORY(#3,#4,$,.ADDED.,$,#3,#4,1651651710);
1314
#6=IFCDIRECTION((1.,0.,0.));
1415
#7=IFCDIRECTION((0.,0.,1.));

test_parser.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ def test_parse_features():
3030
assert f.by_id(1).type == 'IFCPERSON'
3131
assert f.by_type('ifcperson')[0].id == 1
3232
assert f[1][0] is None
33+
assert f.header.file_description[0][0] == 'ViewDefinition [CoordinationView]'
34+
assert f.by_type('ifcapplication')[1][2] == "Nested ' quotes"

0 commit comments

Comments
 (0)