Skip to content

Commit

Permalink
Merge pull request #28 from Solo-steven/steven/poc/ts-parser
Browse files Browse the repository at this point in the history
[Feat]: POC of TS parser
  • Loading branch information
Solo-steven authored Oct 27, 2024
2 parents c6d9a79 + 3e2cbbf commit 7988d4b
Show file tree
Hide file tree
Showing 463 changed files with 28,613 additions and 6,280 deletions.
308 changes: 303 additions & 5 deletions web-infras/common/src/ast.ts

Large diffs are not rendered by default.

689 changes: 688 additions & 1 deletion web-infras/common/src/factory.ts

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions web-infras/common/src/kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,67 @@ export enum SyntaxKinds {
JSXExpressionContainer,
JSXSelfClosedToken, // token for `/>`
JSXCloseTagStart, // token for `</`
/** ======================================
* TypeScript AST Node
* ======================================
*/
// ========= Type computation
TSConditionalType,
TSUnionType,
TSIntersectionType,
TSTypeOperator,
TSArrayType,
TSIndexedAccessType,
// ========= High Level Type
TSConstructorType,
TSFunctionType,
// ========= Type Interface and Type Alias =====
TSTypeAliasDeclaration,
TSInterfaceDeclaration,
TSInterfaceHeritage,
TSInterfaceBody,
TSTypeLiteral,
TSCallSignatureDeclaration,
TSConstructSignatureDeclaration,
TSIndexSignature,
TSPropertySignature,
TSMethodSignature,
// ======== Type Enum
TSEnumDeclaration,
TSEnumBody,
TSEnumMember,
// ========= Type Expression
TSInstantiationExpression,
TSTypeAssertionExpression,
TSAsExpression,
TSSatisfiesExpression,
TSNonNullExpression,
// ========= Type Parameter
TSTypeParameterInstantiation,
TSTypeParameterDeclaration,
TSTypeParameter,
// ======= Other Type
TSQualifiedName,
TSTypePredicate,
TSTypeAnnotation,
// ======= Other Basic Type
TSTypeReference,
TSTypeQuery,
TSTupleType,
TSLiteralType,
TSDeclareFunction,
// ======= Atom Basic Type ======
TSStringKeyword,
TSNumberKeyword,
TSBigIntKeyword,
TSBooleanKeyword,
TSNullKeyword,
TSUndefinedKeyword,
TSSymbolKeyword,
TSAnyKeyword,
TSNeverKeyword,
TSUnknowKeyword,
TSVoidKeyword,
}
export const LexicalLiteral = {
whiteSpaceChars: [" ", "\t"],
Expand Down Expand Up @@ -539,6 +600,7 @@ export const SytaxKindsMapLexicalLiteral: Record<SyntaxKinds, string> = {
[SyntaxKinds.ColonPunctuator]: ":", // :
[SyntaxKinds.HashTagPunctuator]: "#", // #
[SyntaxKinds.AtPunctuator]: "@", // @

// ========== Template ===========
[SyntaxKinds.TemplateHead]: "TemplateHead",
[SyntaxKinds.TemplateTail]: "TemplateTail",
Expand Down Expand Up @@ -679,6 +741,58 @@ export const SytaxKindsMapLexicalLiteral: Record<SyntaxKinds, string> = {
[SyntaxKinds.JSXExpressionContainer]: "JSXExpressionContainer",
[SyntaxKinds.JSXCloseTagStart]: "JSXClosedTagStart",
[SyntaxKinds.JSXSelfClosedToken]: "JSXSelfClosedToken",
// ====== TypeScript Computed Type
[SyntaxKinds.TSConditionalType]: "TSConditionalType",
[SyntaxKinds.TSUnionType]: "TSUnionType",
[SyntaxKinds.TSIntersectionType]: "TSIntersectionType",
[SyntaxKinds.TSTypeOperator]: "TSTypeOperator",
[SyntaxKinds.TSArrayType]: "TSArrayType",
[SyntaxKinds.TSIndexedAccessType]: "TSIndexedAccessType",
[SyntaxKinds.TSTypeAliasDeclaration]: "TSTypeAliasDeclaration",
[SyntaxKinds.TSInterfaceDeclaration]: "TSInterfaceDeclaration",
// ====== TypeScript High Basic Type
[SyntaxKinds.TSFunctionType]: "TSFunctionType",
[SyntaxKinds.TSConstructorType]: "TSConstructorType",
// ====== TypeScript Type Param
[SyntaxKinds.TSTypeParameterInstantiation]: "TSTypeParameterInstantiation",
[SyntaxKinds.TSTypeParameterDeclaration]: "TSTypeParameterDeclaration",
[SyntaxKinds.TSTypeParameter]: "TSTypeParameter",
// ====== TypeScript Basic Type
[SyntaxKinds.TSTypeLiteral]: "TSTypeLiteral",
[SyntaxKinds.TSCallSignatureDeclaration]: "TSCallSignatureDeclaration",
[SyntaxKinds.TSConstructSignatureDeclaration]: "TSConstructSignatureDeclaration",
[SyntaxKinds.TSIndexSignature]: "TSIndexSignature",
[SyntaxKinds.TSPropertySignature]: "TSPropertySignature",
[SyntaxKinds.TSMethodSignature]: "TSMethodSignature",
[SyntaxKinds.TSQualifiedName]: "TSQualifiedName",
[SyntaxKinds.TSTypePredicate]: "TSTypePredicate",
[SyntaxKinds.TSTypeAnnotation]: "TSTypeAnnotation",
[SyntaxKinds.TSTypeReference]: "TSTypeReference",
[SyntaxKinds.TSStringKeyword]: "TSStringKeyword",
[SyntaxKinds.TSNumberKeyword]: "TSNumberKeyword",
[SyntaxKinds.TSBigIntKeyword]: "TSBigIntKeyword",
[SyntaxKinds.TSBooleanKeyword]: "TSBooleanKeyword",
[SyntaxKinds.TSNullKeyword]: "TSNullKeyword",
[SyntaxKinds.TSUndefinedKeyword]: "TSUndefinedKeyword",
[SyntaxKinds.TSSymbolKeyword]: "TSSymbolKeyword",
[SyntaxKinds.TSAnyKeyword]: "TSAnyKeyword",
[SyntaxKinds.TSNeverKeyword]: "TSNeverKeyword",
[SyntaxKinds.TSUnknowKeyword]: "TSUnknowKeyword",
[SyntaxKinds.TSTypeQuery]: "TSTypeQuery",
[SyntaxKinds.TSInterfaceBody]: "TSInterfaceBody",
[SyntaxKinds.TSTupleType]: "TSTupleType",
[SyntaxKinds.TSLiteralType]: "TSLiteralType",
[SyntaxKinds.TSVoidKeyword]: "TSVoidKeyword",
[SyntaxKinds.TSInstantiationExpression]: "TSInstantiationExpression",
[SyntaxKinds.TSInterfaceHeritage]: "TSInterfaceHeritage",
[SyntaxKinds.TSTypeAssertionExpression]: "TSTypeAssertionExpression",
[SyntaxKinds.TSAsExpression]: "TSAsExpression",
[SyntaxKinds.TSSatisfiesExpression]: "TSSatisfiesExpression",
[SyntaxKinds.TSNonNullExpression]: "TSNonNullExpression",
[SyntaxKinds.TSEnumDeclaration]: "TSEnumDeclaration",
[SyntaxKinds.TSEnumBody]: "TSEnumBody",
[SyntaxKinds.TSEnumMember]: "TSEnumMember",
[SyntaxKinds.TSDeclareFunction]: "TSDeclareFunction",
};
/** ===================================
* Union SytaxKinds
Expand Down
Loading

0 comments on commit 7988d4b

Please sign in to comment.