@@ -1488,13 +1488,23 @@ function parse_unary_prefix(ps::ParseState, has_unary_prefix=false)
14881488 end
14891489end
14901490
1491- function maybe_parsed_macro_name(ps, processing_macro_name, mark)
1491+ function maybe_parsed_macro_name (ps, processing_macro_name, last_identifier_orig_kind, mark)
14921492 if processing_macro_name
14931493 emit (ps, mark, K " macro_name" )
1494+ maybe_parsed_special_macro (ps, last_identifier_orig_kind)
14941495 end
14951496 return false
14961497end
14971498
1499+ function maybe_parsed_special_macro (ps, last_identifier_orig_kind)
1500+ is_syntax_version_macro = last_identifier_orig_kind == K " VERSION"
1501+ if is_syntax_version_macro && ps. stream. version >= (1 , 14 )
1502+ # Encode the current parser version into an invisible token
1503+ bump_invisible (ps, K " VERSION" ,
1504+ set_numeric_flags (ps. stream. version[2 ] * 10 ))
1505+ end
1506+ end
1507+
14981508# Parses a chain of suffixes at function call precedence, leftmost binding
14991509# tightest. This handles
15001510# * Bracketed calls like a() b[] c{}
@@ -1543,7 +1553,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
15431553 # @+x y ==> (macrocall (macro_name +) x y)
15441554 # A.@.x ==> (macrocall (. A (macro_name .)) x)
15451555 processing_macro_name = maybe_parsed_macro_name (
1546- ps, processing_macro_name, mark)
1556+ ps, processing_macro_name, last_identifier_orig_kind, mark)
15471557 let ps = with_space_sensitive (ps)
15481558 # Space separated macro arguments
15491559 # A.@foo a b ==> (macrocall (. A (macro_name foo)) a b)
@@ -1577,7 +1587,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
15771587 # (a=1)() ==> (call (parens (= a 1)))
15781588 # f (a) ==> (call f (error-t) a)
15791589 processing_macro_name = maybe_parsed_macro_name (
1580- ps, processing_macro_name, mark)
1590+ ps, processing_macro_name, last_identifier_orig_kind, mark)
15811591 bump_disallowed_space (ps)
15821592 bump (ps, TRIVIA_FLAG)
15831593 opts = parse_call_arglist (ps, K " )" )
@@ -1598,7 +1608,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
15981608 end
15991609 elseif k == K " ["
16001610 processing_macro_name = maybe_parsed_macro_name (
1601- ps, processing_macro_name, mark)
1611+ ps, processing_macro_name, last_identifier_orig_kind, mark)
16021612 m = position (ps)
16031613 # a [i] ==> (ref a (error-t) i)
16041614 bump_disallowed_space (ps)
@@ -1666,7 +1676,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
16661676 if is_macrocall
16671677 # Recover by pretending we do have the syntax
16681678 processing_macro_name = maybe_parsed_macro_name (
1669- ps, processing_macro_name, mark)
1679+ ps, processing_macro_name, last_identifier_orig_kind, mark)
16701680 # @M.(x) ==> (macrocall (dotcall (macro_name M) (error-t) x))
16711681 bump_invisible (ps, K " error" , TRIVIA_FLAG)
16721682 emit_diagnostic (ps, mark,
@@ -1720,6 +1730,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
17201730 macro_atname_range = (m, position (ps))
17211731 is_macrocall = true
17221732 emit (ps, mark, K " ." )
1733+ maybe_parsed_special_macro (ps, last_identifier_orig_kind)
17231734 elseif k == K " '"
17241735 # f.' => (dotcall-post f (error '))
17251736 bump (ps, remap_kind= K " Identifier" ) # bump '
@@ -1760,7 +1771,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
17601771 emit (ps, mark, K " call" , POSTFIX_OP_FLAG)
17611772 elseif k == K " {"
17621773 processing_macro_name = maybe_parsed_macro_name (
1763- ps, processing_macro_name, mark)
1774+ ps, processing_macro_name, last_identifier_orig_kind, mark)
17641775 # Type parameter curlies and macro calls
17651776 m = position (ps)
17661777 # S {a} ==> (curly S (error-t) a)
@@ -2065,6 +2076,13 @@ function parse_resword(ps::ParseState)
20652076 # module do \n end ==> (module (error do) (block))
20662077 bump (ps, error= " Invalid module name" )
20672078 else
2079+ if ps. stream. version >= (1 , 14 )
2080+ # Encode the parser version that parsed this module - the runtime
2081+ # will use this to set the same parser version for runtime `include`
2082+ # etc into this module.
2083+ bump_invisible (ps, K " VERSION" ,
2084+ set_numeric_flags (ps. stream. version[2 ] * 10 ))
2085+ end
20682086 # module $A end ==> (module ($ A) (block))
20692087 parse_unary_prefix (ps)
20702088 end
0 commit comments