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

Upgraded supported TypeScript version to v2.7. #3978

Merged
merged 4 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion javascript/javascript/JavaScriptLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Try : 'try';
As : 'as';
From : 'from';
Of : 'of';
Yield : 'yield';
YieldStar : 'yield*';

/// Future Reserved Words

Expand All @@ -182,7 +184,6 @@ Import : 'import';

Async : 'async';
Await : 'await';
Yield : 'yield';

/// The following tokens are also considered to be FutureReservedWords
/// when parsing strict mode
Expand Down
9 changes: 6 additions & 3 deletions javascript/javascript/JavaScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ returnStatement
;

yieldStatement
: Yield ({this.notLineTerminator()}? expressionSequence)? eos
: (Yield | YieldStar) ({this.notLineTerminator()}? expressionSequence)? eos
;

withStatement
Expand Down Expand Up @@ -314,8 +314,9 @@ arrayLiteral
: ('[' elementList ']')
;

// JavaScript supports arrasys like [,,1,2,,].
elementList
: ','* arrayElement? (','+ arrayElement)* ','* // Yes, everything is optional
: ','* arrayElement? (','+ arrayElement) * ','* // Yes, everything is optional
;

arrayElement
Expand Down Expand Up @@ -420,7 +421,8 @@ objectLiteral
;

anonymousFunction
: Async? Function_ '*'? '(' formalParameterList? ')' functionBody # AnonymousFunctionDecl
: functionDeclaration # NamedFunction
| Async? Function_ '*'? '(' formalParameterList? ')' functionBody # AnonymousFunctionDecl
| Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction
;

Expand Down Expand Up @@ -556,6 +558,7 @@ keyword
| Protected
| Static
| Yield
| YieldStar
| Async
| Await
| From
Expand Down
6 changes: 6 additions & 0 deletions javascript/javascript/examples/ObjectInitializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
obj = { };
obj = { item1: "item1", item2: "item2" };
obj = { item1: "item1", item2: "item2", };
obj = { item1: "item1",
item2: "item2",
item3: function(arg1) { return arg1; },
item4: function myFunction(arg1) { return arg1; },
item5: (arg1) => { return arg1; }
};

1 change: 1 addition & 0 deletions javascript/jsx/JavaScriptLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ In : 'in';
Try : 'try';
As : 'as';
From : 'from';
YieldStar : 'yield*';

/// Future Reserved Words

Expand Down
2 changes: 1 addition & 1 deletion javascript/jsx/JavaScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ returnStatement
;

yieldStatement
: Yield ({this.notLineTerminator()}? expressionSequence)? eos
: (Yield | YieldStar) ({this.notLineTerminator()}? expressionSequence)? eos
;

withStatement
Expand Down
53 changes: 46 additions & 7 deletions javascript/typescript/TypeScriptLexer.g4
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 by Bart Kiers (original author) and Alexandre Vitorelli (contributor -> ported to CSharp)
* Copyright (c) 2017 by Ivan Kochurkin (Positive Technologies):
added ECMAScript 6 support, cleared and transformed to the universal grammar.
* Copyright (c) 2018 by Juan Alvarez (contributor -> ported to Go)
* Copyright (c) 2019 by Andrii Artiushok (contributor -> added TypeScript support)
* Copyright (c) 2024 by Andrew Leppard (www.wegrok.review)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine
// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true
Expand Down Expand Up @@ -139,6 +171,8 @@ From : 'from';
ReadOnly : 'readonly';
Async : 'async';
Await : 'await';
Yield : 'yield';
YieldStar : 'yield*';

/// Future Reserved Words

Expand All @@ -161,15 +195,20 @@ Interface : 'interface';
Package : 'package';
Protected : 'protected';
Static : 'static';
Yield : 'yield';

//keywords:

Any : 'any';
Number : 'number';
Boolean : 'boolean';
String : 'string';
Symbol : 'symbol';
Any : 'any';
Number : 'number';
Never : 'never';
Boolean : 'boolean';
String : 'string';
Unique : 'unique';
Symbol : 'symbol';
Undefined : 'undefined';
Object : 'object';

Of : 'of';
KeyOf : 'keyof';

TypeAlias: 'type';

Expand Down
Loading
Loading