Skip to content

Commit

Permalink
Add a few more special literals
Browse files Browse the repository at this point in the history
The grammar hardcodes a few directive-looking things that we don't
handle today, namely playground literals and key path strings. Adding
those in explicitly for now, but this is worth reevaluating in the
future; it may be better to go generic and let the real language be more
restrictive.

Fixes #43
  • Loading branch information
alex-pinkus committed Nov 16, 2021
1 parent 472f19e commit af1e010
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ compoundValue[keyPath: \.self] = (a: 10, b: 20)

let nestedKeyPath = \OuterStructure.outer.someValue

let keyPathStringExpression = #keyPath(someProperty)

---

(source_file
Expand Down Expand Up @@ -567,7 +569,13 @@ let nestedKeyPath = \OuterStructure.outer.someValue
(navigation_suffix
(simple_identifier)))
(navigation_suffix
(simple_identifier)))))
(simple_identifier))))
(property_declaration
(value_binding_pattern
(non_binding_pattern
(simple_identifier)))
(key_path_string_expression
(simple_identifier))))

===
Tuple expression in function
Expand Down
21 changes: 21 additions & 0 deletions corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,24 @@ let infinity = "\u{221E}"
(non_binding_pattern
(simple_identifier)))
(line_string_literal)))

===
Playground literals
===

===
/tmp/top-repos/firefox/Client/Frontend/Update/UpdateViewModel.swift
===

let playgroundLiteral = #imageLiteral(resourceName: "heart")

---

(source_file
(property_declaration
(value_binding_pattern
(non_binding_pattern
(simple_identifier)))
(simple_identifier)
(line_string_literal)))

0 comments on commit af1e010

Please sign in to comment.