Skip to content

Commit 0cfb970

Browse files
authored
Format files using DocumentFormat
1 parent 93225f9 commit 0cfb970

21 files changed

+431
-426
lines changed

docs/make.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ makedocs(;
77
repo="https://github.com/julia-vscode/CSTParser.jl/blob/{commit}{path}#L{line}",
88
sitename="CSTParser.jl",
99
format=Documenter.HTML(;
10-
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
10+
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true"
1111
# canonical="https://www.julia-vscode.org/CSTParser.jl",
1212
# assets=String[],
1313
),
1414
pages=[
1515
"Home" => "index.md",
1616
"Syntax Reference" => "syntax.md",
17-
],
17+
]
1818
)
1919

2020
deploydocs(;
21-
repo="github.com/julia-vscode/CSTParser.jl",
21+
repo="github.com/julia-vscode/CSTParser.jl"
2222
)

src/CSTParser.jl

Lines changed: 10 additions & 10 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_const_field=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_const_field=allow_const_field)
5252
elseif kindof(ps.t) === Tokens.LPAREN
5353
ret = parse_paren(ps)
5454
elseif kindof(ps.t) === Tokens.LSQUARE
@@ -143,9 +143,9 @@ function parse_compound(ps::ParseState, ret::EXPR)
143143
# prime operator followed by an identifier has an implicit multiplication
144144
nextarg = @precedence ps TimesOp parse_expression(ps)
145145
ret = EXPR(:call, EXPR[EXPR(:OPERATOR, 0, 0, "*"), ret, nextarg], nothing)
146-
# ###############################################################################
147-
# Everything below here is an error
148-
# ###############################################################################
146+
# ###############################################################################
147+
# Everything below here is an error
148+
# ###############################################################################
149149
else
150150
ps.errored = true
151151
if kindof(ps.nt) in (Tokens.RPAREN, Tokens.RSQUARE, Tokens.RBRACE)
@@ -173,7 +173,7 @@ Parses an expression starting with a `(`.
173173
function parse_paren(ps::ParseState)
174174
args = EXPR[]
175175
trivia = EXPR[EXPR(ps)]
176-
@closeparen ps @default ps @nocloser ps :inwhere parse_comma_sep(ps, args, trivia, false, true, true, insert_params_at = 1)
176+
@closeparen ps @default ps @nocloser ps :inwhere parse_comma_sep(ps, args, trivia, false, true, true, insert_params_at=1)
177177
if length(args) == 1 && length(trivia) == 1 && ((kindof(ps.ws) !== SemiColonWS || headof(args[1]) === :block) && headof(args[1]) !== :parameters)
178178
accept_rparen(ps, trivia)
179179
ret = EXPR(:brackets, args, trivia)
@@ -292,10 +292,10 @@ end
292292

293293
function _continue_doc_parse(ps::ParseState, x::EXPR)
294294
kindof(ps.nt) !== Tokens.ENDMARKER &&
295-
headof(x) === :macrocall &&
296-
valof(x.args[1]) == "@doc" &&
297-
length(x.args) < 4 &&
298-
ps.t.endpos[1] + 1 == ps.nt.startpos[1]
295+
headof(x) === :macrocall &&
296+
valof(x.args[1]) == "@doc" &&
297+
length(x.args) < 4 &&
298+
ps.t.endpos[1] + 1 == ps.nt.startpos[1]
299299
end
300300

301301
include("precompile.jl")

src/components/internals.jl

Lines changed: 10 additions & 10 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_const_field=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_const_field=allow_const_field)
2121
end
2222
push!(ret, a)
2323
end
@@ -31,7 +31,7 @@ Parses an iterator, allowing for the preceding keyword `outer`. Returns an
3131
error expression if an invalid expression is parsed (anything other than
3232
`=`, `in`, `∈`).
3333
"""
34-
function parse_iterator(ps::ParseState, outer = parse_outer(ps))
34+
function parse_iterator(ps::ParseState, outer=parse_outer(ps))
3535
arg = @closer ps :range @closer ps :ws @nocloser ps :wsop parse_expression(ps)
3636
if !is_range(arg)
3737
arg = mErrorToken(ps, arg, InvalidIterator)
@@ -135,7 +135,7 @@ function parse_call(ps::ParseState, ret::EXPR, ismacro=false)
135135
end
136136
# args = ismacro ? EXPR[ret, EXPR(:NOTHING, 0, 0)] : EXPR[ret]
137137
trivia = EXPR[EXPR(next(ps))]
138-
@closeparen ps @default ps parse_comma_sep(ps, args, trivia, !ismacro, insert_params_at = ismacro ? 3 : 2)
138+
@closeparen ps @default ps parse_comma_sep(ps, args, trivia, !ismacro, insert_params_at=ismacro ? 3 : 2)
139139
accept_rparen(ps, trivia)
140140
ret = EXPR(ismacro ? :macrocall : syntaxcall ? ret : :call, args, trivia)
141141
end
@@ -146,7 +146,7 @@ end
146146
Parses a comma separated list, optionally allowing for conversion of
147147
assignment (`=`) expressions to `Kw`.
148148
"""
149-
function parse_comma_sep(ps::ParseState, args::Vector{EXPR}, trivia::Vector{EXPR}, kw = true, block = false, istuple = false; insert_params_at = 2)
149+
function parse_comma_sep(ps::ParseState, args::Vector{EXPR}, trivia::Vector{EXPR}, kw=true, block=false, istuple=false; insert_params_at=2)
150150
prevpos = position(ps)
151151
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !closer(ps)
152152
a = parse_expression(ps)
@@ -205,11 +205,11 @@ end
205205
206206
Parses parameter arguments for a function call (e.g. following a semicolon).
207207
"""
208-
function parse_parameters(ps::ParseState, args::Vector{EXPR}, args1::Vector{EXPR} = EXPR[], insert_params_at = 2; usekw = true)
208+
function parse_parameters(ps::ParseState, args::Vector{EXPR}, args1::Vector{EXPR}=EXPR[], insert_params_at=2; usekw=true)
209209
trivia = EXPR[]
210210
isfirst = isempty(args1)
211211
prevpos = position(ps)
212-
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !isfirst || (@nocloser ps :semicolon !closer(ps))
212+
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !isfirst || (@nocloser ps :semicolon !closer(ps))
213213
a = isfirst ? parse_expression(ps) : first(args1)
214214
if usekw && _do_kw_convert(ps, a)
215215
a = _kw_convert(a)
@@ -347,7 +347,7 @@ end
347347
function get_appropriate_child_to_expand(x)
348348
if headof(x) === :generator && !(headof(x.args[1]) in (:generator, :flatten))
349349
return x, x.args[1]
350-
elseif headof(x) === :flatten && headof(x.args[1]) === :generator && headof(x.args[1].args[1]) === :generator
350+
elseif headof(x) === :flatten && headof(x.args[1]) === :generator && headof(x.args[1].args[1]) === :generator
351351
x.args[1], x.args[1].args[1]
352352
else
353353
get_appropriate_child_to_expand(x.args[1])
@@ -365,7 +365,7 @@ function parse_nonstd_identifier(ps)
365365
end
366366
end
367367

368-
function parse_importexport_item(ps, is_colon = false)
368+
function parse_importexport_item(ps, is_colon=false)
369369
if kindof(ps.nt) === Tokens.AT_SIGN
370370
parse_macroname(next(ps))
371371
elseif kindof(ps.nt) === Tokens.LPAREN
@@ -377,7 +377,7 @@ function parse_importexport_item(ps, is_colon = false)
377377
parse_unary(ps, INSTANCE(next(ps)))
378378
elseif !is_colon && isoperator(ps.nt)
379379
next(ps)
380-
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
380+
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
381381
elseif is_nonstd_identifier(ps)
382382
parse_nonstd_identifier(ps)
383383
else

src/components/keywords.jl

Lines changed: 10 additions & 10 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_const_field=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_const_field=allow_const_field)
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_const_field=true)
7979
elseif k === Tokens.MUTABLE
8080
return @default ps @closer ps :block parse_mutable(ps)
8181
elseif k === Tokens.OUTER
@@ -85,7 +85,7 @@ 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_const_field=false)
8989
kw = EXPR(ps)
9090
arg = parse_expression(ps)
9191
if !allow_const_field && !(isassignment(unwrapbracket(arg)) || (headof(arg) === :global && length(arg.args) > 0 && isassignment(unwrapbracket(arg.args[1]))))
@@ -95,7 +95,7 @@ function parse_const(ps::ParseState; allow_const_field = false)
9595
return ret
9696
end
9797

98-
function parse_local_global(ps::ParseState, islocal = true)
98+
function parse_local_global(ps::ParseState, islocal=true)
9999
kw = EXPR(ps)
100100
if ps.nt.kind === Tokens.CONST
101101
arg1 = parse_const(next(ps))
@@ -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_const_field=true)
158158
pushfirst!(ret.trivia, setparent!(kw, ret))
159159
update_span!(ret)
160160
else
@@ -313,10 +313,10 @@ end
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_const_field=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_const_field=allow_const_field)
320320
if head === :begin
321321
EXPR(:block, blockargs, EXPR[kw, accept_end(ps)])
322322
elseif sig === nothing
@@ -347,7 +347,7 @@ end
347347
348348
Parse an `if` block.
349349
"""
350-
function parse_if(ps::ParseState, nested = false)
350+
function parse_if(ps::ParseState, nested=false)
351351
args = EXPR[]
352352
trivia = EXPR[EXPR(ps)]
353353

@@ -417,7 +417,7 @@ function parse_try(ps::ParseState)
417417
args[3] = EXPR(:block, 0, 0, "")
418418
end
419419
else_trivia = EXPR(next(ps))
420-
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY,Tokens.END)))
420+
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY, Tokens.END)))
421421
end
422422

423423
has_finally = false

src/components/lists.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function parse_tuple(ps::ParseState, ret::EXPR)
4646
end
4747

4848
# XXX: Avert thine eyes.
49-
function count_semicolons(ps, check_newline = true)
49+
function count_semicolons(ps, check_newline=true)
5050
dims = 0
5151
has_newline = false
5252
old_pos = position(ps.l.io)
@@ -75,7 +75,7 @@ Having hit '[' return either:
7575
+ A comprehension
7676
+ An array (vcat of hcats)
7777
"""
78-
function parse_array(ps::ParseState, isref = false)
78+
function parse_array(ps::ParseState, isref=false)
7979
args = EXPR[]
8080
trivia = EXPR[EXPR(ps)]
8181
# [] or [;;;]
@@ -100,7 +100,7 @@ function parse_array(ps::ParseState, isref = false)
100100
end
101101
end
102102

103-
binding_power(ps, nl = true) =
103+
binding_power(ps, nl=true) =
104104
if kindof(ps.ws) == SemiColonWS
105105
-count_semicolons(ps, nl)
106106
elseif kindof(ps.ws) == NewLineWS
@@ -150,7 +150,7 @@ function parse_array_outer(ps::ParseState, trivia, isref)
150150
args = EXPR[]
151151
push!(args, a)
152152
push!(trivia, accept_comma(ps))
153-
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at = 1)
153+
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at=1)
154154
return EXPR(:vect, args, trivia)
155155
end
156156
end
@@ -307,7 +307,7 @@ function parse_barray(ps::ParseState)
307307
accept_rbrace(ps, trivia)
308308
ret = EXPR(:braces, args, trivia)
309309
else
310-
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
310+
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
311311
if kindof(ps.nt) === Tokens.RBRACE
312312
push!(args, first_arg)
313313
if kindof(ps.ws) == SemiColonWS
@@ -318,15 +318,15 @@ function parse_barray(ps::ParseState)
318318
elseif iscomma(ps.nt)
319319
push!(args, first_arg)
320320
accept_comma(ps, trivia)
321-
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at = 1)
321+
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at=1)
322322
accept_rbrace(ps, trivia)
323323
return EXPR(:braces, args, trivia)
324324
elseif kindof(ps.ws) == NewLineWS
325325
ret = EXPR(:bracescat, args, trivia)
326326
push!(ret, first_arg)
327327
prevpos = position(ps)
328328
while kindof(ps.nt) != Tokens.RBRACE && kindof(ps.nt) !== Tokens.ENDMARKER
329-
a = @closebrace ps parse_expression(ps)
329+
a = @closebrace ps parse_expression(ps)
330330
push!(ret, a)
331331
prevpos = loop_check(ps, prevpos)
332332
end

0 commit comments

Comments
 (0)