Skip to content

Commit 1a8dba3

Browse files
authored
Format files using DocumentFormat
1 parent 89efdcb commit 1a8dba3

21 files changed

+423
-418
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: 9 additions & 9 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)
41+
function parse_expression(ps::ParseState, esc_on_error=false)
4242
if kindof(ps.nt) === Tokens.ENDMARKER
4343
ret = mErrorToken(ps, UnexpectedToken)
4444
elseif (esc_on_error && ps.nt.kind == Tokens.ERROR)
@@ -147,9 +147,9 @@ function parse_compound(ps::ParseState, ret::EXPR)
147147
# prime operator followed by an identifier has an implicit multiplication
148148
nextarg = @precedence ps TimesOp parse_expression(ps)
149149
ret = EXPR(:call, EXPR[EXPR(:OPERATOR, 0, 0, "*"), ret, nextarg], nothing)
150-
# ###############################################################################
151-
# Everything below here is an error
152-
# ###############################################################################
150+
# ###############################################################################
151+
# Everything below here is an error
152+
# ###############################################################################
153153
else
154154
ps.errored = true
155155
if kindof(ps.nt) in (Tokens.RPAREN, Tokens.RSQUARE, Tokens.RBRACE)
@@ -177,7 +177,7 @@ Parses an expression starting with a `(`.
177177
function parse_paren(ps::ParseState)
178178
args = EXPR[]
179179
trivia = EXPR[EXPR(ps)]
180-
@closeparen ps @default ps @nocloser ps :inwhere parse_comma_sep(ps, args, trivia, false, true, true, insert_params_at = 1)
180+
@closeparen ps @default ps @nocloser ps :inwhere parse_comma_sep(ps, args, trivia, false, true, true, insert_params_at=1)
181181
if length(args) == 1 && length(trivia) == 1 && ((kindof(ps.ws) !== SemiColonWS || headof(args[1]) === :block) && headof(args[1]) !== :parameters)
182182
accept_rparen(ps, trivia)
183183
ret = EXPR(:brackets, args, trivia)
@@ -296,10 +296,10 @@ end
296296

297297
function _continue_doc_parse(ps::ParseState, x::EXPR)
298298
kindof(ps.nt) !== Tokens.ENDMARKER &&
299-
headof(x) === :macrocall &&
300-
valof(x.args[1]) == "@doc" &&
301-
length(x.args) < 4 &&
302-
ps.t.endpos[1] + 1 == ps.nt.startpos[1]
299+
headof(x) === :macrocall &&
300+
valof(x.args[1]) == "@doc" &&
301+
length(x.args) < 4 &&
302+
ps.t.endpos[1] + 1 == ps.nt.startpos[1]
303303
end
304304

305305
include("precompile.jl")

src/components/internals.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ function parse_const(ps::ParseState)
9494
nt = ps.nt
9595
arg = parse_expression(ps)
9696
allow_no_assignment = has_flag(ps, ParserFlags.AllowConstWithoutAssignment) ||
97-
has_flag(ps, ParserFlags.InQuote) && (kindof(nt) === Tokens.GLOBAL || kindof(lt) === Tokens.GLOBAL)
97+
has_flag(ps, ParserFlags.InQuote) && (kindof(nt) === Tokens.GLOBAL || kindof(lt) === Tokens.GLOBAL)
9898
if !allow_no_assignment && !(isassignment(unwrapbracket(arg)) || (headof(arg) === :global && length(arg.args) > 0 && isassignment(unwrapbracket(arg.args[1]))))
9999
arg = mErrorToken(ps, arg, ExpectedAssignment)
100100
end
101101
ret = EXPR(:const, EXPR[arg], EXPR[kw])
102102
return ret
103103
end
104104

105-
function parse_local_global(ps::ParseState, islocal = true)
105+
function parse_local_global(ps::ParseState, islocal=true)
106106
kw = EXPR(ps)
107107
if ps.nt.kind === Tokens.CONST
108108
arg1 = parse_const(next(ps))
@@ -358,7 +358,7 @@ end
358358
359359
Parse an `if` block.
360360
"""
361-
function parse_if(ps::ParseState, nested = false)
361+
function parse_if(ps::ParseState, nested=false)
362362
args = EXPR[]
363363
trivia = EXPR[EXPR(ps)]
364364

@@ -428,7 +428,7 @@ function parse_try(ps::ParseState)
428428
args[3] = EXPR(:block, 0, 0, "")
429429
end
430430
else_trivia = EXPR(next(ps))
431-
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY,Tokens.END)))
431+
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY, Tokens.END)))
432432
end
433433

434434
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
@@ -149,7 +149,7 @@ function parse_array_outer(ps::ParseState, trivia, isref)
149149
args = EXPR[]
150150
push!(args, a)
151151
push!(trivia, accept_comma(ps))
152-
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at = 1)
152+
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at=1)
153153
return EXPR(:vect, args, trivia)
154154
elseif kindof(ps.nt) === Tokens.ENDMARKER
155155
push!(args, a)
@@ -309,7 +309,7 @@ function parse_barray(ps::ParseState)
309309
accept_rbrace(ps, trivia)
310310
ret = EXPR(:braces, args, trivia)
311311
else
312-
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
312+
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
313313
if kindof(ps.nt) === Tokens.RBRACE
314314
push!(args, first_arg)
315315
if kindof(ps.ws) == SemiColonWS
@@ -320,15 +320,15 @@ function parse_barray(ps::ParseState)
320320
elseif iscomma(ps.nt)
321321
push!(args, first_arg)
322322
accept_comma(ps, trivia)
323-
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at = 1)
323+
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at=1)
324324
accept_rbrace(ps, trivia)
325325
return EXPR(:braces, args, trivia)
326326
elseif kindof(ps.ws) == NewLineWS
327327
ret = EXPR(:bracescat, args, trivia)
328328
push!(ret, first_arg)
329329
prevpos = position(ps)
330330
while kindof(ps.nt) != Tokens.RBRACE && kindof(ps.nt) !== Tokens.ENDMARKER
331-
a = @closebrace ps parse_expression(ps)
331+
a = @closebrace ps parse_expression(ps)
332332
push!(ret, a)
333333
prevpos = loop_check(ps, prevpos)
334334
end

0 commit comments

Comments
 (0)