Skip to content

Commit c015463

Browse files
committed
parse juxtapositions involving string literals as calls to string()
examples: "" x "" => string(x) 1+2 " equals " 3 "" x y z "" only happens in non-space-sensitive contexts, so macro calls and hcat are not affected. empty string literals are removed.
1 parent 98fd41c commit c015463

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/julia-parser.scm

+17-6
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,22 @@
419419
(if (not (eq? (take-token s) ':))
420420
(error "colon expected in ? expression")
421421
(list 'if ex then (parse-cond s))))))
422-
#;((string? ex)
423-
(let loop ((args (list ex)))
422+
((and (or (string? ex) (eqv? (peek-token s) #\"))
423+
(not space-sensitive))
424+
(let parse-strcat ((args (list ex)))
424425
(let ((next (peek-token s)))
425-
(if (or (eof-object? next) (closing-token? next)
426-
(newline? next))
427-
`(call (top string) ,@(reverse args))
428-
(loop (cons (parse-or s) args))))))
426+
(if (or (closing-token? next)
427+
(and (not range-colon-enabled)
428+
(eq? next ':))
429+
(and (not whitespace-newline)
430+
(newline? next)))
431+
(if (length= args 1)
432+
(car args)
433+
`(call (top string)
434+
,@(reverse (filter (lambda (x)
435+
(not (equal? x "")))
436+
args))))
437+
(parse-strcat (cons (parse-or s) args))))))
429438
(else ex))))
430439

431440
(define (invalid-initial-token? tok)
@@ -640,6 +649,8 @@
640649
(not (memq t reserved-words))
641650
(not (closing-token? t))
642651
(not (newline? t))
652+
(not (string? expr))
653+
(not (eqv? t #\"))
643654
(or (number? expr)
644655
(not (memv t '(#\( #\[ #\{))))))
645656

0 commit comments

Comments
 (0)