Skip to content

Commit

Permalink
Format files using DocumentFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff authored Jun 15, 2023
1 parent 993a923 commit 4174188
Show file tree
Hide file tree
Showing 43 changed files with 2,803 additions and 2,599 deletions.
6 changes: 3 additions & 3 deletions packages/CSTParser/docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ makedocs(;
repo="https://github.com/julia-vscode/CSTParser.jl/blob/{commit}{path}#L{line}",
sitename="CSTParser.jl",
format=Documenter.HTML(;
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true"
# canonical="https://www.julia-vscode.org/CSTParser.jl",
# assets=String[],
),
pages=[
"Home" => "index.md",
"Syntax Reference" => "syntax.md",
],
]
)

deploydocs(;
repo="github.com/julia-vscode/CSTParser.jl",
repo="github.com/julia-vscode/CSTParser.jl"
)
2 changes: 1 addition & 1 deletion packages/CSTParser/src/CSTParser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module CSTParser
using Tokenize
import Tokenize.Tokens
import Tokenize.Tokens: RawToken, AbstractToken, iskeyword, isliteral, isoperator, untokenize
import Tokenize.Lexers: Lexer, peekchar, iswhitespace, readchar, emit, emit_error, accept_batch, eof
import Tokenize.Lexers: Lexer, peekchar, iswhitespace, readchar, emit, emit_error, accept_batch, eof

include("packagedef.jl")

Expand Down
16 changes: 8 additions & 8 deletions packages/CSTParser/src/components/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Parses an iterator, allowing for the preceding keyword `outer`. Returns an
error expression if an invalid expression is parsed (anything other than
`=`, `in`, `∈`).
"""
function parse_iterator(ps::ParseState, outer = parse_outer(ps))
function parse_iterator(ps::ParseState, outer=parse_outer(ps))
arg = @closer ps :range @closer ps :ws @nocloser ps :wsop parse_expression(ps)
if !is_range(arg)
arg = mErrorToken(ps, arg, InvalidIterator)
Expand Down Expand Up @@ -135,7 +135,7 @@ function parse_call(ps::ParseState, ret::EXPR, ismacro=false)
end
# args = ismacro ? EXPR[ret, EXPR(:NOTHING, 0, 0)] : EXPR[ret]
trivia = EXPR[EXPR(next(ps))]
@closeparen ps @default ps parse_comma_sep(ps, args, trivia, !ismacro, insert_params_at = ismacro ? 3 : 2)
@closeparen ps @default ps parse_comma_sep(ps, args, trivia, !ismacro, insert_params_at=ismacro ? 3 : 2)
accept_rparen(ps, trivia)
ret = EXPR(ismacro ? :macrocall : syntaxcall ? ret : :call, args, trivia)
end
Expand All @@ -146,7 +146,7 @@ end
Parses a comma separated list, optionally allowing for conversion of
assignment (`=`) expressions to `Kw`.
"""
function parse_comma_sep(ps::ParseState, args::Vector{EXPR}, trivia::Vector{EXPR}, kw = true, block = false, istuple = false; insert_params_at = 2)
function parse_comma_sep(ps::ParseState, args::Vector{EXPR}, trivia::Vector{EXPR}, kw=true, block=false, istuple=false; insert_params_at=2)
prevpos = position(ps)
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !closer(ps)
a = parse_expression(ps)
Expand Down Expand Up @@ -205,11 +205,11 @@ end
Parses parameter arguments for a function call (e.g. following a semicolon).
"""
function parse_parameters(ps::ParseState, args::Vector{EXPR}, args1::Vector{EXPR} = EXPR[], insert_params_at = 2; usekw = true)
function parse_parameters(ps::ParseState, args::Vector{EXPR}, args1::Vector{EXPR}=EXPR[], insert_params_at=2; usekw=true)
trivia = EXPR[]
isfirst = isempty(args1)
prevpos = position(ps)
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !isfirst || (@nocloser ps :semicolon !closer(ps))
@nocloser ps :inwhere @nocloser ps :newline @closer ps :comma while !isfirst || (@nocloser ps :semicolon !closer(ps))
a = isfirst ? parse_expression(ps) : first(args1)
if usekw && _do_kw_convert(ps, a)
a = _kw_convert(a)
Expand Down Expand Up @@ -347,7 +347,7 @@ end
function get_appropriate_child_to_expand(x)
if headof(x) === :generator && !(headof(x.args[1]) in (:generator, :flatten))
return x, x.args[1]
elseif headof(x) === :flatten && headof(x.args[1]) === :generator && headof(x.args[1].args[1]) === :generator
elseif headof(x) === :flatten && headof(x.args[1]) === :generator && headof(x.args[1].args[1]) === :generator
x.args[1], x.args[1].args[1]
else
get_appropriate_child_to_expand(x.args[1])
Expand All @@ -365,7 +365,7 @@ function parse_nonstd_identifier(ps)
end
end

function parse_importexport_item(ps, is_colon = false)
function parse_importexport_item(ps, is_colon=false)
if kindof(ps.nt) === Tokens.AT_SIGN
parse_macroname(next(ps))
elseif kindof(ps.nt) === Tokens.LPAREN
Expand All @@ -377,7 +377,7 @@ function parse_importexport_item(ps, is_colon = false)
parse_unary(ps, INSTANCE(next(ps)))
elseif !is_colon && isoperator(ps.nt)
next(ps)
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
elseif is_nonstd_identifier(ps)
parse_nonstd_identifier(ps)
else
Expand Down
8 changes: 4 additions & 4 deletions packages/CSTParser/src/components/keywords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ function parse_const(ps::ParseState)
nt = ps.nt
arg = parse_expression(ps)
allow_no_assignment = has_flag(ps, ParserFlags.AllowConstWithoutAssignment) ||
has_flag(ps, ParserFlags.InQuote) && (kindof(nt) === Tokens.GLOBAL || kindof(lt) === Tokens.GLOBAL)
has_flag(ps, ParserFlags.InQuote) && (kindof(nt) === Tokens.GLOBAL || kindof(lt) === Tokens.GLOBAL)
if !allow_no_assignment && !(isassignment(unwrapbracket(arg)) || (headof(arg) === :global && length(arg.args) > 0 && isassignment(unwrapbracket(arg.args[1]))))
arg = mErrorToken(ps, arg, ExpectedAssignment)
end
ret = EXPR(:const, EXPR[arg], EXPR[kw])
return ret
end

function parse_local_global(ps::ParseState, islocal = true)
function parse_local_global(ps::ParseState, islocal=true)
kw = EXPR(ps)
if ps.nt.kind === Tokens.CONST
arg1 = parse_const(next(ps))
Expand Down Expand Up @@ -358,7 +358,7 @@ end
Parse an `if` block.
"""
function parse_if(ps::ParseState, nested = false)
function parse_if(ps::ParseState, nested=false)
args = EXPR[]
trivia = EXPR[EXPR(ps)]

Expand Down Expand Up @@ -428,7 +428,7 @@ function parse_try(ps::ParseState)
args[3] = EXPR(:block, 0, 0, "")
end
else_trivia = EXPR(next(ps))
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY,Tokens.END)))
else_arg = EXPR(:block, parse_block(ps, EXPR[], (Tokens.FINALLY, Tokens.END)))
end

has_finally = false
Expand Down
14 changes: 7 additions & 7 deletions packages/CSTParser/src/components/lists.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function parse_tuple(ps::ParseState, ret::EXPR)
end

# XXX: Avert thine eyes.
function count_semicolons(ps, check_newline = true)
function count_semicolons(ps, check_newline=true)
dims = 0
has_newline = false
old_pos = position(ps.l.io)
Expand Down Expand Up @@ -75,7 +75,7 @@ Having hit '[' return either:
+ A comprehension
+ An array (vcat of hcats)
"""
function parse_array(ps::ParseState, isref = false)
function parse_array(ps::ParseState, isref=false)
args = EXPR[]
trivia = EXPR[EXPR(ps)]
# [] or [;;;]
Expand All @@ -100,7 +100,7 @@ function parse_array(ps::ParseState, isref = false)
end
end

binding_power(ps, nl = true) =
binding_power(ps, nl=true) =
if kindof(ps.ws) == SemiColonWS
-count_semicolons(ps, nl)
elseif kindof(ps.ws) == NewLineWS
Expand Down Expand Up @@ -149,7 +149,7 @@ function parse_array_outer(ps::ParseState, trivia, isref)
args = EXPR[]
push!(args, a)
push!(trivia, accept_comma(ps))
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at = 1)
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at=1)
return EXPR(:vect, args, trivia)
elseif kindof(ps.nt) === Tokens.ENDMARKER
push!(args, a)
Expand Down Expand Up @@ -309,7 +309,7 @@ function parse_barray(ps::ParseState)
accept_rbrace(ps, trivia)
ret = EXPR(:braces, args, trivia)
else
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
first_arg = @nocloser ps :newline @closebrace ps @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
if kindof(ps.nt) === Tokens.RBRACE
push!(args, first_arg)
if kindof(ps.ws) == SemiColonWS
Expand All @@ -320,15 +320,15 @@ function parse_barray(ps::ParseState)
elseif iscomma(ps.nt)
push!(args, first_arg)
accept_comma(ps, trivia)
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at = 1)
@closebrace ps parse_comma_sep(ps, args, trivia, true, insert_params_at=1)
accept_rbrace(ps, trivia)
return EXPR(:braces, args, trivia)
elseif kindof(ps.ws) == NewLineWS
ret = EXPR(:bracescat, args, trivia)
push!(ret, first_arg)
prevpos = position(ps)
while kindof(ps.nt) != Tokens.RBRACE && kindof(ps.nt) !== Tokens.ENDMARKER
a = @closebrace ps parse_expression(ps)
a = @closebrace ps parse_expression(ps)
push!(ret, a)
prevpos = loop_check(ps, prevpos)
end
Expand Down
Loading

0 comments on commit 4174188

Please sign in to comment.