File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -389,12 +389,20 @@ def _read_interop(ctx: ReaderContext, end_token: str) -> llist.List:
389
389
elif token == '-' :
390
390
reader .advance ()
391
391
seq .append (_INTEROP_PROP )
392
+
393
+ # If whitespace immediately follows, this is the form
394
+ # (.- object member ...), otherwise it is (.-member object ...).
395
+ # We need to support both, as the former is more commonly
396
+ # the format which will appear in macros.
392
397
if whitespace_chars .match (reader .peek ()):
393
- raise SyntaxError (f"Expected Symbol; found whitespace" )
394
- member = _read_next_consuming_comment (ctx )
395
- if not isinstance (member , symbol .Symbol ):
396
- raise SyntaxError (f"Expected Symbol; found { type (member )} " )
397
- instance = _read_next_consuming_comment (ctx )
398
+ instance = _read_next_consuming_comment (ctx )
399
+ member = _read_next_consuming_comment (ctx )
400
+ else :
401
+ member = _read_next_consuming_comment (ctx )
402
+ if not isinstance (member , symbol .Symbol ):
403
+ raise SyntaxError (f"Expected Symbol; found { type (member )} " )
404
+ instance = _read_next_consuming_comment (ctx )
405
+
398
406
seq .append (instance )
399
407
seq .append (member )
400
408
else :
Original file line number Diff line number Diff line change @@ -586,13 +586,14 @@ def test_interop_call():
586
586
587
587
588
588
def test_interop_prop ():
589
- assert read_str_first ("(. sym -name)" ) == llist .l (
590
- sym .symbol ('.-' ), sym .symbol ('sym' ), sym .symbol ('name' ))
591
- assert read_str_first ('(.-algorithm encoder)' ) == llist .l (
592
- sym .symbol ('.-' ), sym .symbol ('encoder' ), sym .symbol ('algorithm' ))
593
-
594
- with pytest .raises (reader .SyntaxError ):
595
- read_str_first ('(.- name sym)' )
589
+ assert llist .l (sym .symbol ('.-' ), sym .symbol ('sym' ), sym .symbol ('name' )
590
+ ) == read_str_first ("(. sym -name)" )
591
+ assert llist .l (sym .symbol ('.-' ), sym .symbol ('encoder' ), sym .symbol ('algorithm' )
592
+ ) == read_str_first ('(.-algorithm encoder)' )
593
+ assert llist .l (sym .symbol ('.-' ), sym .symbol ('name' ), sym .symbol ('sym' )
594
+ ) == read_str_first ('(.- name sym)' )
595
+ assert llist .l (sym .symbol ('.-' ), sym .symbol ('name' ), "string"
596
+ ) == read_str_first ('(.- name "string")' )
596
597
597
598
with pytest .raises (reader .SyntaxError ):
598
599
read_str_first ('(.-"string" sym)' )
You can’t perform that action at this time.
0 commit comments