Skip to content

Commit

Permalink
Replace delimited identifier syntax
Browse files Browse the repository at this point in the history
Fixes #243.
Fixes #193.
  • Loading branch information
jclark committed Jun 28, 2019
1 parent 651cbba commit aa9f05f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lang/lib/array.bal
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function enumerate(Type[] arr) returns [int, Type][] = external;

// Functional iteration

// use delimited identifer for function name to avoid conflict with reserved name
public function ^"map"(Type[] arr, function(Type val) returns Type1 func) returns Type1[] = external;
// use quoted identifer for function name to avoid conflict with reserved name
public function 'map(Type[] arr, function(Type val) returns Type1 func) returns Type1[] = external;
# Applies `func` to each member of `arr`.
public function forEach(Type[] arr, function(Type val) returns () func) returns () = external;
public function filter(Type[] arr, function(Type val) returns boolean func) returns Type[] = external;
Expand Down
4 changes: 2 additions & 2 deletions lang/lib/map.bal
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function entries(map<Type> m) returns map<[string, Type]> = external;

// Functional iteration

// use delimited identifer for function name to avoid conflict with reserved name
public function ^"map"(map<Type> m, function(Type val) returns Type1 func) returns map<Type1> = external;
// use quoted identifer for function name to avoid conflict with reserved name
public function 'map(map<Type> m, function(Type val) returns Type1 func) returns map<Type1> = external;
# Applies `func` to each member of `m`.
public function forEach(map<Type> m, function(Type val) returns () func) returns () = external;
public function filter(map<Type> m, function(Type val) returns boolean func) returns map<Type> = external;
Expand Down
22 changes: 18 additions & 4 deletions lang/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,18 @@ <h2 id="lexical_structure">4. Lexical structure</h2>
</p>

<pre
class="grammar">identifier := UndelimitedIdentifier | DelimitedIdentifier
UndelimitedIdentifier :=
class="grammar">identifier := UnquotedIdentifier | QuotedIdentifier
UnquotedIdentifier :=
IdentifierInitialChar IdentifierFollowingChar*
DelimitedIdentifier := <code>^"</code> StringChar+ <code>"</code>
IdentifierInitialChar := <code>A</code> .. <code>Z</code> | <code>a</code> .. <code>z</code> | <code>_</code> | UnicodeIdentifierChar
QuotedIdentifier := <code>'</code> QuotedIdentifierChar+
QuotedIdentifierChar :=
IdentifierFollowingChar
| QuotedIdentifierEscape
| StringNumericEscape
IdentifierInitialChar := AsciiLetter | <code>_</code> | UnicodeIdentifierChar
IdentifierFollowingChar := IdentifierInitialChar | Digit
QuotedIdentifierEscape := <code>\</code> ^ ( AsciiLetter | 0x9 | 0xA | 0xD | UnicodePatternWhiteSpaceChar )
AsciiLetter := <code>A</code> .. <code>Z</code> | <code>a</code> .. <code>z</code>
UnicodeIdentifierChar := ^ ( AsciiChar | UnicodeNonIdentifierChar )
AsciiChar := 0x0 .. 0x7F
UnicodeNonIdentifierChar :=
Expand All @@ -309,6 +315,12 @@ <h2 id="lexical_structure">4. Lexical structure</h2>
of Unicode TR31 for immutable identifiers; the set of characters is immutable in
the sense that it does not change between Unicode versions.
</p>
<p>
The QuotedIdentifier syntax allows an arbitrary non-empty string to be treated
as an identifier. In particular, a reserved keyword <code><var>K</var></code>
can be used as an identifier by preceding it with a single quote i.e.
<code>'<var>K</var></code>.
</p>

<pre
class="grammar">TokenWhiteSpace := (Comment | WhiteSpaceChar)*
Expand Down Expand Up @@ -6024,6 +6036,8 @@ <h3>Summary of changes from 2019R1 to 2019R2</h3>
rather than <code>anydata|error</code>.</li>
<li>Calls using <code>start</code> are treated as actions, and so are not
allowed within expressions.</li>
<li>There is a new syntax for allowing arbitrary strings as identifiers to
replace the old delimited identifier syntax <code>^"<var>s</code>"</code>.</li>
</ol>

<h3>Summary of changes from 0.990 to 2019R1</h3>
Expand Down

0 comments on commit aa9f05f

Please sign in to comment.