@@ -763,7 +763,7 @@ function parse_comparison(ps::ParseState, subtype_comparison=false)
763
763
mark = position (ps)
764
764
if subtype_comparison && is_reserved_word (peek (ps))
765
765
# Recovery
766
- # struct try end ==> (struct false (error (try)) (block))
766
+ # struct try end ==> (struct (error (try)) (block))
767
767
name = untokenize (peek (ps))
768
768
bump (ps)
769
769
emit (ps, mark, K " error" , error= " Invalid type name `$name `" )
@@ -1105,13 +1105,13 @@ function is_juxtapose(ps, prev_k, t)
1105
1105
! is_initial_reserved_word (ps, k)
1106
1106
end
1107
1107
1108
- # Juxtoposition. Ugh!
1108
+ # Juxtoposition. Ugh! But so useful for units and Field identities like `im`
1109
1109
#
1110
- # 2x ==> (call-i 2 * x)
1111
- # 2(x) ==> (call-i 2 * x)
1112
- # (2)(3)x ==> (call-i 2 * 3 x)
1113
- # (x-1)y ==> (call-i (call-i x - 1) * y)
1114
- # x'y ==> (call-i (call-post x ') * y)
1110
+ # 2x ==> (juxtapose 2 x)
1111
+ # 2(x) ==> (juxtapose 2 x)
1112
+ # (2)(3)x ==> (juxtapose 2 3 x)
1113
+ # (x-1)y ==> (juxtapose (call-i x - 1) y)
1114
+ # x'y ==> (juxtapose (call-post x ') y)
1115
1115
#
1116
1116
# flisp: parse-juxtapose
1117
1117
function parse_juxtapose (ps:: ParseState )
@@ -1124,15 +1124,12 @@ function parse_juxtapose(ps::ParseState)
1124
1124
if ! is_juxtapose (ps, prev_kind, t)
1125
1125
break
1126
1126
end
1127
- if n_terms == 1
1128
- bump_invisible (ps, K " *" )
1129
- end
1130
1127
if prev_kind == K " string" || is_string_delim (t)
1131
1128
# issue #20575
1132
1129
#
1133
- # "a""b" ==> (call-i (string "a") * (error-t) (string "b"))
1134
- # "a"x ==> (call-i (string "a") * (error-t) x)
1135
- # "$y"x ==> (call-i (string (string y)) * (error-t) x)
1130
+ # "a""b" ==> (juxtapose (string "a") (error-t) (string "b"))
1131
+ # "a"x ==> (juxtapose (string "a") (error-t) x)
1132
+ # "$y"x ==> (juxtapose (string (string y)) (error-t) x)
1136
1133
bump_invisible (ps, K " error" , TRIVIA_FLAG,
1137
1134
error= " cannot juxtapose string literal" )
1138
1135
end
@@ -1144,7 +1141,7 @@ function parse_juxtapose(ps::ParseState)
1144
1141
n_terms += 1
1145
1142
end
1146
1143
if n_terms > 1
1147
- emit (ps, mark, K "call " , INFIX_FLAG )
1144
+ emit (ps, mark, K "juxtapose " )
1148
1145
end
1149
1146
end
1150
1147
@@ -1767,8 +1764,8 @@ function parse_struct_field(ps::ParseState)
1767
1764
parse_eq (ps)
1768
1765
if const_field
1769
1766
# Const fields https://github.com/JuliaLang/julia/pull/43305
1770
- # v1.8: struct A const a end ==> (struct false A (block (const x)))
1771
- # v1.7: struct A const a end ==> (struct false A (block (error (const x))))
1767
+ # v1.8: struct A const a end ==> (struct A (block (const x)))
1768
+ # v1.7: struct A const a end ==> (struct A (block (error (const x))))
1772
1769
emit (ps, mark, K " const" )
1773
1770
min_supported_version (v " 1.8" , ps, mark, " `const` struct field" )
1774
1771
end
@@ -1823,23 +1820,21 @@ function parse_resword(ps::ParseState)
1823
1820
emit (ps, mark, K " for" )
1824
1821
elseif word == K " let"
1825
1822
bump (ps, TRIVIA_FLAG)
1826
- if peek (ps) ∉ KSet " NewlineWs ;"
1827
- # let x=1\n end ==> (let (block (= x 1)) (block))
1828
- # let x=1 ; end ==> (let (block (= x 1)) (block))
1829
- m = position (ps)
1830
- n_subexprs = parse_comma_separated (ps, parse_eq_star)
1831
- kb = peek_behind (ps). kind
1823
+ m = position (ps)
1824
+ if peek (ps) in KSet " NewlineWs ;"
1825
+ # let end ==> (let (block) (block))
1826
+ # let ; end ==> (let (block) (block))
1827
+ # let ; body end ==> (let (block) (block body))
1828
+ else
1829
+ # let x=1\n end ==> (let (block (= x 1)) (block))
1830
+ # let x=1 ; end ==> (let (block (= x 1)) (block))
1832
1831
# let x::1 ; end ==> (let (block (::-i x 1)) (block))
1833
1832
# let x ; end ==> (let (block x) (block))
1834
1833
# let x=1,y=2 ; end ==> (let (block (= x 1) (= y 2) (block)))
1835
1834
# let x+=1 ; end ==> (let (block (+= x 1)) (block))
1836
- emit (ps, m, K " block" )
1837
- else
1838
- # let end ==> (let (block) (block))
1839
- # let ; end ==> (let (block) (block))
1840
- # let ; body end ==> (let (block) (block body))
1841
- bump_invisible (ps, K " block" )
1835
+ parse_comma_separated (ps, parse_eq_star)
1842
1836
end
1837
+ emit (ps, m, K " block" )
1843
1838
k = peek (ps)
1844
1839
if k in KSet " NewlineWs ;"
1845
1840
bump (ps, TRIVIA_FLAG)
@@ -1934,24 +1929,23 @@ function parse_resword(ps::ParseState)
1934
1929
bump_closing_token (ps, K " end" )
1935
1930
emit (ps, mark, K " abstract" )
1936
1931
elseif word in KSet " struct mutable"
1937
- # struct A <: B \n a::X \n end ==> (struct false (<: A B) (block (::-i a X)))
1938
- # struct A \n a \n b \n end ==> (struct false A (block a b))
1939
- # v1.7: struct A const a end ==> (struct false A (block (error (const a))))
1940
- # v1.8: struct A const a end ==> (struct false A (block (const a)))
1941
- if word == K " mutable"
1942
- # mutable struct A end ==> (struct true A (block))
1932
+ # struct A <: B \n a::X \n end ==> (struct (<: A B) (block (::-i a X)))
1933
+ # struct A \n a \n b \n end ==> (struct A (block a b))
1934
+ # v1.7: struct A const a end ==> (struct A (block (error (const a))))
1935
+ # v1.8: struct A const a end ==> (struct A (block (const a)))
1936
+ is_mut = word == K " mutable"
1937
+ if is_mut
1938
+ # mutable struct A end ==> (struct-mut A (block))
1943
1939
bump (ps, TRIVIA_FLAG)
1944
- bump_invisible (ps, K " true" )
1945
1940
else
1946
- # struct A end ==> (struct false A (block))
1947
- bump_invisible (ps, K " false" )
1941
+ # struct A end ==> (struct A (block))
1948
1942
end
1949
1943
@check peek (ps) == K " struct"
1950
1944
bump (ps, TRIVIA_FLAG)
1951
1945
parse_subtype_spec (ps)
1952
1946
parse_block (ps, parse_struct_field)
1953
1947
bump_closing_token (ps, K " end" )
1954
- emit (ps, mark, K " struct" )
1948
+ emit (ps, mark, K " struct" , is_mut ? MUTABLE_FLAG : EMPTY_FLAGS )
1955
1949
elseif word == K " primitive"
1956
1950
# primitive type A 32 end ==> (primitive A 32)
1957
1951
# primitive type A 32 ; end ==> (primitive A 32)
@@ -1973,9 +1967,8 @@ function parse_resword(ps::ParseState)
1973
1967
bump (ps, TRIVIA_FLAG)
1974
1968
k = peek (ps)
1975
1969
if k == K " NewlineWs" || is_closing_token (ps, k)
1976
- # return\nx ==> (return nothing)
1977
- # return) ==> (return nothing)
1978
- bump_invisible (ps, K " nothing" )
1970
+ # return\nx ==> (return)
1971
+ # return) ==> (return)
1979
1972
else
1980
1973
# return x ==> (return x)
1981
1974
# return x,y ==> (return (tuple x y))
@@ -1992,22 +1985,22 @@ function parse_resword(ps::ParseState)
1992
1985
error= " unexpected token after $(untokenize (word)) " )
1993
1986
end
1994
1987
elseif word in KSet " module baremodule"
1995
- # module A end ==> (module true A (block))
1996
- # baremodule A end ==> (module false A (block))
1988
+ # module A end ==> (module A (block))
1989
+ # baremodule A end ==> (module-bare A (block))
1997
1990
bump (ps, TRIVIA_FLAG)
1998
- bump_invisible (ps, (word == K " module" ) ? K " true" : K " false" )
1999
1991
if is_reserved_word (peek (ps))
2000
- # module do \n end ==> (module true (error do) (block))
1992
+ # module do \n end ==> (module (error do) (block))
2001
1993
bump (ps, error= " Invalid module name" )
2002
1994
else
2003
- # module $A end ==> (module true ($ A) (block))
1995
+ # module $A end ==> (module ($ A) (block))
2004
1996
parse_unary_prefix (ps)
2005
1997
end
2006
- # module A \n a \n b \n end ==> (module true A (block a b))
2007
- # module A \n "x"\na \n end ==> (module true A (block (doc (string "x") a)))
1998
+ # module A \n a \n b \n end ==> (module A (block a b))
1999
+ # module A \n "x"\na \n end ==> (module A (block (doc (string "x") a)))
2008
2000
parse_block (ps, parse_docstring)
2009
2001
bump_closing_token (ps, K " end" )
2010
- emit (ps, mark, K " module" )
2002
+ emit (ps, mark, K " module" ,
2003
+ word == K " baremodule" ? BARE_MODULE_FLAG : EMPTY_FLAGS)
2011
2004
elseif word == K " export"
2012
2005
# export a ==> (export a)
2013
2006
# export @a ==> (export @a)
0 commit comments