From 10d1e4de471159cedc33479a26a979decd55c8b6 Mon Sep 17 00:00:00 2001 From: jiangkaiwen Date: Mon, 13 Feb 2023 16:24:53 +0800 Subject: [PATCH] Es2abc supports new features: Ideographic Space, NextLine, Shebang 1.Es2abc supports Ideographic Space 2.Es2abc supports Shebang 3.Es2abc supports NextLine Issue:I6DBQP Signed-off-by: jiangkaiwen Change-Id: I1383fdf8c4307b4e8c99b94575625406fa79cff3 --- es2panda/lexer/lexer.cpp | 14 ++++++++++++++ es2panda/lexer/token/letters.h | 2 ++ es2panda/test/test_tsc_ignore_list.txt | 6 ------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/es2panda/lexer/lexer.cpp b/es2panda/lexer/lexer.cpp index 5e80b9718e..657f2addc5 100644 --- a/es2panda/lexer/lexer.cpp +++ b/es2panda/lexer/lexer.cpp @@ -1233,6 +1233,18 @@ void Lexer::SkipWhiteSpaces() auto cp = Iterator().Peek(); switch (cp) { + case LEX_CHAR_HASH_MARK: { + Iterator().Forward(1); + cp = Iterator().Peek(); + if (cp == LEX_CHAR_EXCLAMATION) { + Iterator().Forward(1); + SkipSingleLineComment(); + continue; + } + + Iterator().Backward(1); + return; + } case LEX_CHAR_CR: { Iterator().Forward(1); @@ -1286,6 +1298,8 @@ void Lexer::SkipWhiteSpaces() [[fallthrough]]; } case LEX_CHAR_NBSP: + case LEX_CHAR_NLINE: + case LEX_CHAR_IGSP: case LEX_CHAR_ZWNBSP: { Iterator().Forward(cpSize); continue; diff --git a/es2panda/lexer/token/letters.h b/es2panda/lexer/token/letters.h index 5ca3771406..cb8c574b5c 100644 --- a/es2panda/lexer/token/letters.h +++ b/es2panda/lexer/token/letters.h @@ -89,11 +89,13 @@ namespace panda::es2panda::lexer { #define LEX_CHAR_SP 0x20 /* space */ #define LEX_CHAR_NBSP 0xA0 /* no-break space */ #define LEX_CHAR_ZWNBSP 0xFEFF /* zero width no-break space */ +#define LEX_CHAR_IGSP 0x3000 /* ideographic space */ #define LEX_CHAR_MVS 0x180e /* MONGOLIAN VOWEL SEPARATOR (U+180E) */ #define LEX_CHAR_DOUBLE_QUOTE 0x22 /* " */ #define LEX_CHAR_DOLLAR_SIGN 0x24 /* $ */ #define LEX_CHAR_SINGLE_QUOTE 0x27 /* ' */ #define LEX_CHAR_DOT 0x2E /* . */ +#define LEX_CHAR_NLINE 0x85 /* nextline */ #define LEX_CHAR_0 0x30 /* 0 */ #define LEX_CHAR_1 0x31 /* 1 */ diff --git a/es2panda/test/test_tsc_ignore_list.txt b/es2panda/test/test_tsc_ignore_list.txt index 761f6a12a6..91c8e1cc50 100644 --- a/es2panda/test/test_tsc_ignore_list.txt +++ b/es2panda/test/test_tsc_ignore_list.txt @@ -6,9 +6,6 @@ es2panda/test/TypeScript/tests/cases/compiler/collisionArgumentsInterfaceMembers es2panda/test/TypeScript/tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts es2panda/test/TypeScript/tests/cases/compiler/constructorOverloads5.ts es2panda/test/TypeScript/tests/cases/compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts -es2panda/test/TypeScript/tests/cases/compiler/emitBundleWithShebang1.ts -es2panda/test/TypeScript/tests/cases/compiler/fileWithNextLine2.ts -es2panda/test/TypeScript/tests/cases/compiler/genericRecursiveImplicitConstructorErrors2.ts es2panda/test/TypeScript/tests/cases/compiler/globalIsContextualKeyword.ts es2panda/test/TypeScript/tests/cases/compiler/inferenceErasedSignatures.ts es2panda/test/TypeScript/tests/cases/compiler/isLiteral1.ts @@ -19,9 +16,7 @@ es2panda/test/TypeScript/tests/cases/compiler/letInVarDeclOfForIn_ES6.ts es2panda/test/TypeScript/tests/cases/compiler/letInVarDeclOfForOf_ES5.ts es2panda/test/TypeScript/tests/cases/compiler/letInVarDeclOfForOf_ES6.ts es2panda/test/TypeScript/tests/cases/compiler/parameterInitializerBeforeDestructuringEmit.ts -es2panda/test/TypeScript/tests/cases/compiler/shebang.ts es2panda/test/TypeScript/tests/cases/compiler/sigantureIsSubTypeIfTheyAreIdentical.ts -es2panda/test/TypeScript/tests/cases/compiler/sourceMap-LineBreaks.ts es2panda/test/TypeScript/tests/cases/compiler/withStatementInternalComments.ts es2panda/test/TypeScript/tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments03_ES6.ts es2panda/test/TypeScript/tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments04_ES6.ts @@ -62,7 +57,6 @@ es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclaration es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface03.ts es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface04.ts es2panda/test/TypeScript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser579071.ts -es2panda/test/TypeScript/tests/cases/conformance/parser/ecmascript5/parserUnicodeWhitespaceCharacter1.ts es2panda/test/TypeScript/tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral2.ts es2panda/test/TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts es2panda/test/TypeScript/tests/cases/conformance/types/members/objectTypeWithStringNamedNumericProperty.ts -- Gitee