Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named Arguments #625

Merged
merged 32 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8ac5b1d
Initial commit for semantic tokenizer.
gdotdesign Jun 12, 2023
60f1bb5
Simplify semantic tokenizer a bit.
gdotdesign Jun 13, 2023
0e865c6
Working language server implementation.
gdotdesign Jun 13, 2023
1c14a5a
Cleanup semantic tokenizer class.
gdotdesign Jun 13, 2023
ca01ad6
Save keywords automatically instead of manually.
gdotdesign Jun 13, 2023
6926d57
Use an array derived from the actual token types.
gdotdesign Jun 13, 2023
29fb79b
Implement suggestions from code review.
gdotdesign Jun 14, 2023
6b25fc8
Update src/ls/semantic_tokens.cr
gdotdesign Jun 14, 2023
0eea575
Implement HTML highlighting.
gdotdesign Jun 14, 2023
1cd96da
Implement highlight directive.
gdotdesign Jun 14, 2023
529117d
Avoid unnecessary interations.
gdotdesign Jun 14, 2023
79c3f11
Implement suggestions from code review.
gdotdesign Jun 14, 2023
6faec26
Use the ast from the workspace semantic tokens.
gdotdesign Jun 25, 2023
37db9b6
Implementation of localization language structures.
gdotdesign Jun 26, 2023
6e51ae0
Update operation.cr
gdotdesign Jul 18, 2023
673b361
Merge branch 'master' into locales
gdotdesign Jul 18, 2023
92833ca
Update test.
gdotdesign Jul 21, 2023
5e9eef7
Merge branch 'master' into locales
gdotdesign Aug 8, 2023
44ab595
Revert change to the operation formatting.
gdotdesign Aug 8, 2023
a8ecd78
Update Locale.md
gdotdesign Aug 8, 2023
cb99c78
Implement labelled calls.
gdotdesign Jul 21, 2023
dd254f8
Don't reorder arguments in the formatter.
gdotdesign Jul 22, 2023
630c080
Minor fixes.
gdotdesign Jul 26, 2023
d28c7a3
Merge branch 'master' into locales
gdotdesign Sep 6, 2023
095ab66
Merge branch 'locales' into labelled-calls
gdotdesign Sep 6, 2023
d171155
Merge branch 'master' into locales
gdotdesign Sep 7, 2023
88bd4cc
Merge branch 'locales' into labelled-calls
gdotdesign Sep 7, 2023
36c9d98
Apply suggestions from code review
gdotdesign Sep 7, 2023
a2a0c04
Update src/compilers/call.cr
gdotdesign Sep 7, 2023
687550d
Finish renaming an error from code review.
gdotdesign Sep 7, 2023
99a1bac
Merge branch 'master' into labelled-calls
gdotdesign Sep 17, 2023
99acd9f
Merge branch 'master' into labelled-calls
gdotdesign Sep 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Save keywords automatically instead of manually.
  • Loading branch information
gdotdesign committed Jun 13, 2023
commit ca01ad6659eab0f563d35db97c9d7be93bec3f01
8 changes: 4 additions & 4 deletions src/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ module Mint
# Consuming keywords
# ----------------------------------------------------------------------------

def keyword!(word, error, save : Bool = false) : Bool
keyword(word, save) || raise error
def keyword!(word, error) : Bool
keyword(word) || raise error
end

def keyword_ahead?(word) : Bool
Expand All @@ -184,9 +184,9 @@ module Mint
true
end

def keyword(word, save : Bool = false) : Bool
def keyword(word) : Bool
if keyword_ahead?(word)
if save
if word =~ /^[a-z]+$/
@ast.keywords << {position, position + word.size}
end

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/array_literal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Mint

type = start do
whitespace
next unless keyword("of", true)
next unless keyword "of"
whitespace
type_or_type_variable! ArrayLiteralExpectedTypeOrVariable
end
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/case.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module Mint

def case_expression(for_css : Bool = false) : Ast::Case?
start do |start_position|
next unless keyword("case", true)
next unless keyword "case"

whitespace

parens = char! '('

whitespace
await = keyword("await", true)
await = keyword "await"

whitespace
condition = expression! CaseExpectedCondition
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/component.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module Mint
start do |start_position|
comment = self.comment

global = keyword("global", true)
global = keyword "global"
whitespace

next unless keyword("component", true)
next unless keyword "component"
whitespace

name = type_id! ComponentExpectedName
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/connect.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module Mint

def connect : Ast::Connect?
start do |start_position|
next unless keyword("connect", true)
next unless keyword "connect"
whitespace

store = type_id! ConnectExpectedType
whitespace

keyword!("exposing", ConnectExpectedExposing, true)
keyword! "exposing", ConnectExpectedExposing

keys = block(
opening_bracket: ConnectExpectedOpeningBracket,
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/connect_variable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Mint

whitespace

if keyword("as", true)
if keyword "as"
whitespace
name = variable! ConnectVariableExpectedAs
end
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/constant.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Mint
comment = self.comment
whitespace

next unless keyword("const", true)
next unless keyword "const"
whitespace

name = variable_constant!
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/css_font_face.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Mint

def css_font_face : Ast::CssFontFace?
start do |start_position|
next unless keyword("@font-face", true)
next unless keyword "@font-face"

definitions = block(
opening_bracket: CssFontFaceExpectedOpeningBracket,
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/css_keyframes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def css_keyframes : Ast::CssKeyframes?
start do |start_position|
next unless keyword("@keyframes", true)
next unless keyword "@keyframes"

whitespace

Expand Down
6 changes: 3 additions & 3 deletions src/parsers/decode.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ module Mint

def decode : Ast::Decode?
start do |start_position|
next unless keyword("decode", true)
next unless keyword "decode"
next unless whitespace?
whitespace

unless keyword("as", true)
unless keyword "as"
expression = expression! DecodeExpectedExpression

whitespace
keyword!("as", DecodeExpectedAs, true)
keyword! "as", DecodeExpectedAs
end

whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/directives/asset.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def asset_directive : Ast::Directives::Asset?
start do |start_position|
next unless keyword("@asset", true)
next unless keyword "@asset"

char '(', AssetDirectiveExpectedOpeningParentheses
whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/directives/documentation.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def documentation_directive : Ast::Directives::Documentation?
start do |start_position|
next unless keyword("@documentation", true)
next unless keyword "@documentation"

char '(', DocumentationDirectiveExpectedOpeningParentheses
whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/directives/format.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def format_directive : Ast::Directives::Format?
start do |start_position|
next unless keyword("@format", true)
next unless keyword "@format"

content =
code_block(
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/directives/inline.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def inline_directive : Ast::Directives::Inline?
start do |start_position|
next unless keyword("@inline", true)
next unless keyword "@inline"

char '(', InlineDirectiveExpectedOpeningParentheses
whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/directives/svg.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def svg_directive : Ast::Directives::Svg?
start do |start_position|
next unless keyword("@svg", true)
next unless keyword "@svg"

char '(', SvgDirectiveExpectedOpeningParentheses
whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/encode.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mint

def encode : Ast::Encode?
start do |start_position|
next unless keyword("encode", true)
next unless keyword "encode"
next unless whitespace?
whitespace

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/enum.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Mint
start do |start_position|
comment = self.comment

next unless keyword("enum", true)
next unless keyword "enum"
whitespace

name = type_id! EnumExpectedName
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/for.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Mint

def for_expression : Ast::For?
start do |start_position|
next unless keyword("for", true)
next unless keyword "for"
next unless whitespace?
whitespace

Expand All @@ -22,7 +22,7 @@ module Mint
) { variable }

whitespace
keyword!("of", ForExpectedOf, true)
keyword! "of", ForExpectedOf
whitespace

subject = expression! ForExpectedSubject
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/for_condition.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def for_condition : Ast::ForCondition?
start do |start_position|
next unless keyword("when", true)
next unless keyword "when"
whitespace

condition =
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/function.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mint
start do |start_position|
comment = self.comment

next unless keyword("fun", true)
next unless keyword "fun"
whitespace

name = variable! FunctionExpectedName, track: false
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/get.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mint
start do |start_position|
comment = self.comment

next unless keyword("get", true)
next unless keyword "get"
whitespace

name = variable! GetExpectedName, track: false
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/html_component.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Mint

ref = start do
whitespace
next unless keyword("as", true)
next unless keyword "as"
whitespace
variable! HtmlComponentExpectedReference
end
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/html_element.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Mint

ref = start do
whitespace
next unless keyword("as", true)
next unless keyword "as"
whitespace
variable! HtmlElementExpectedReference
end
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/if.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mint

def if_expression(for_css = false) : Ast::If?
start do |start_position|
next unless keyword("if", true)
next unless keyword "if"

whitespace
parens = char! '('
Expand Down Expand Up @@ -40,7 +40,7 @@ module Mint
falsy = nil
whitespace

if keyword("else", true)
if keyword "else"
whitespace

unless falsy = if_expression(for_css: for_css)
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/js.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Mint

type = start do
whitespace
next unless keyword("as", true)
next unless keyword "as"
whitespace
type_or_type_variable! JsExpectedTypeOrVariable
end
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/module.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Mint
comment = self.comment
whitespace

next unless keyword("module", true)
next unless keyword "module"
whitespace

name = type_id! ModuleExpectedName
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/next_call.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mint

def next_call : Ast::NextCall?
start do |start_position|
next unless keyword("next", true)
next unless keyword "next"
next unless whitespace?
whitespace

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/property.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mint

start_position = position

next unless keyword("property", true)
next unless keyword "property"
whitespace

name = variable! PropertyExpectedName, track: false
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/provider.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mint
start do |start_position|
comment = self.comment

next unless keyword("provider", true)
next unless keyword "provider"
whitespace

name = type_id! ProviderExpectedName
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/record_definition.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Mint
start do |start_position|
comment = self.comment

next unless keyword("record", true)
next unless keyword "record"
whitespace

name = type_id! RecordDefinitionExpectedName
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/record_definition_field.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Mint
mapping =
start do
whitespace
next unless keyword("using", true)
next unless keyword "using"
whitespace
string_literal! RecordDefinitionFieldExpectedMapping,
with_interpolation: false
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/return.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mint

def return_call : Ast::ReturnCall?
start do |start_position|
next unless keyword("return", true)
next unless keyword "return"
next unless whitespace?
whitespace

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/routes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Mint

def routes : Ast::Routes?
start do |start_position|
next unless keyword("routes", true)
next unless keyword "routes"

body = block(
opening_bracket: RoutesExpectedOpeningBracket,
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/state.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Mint
comment = self.comment
whitespace

next unless keyword("state", true)
next unless keyword "state"
whitespace

name = variable! StateExpectedName
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/statement.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Mint
def statement : Ast::Statement?
start do |start_position|
target = start do
next unless keyword("let", true)
next unless keyword "let"
whitespace

value = variable(track: false) ||
Expand All @@ -19,7 +19,7 @@ module Mint
end

whitespace
await = keyword("await", true)
await = keyword "await"

whitespace
body = expression
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Mint
comment = self.comment
whitespace

next unless keyword("store", true)
next unless keyword "store"
whitespace

name = type_id! StoreExpectedName
Expand Down
Loading