Skip to content

Commit 79d5733

Browse files
committed
NFC: rename allow_const_field -> allow_no_assignment
1 parent f8b47ef commit 79d5733

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/CSTParser.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Acceptable starting tokens are:
3838
+ An `@`.
3939
4040
"""
41-
function parse_expression(ps::ParseState, esc_on_error = false; allow_const_field = false)
41+
function parse_expression(ps::ParseState, esc_on_error = false; allow_no_assignment = false)
4242
if kindof(ps.nt) === Tokens.ENDMARKER
4343
ret = mErrorToken(ps, UnexpectedToken)
4444
elseif (esc_on_error && ps.nt.kind == Tokens.ERROR)
@@ -48,7 +48,7 @@ function parse_expression(ps::ParseState, esc_on_error = false; allow_const_fiel
4848
else
4949
next(ps)
5050
if iskeyword(kindof(ps.t)) && kindof(ps.t) != Tokens.DO
51-
ret = parse_kw(ps; allow_const_field = allow_const_field)
51+
ret = parse_kw(ps; allow_no_assignment = allow_no_assignment)
5252
elseif kindof(ps.t) === Tokens.LPAREN
5353
ret = parse_paren(ps)
5454
elseif kindof(ps.t) === Tokens.LSQUARE

src/components/internals.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const term_c = (Tokens.RPAREN, Tokens.RSQUARE, Tokens.RBRACE, Tokens.END, Tokens
44
Continue parsing statements until an element of `closers` is hit (usually
55
`end`). Statements are grouped in a `Block` EXPR.
66
"""
7-
function parse_block(ps::ParseState, ret::Vector{EXPR}=EXPR[], closers=(Tokens.END,), docable=false; allow_const_field = false)
7+
function parse_block(ps::ParseState, ret::Vector{EXPR}=EXPR[], closers=(Tokens.END,), docable=false; allow_no_assignment = false)
88
prevpos = position(ps)
99
while kindof(ps.nt) closers # loop until an expected closer is hit
1010
if kindof(ps.nt) term_c # error handling if an unexpected closer is hit
@@ -17,7 +17,7 @@ function parse_block(ps::ParseState, ret::Vector{EXPR}=EXPR[], closers=(Tokens.E
1717
if docable
1818
a = parse_doc(ps)
1919
else
20-
a = parse_expression(ps; allow_const_field = allow_const_field)
20+
a = parse_expression(ps; allow_no_assignment = allow_no_assignment)
2121
end
2222
push!(ret, a)
2323
end

src/components/keywords.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Dispatch function for when the parser has reached a keyword.
55
"""
6-
function parse_kw(ps::ParseState; allow_const_field = false)
6+
function parse_kw(ps::ParseState; allow_no_assignment = false)
77
k = kindof(ps.t)
88
if ps.closer.precedence == 20 && ps.lt.kind === Tokens.EX_OR && k !== Tokens.END
99
return EXPR(:IDENTIFIER, ps)
@@ -52,7 +52,7 @@ function parse_kw(ps::ParseState; allow_const_field = false)
5252
elseif k === Tokens.BAREMODULE
5353
return @default ps @closer ps :block parse_blockexpr(ps, :baremodule)
5454
elseif k === Tokens.CONST
55-
return @default ps parse_const(ps; allow_const_field = allow_const_field)
55+
return @default ps parse_const(ps; allow_no_assignment = allow_no_assignment)
5656
elseif k === Tokens.GLOBAL
5757
return @default ps parse_local_global(ps, false)
5858
elseif k === Tokens.LOCAL
@@ -75,7 +75,7 @@ function parse_kw(ps::ParseState; allow_const_field = false)
7575
elseif k === Tokens.TYPE
7676
return EXPR(:IDENTIFIER, ps)
7777
elseif k === Tokens.STRUCT
78-
return @default ps @closer ps :block parse_blockexpr(ps, :struct, allow_const_field = true)
78+
return @default ps @closer ps :block parse_blockexpr(ps, :struct, allow_no_assignment = true)
7979
elseif k === Tokens.MUTABLE
8080
return @default ps @closer ps :block parse_mutable(ps)
8181
elseif k === Tokens.OUTER
@@ -85,10 +85,10 @@ function parse_kw(ps::ParseState; allow_const_field = false)
8585
end
8686
end
8787

88-
function parse_const(ps::ParseState; allow_const_field = false)
88+
function parse_const(ps::ParseState; allow_no_assignment = false)
8989
kw = EXPR(ps)
9090
arg = parse_expression(ps)
91-
if !allow_const_field && !(isassignment(unwrapbracket(arg)) || (headof(arg) === :global && length(arg.args) > 0 && isassignment(unwrapbracket(arg.args[1]))))
91+
if !allow_no_assignment && !(isassignment(unwrapbracket(arg)) || (headof(arg) === :global && length(arg.args) > 0 && isassignment(unwrapbracket(arg.args[1]))))
9292
arg = mErrorToken(ps, arg, ExpectedAssignment)
9393
end
9494
ret = EXPR(:const, EXPR[arg], EXPR[kw])
@@ -154,7 +154,7 @@ function parse_mutable(ps::ParseState)
154154
if kindof(ps.nt) === Tokens.STRUCT
155155
kw = EXPR(ps)
156156
next(ps)
157-
ret = parse_blockexpr(ps, :mutable, allow_const_field = true)
157+
ret = parse_blockexpr(ps, :mutable, allow_no_assignment = true)
158158
pushfirst!(ret.trivia, setparent!(kw, ret))
159159
update_span!(ret)
160160
else
@@ -308,15 +308,15 @@ function parse_do(ps::ParseState, pre::EXPR)
308308
end
309309

310310
"""
311-
parse_blockexpr(ps::ParseState, head; allow_const_field = false)
311+
parse_blockexpr(ps::ParseState, head; allow_no_assignment = false)
312312
313313
General function for parsing block expressions comprised of a series of statements
314314
terminated by an `end`.
315315
"""
316-
function parse_blockexpr(ps::ParseState, head; allow_const_field = false)
316+
function parse_blockexpr(ps::ParseState, head; allow_no_assignment = false)
317317
kw = EXPR(ps)
318318
sig = parse_blockexpr_sig(ps, head)
319-
blockargs = parse_block(ps, EXPR[], (Tokens.END,), docable(head); allow_const_field = allow_const_field)
319+
blockargs = parse_block(ps, EXPR[], (Tokens.END,), docable(head); allow_no_assignment = allow_no_assignment)
320320
if head === :begin
321321
EXPR(:block, blockargs, EXPR[kw, accept_end(ps)])
322322
elseif sig === nothing

0 commit comments

Comments
 (0)