Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Supports grammar for minits #2

Open
31 of 48 tasks
mohanson opened this issue Aug 14, 2019 · 6 comments
Open
31 of 48 tasks

Supports grammar for minits #2

mohanson opened this issue Aug 14, 2019 · 6 comments

Comments

@mohanson
Copy link
Contributor

mohanson commented Aug 14, 2019

https://github.com/microsoft/TypeScript/blob/master/doc/spec.md

Types

  • Primitive Types
    • number(support signed 64): 0x10, 12
    • boolean: true, false
    • string: "Hello"
    • void
    • null
    • * undefined
    • enum: enum { a = 1, b, c }
  • Object
    • Array
    • Tuple

Expression

  • Assignment: let a: number = 1;, let a: number[] = [1, 2, 3]
  • Parentheses
  • Function Expressions
  • Arrow Functions
  • * Class Expressions
  • Function Calls
  • ++ / --
  • + / - / ~
  • !
  • * typeof
  • +: number + number, string + string, eg.
  • *, /, %, , <<, >>, >>>, &, ^, and | operators
  • <, >, <=, >=, ==, !=, ===, and !== operators
  • * in
  • && and ||
  • The Conditional Operator: test ? expr1 : expr2
  • *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^=, |=
  • Destructuring Assignment: [x, y] = [y, x];

Statements

  • Block
  • Variable Statements
  • Let and Const Declarations
  • If, Do, and While Statements
  • For Statements
  • For-In Statements
  • For-Of Statements
  • Continue Statements
  • Break Statements
  • Return Statements
  • With Statements
  • Switch Statements
  • Throw Statements
  • * Try Statements

Function

  • Function Declarations
  • Function Implementations

Interfaces

Class

  • Class Declarations
  • New class

Build in functions

Extra

在实现 TS 的语法过程中可以先只支持 number 类型, 如果过早考虑其他类型会遇到大量类似 string + number = ? 这类的奇怪特性.

@mohanson
Copy link
Contributor Author

@yejiayu

@yejiayu
Copy link
Contributor

yejiayu commented Aug 15, 2019

Throw 和 Try 要做,否则异常怎么抛到外部?难道用返回值吗?

@mohanson
Copy link
Contributor Author

对的. Throw 和 Try 不是必须的.

@yejiayu
Copy link
Contributor

yejiayu commented Aug 15, 2019

这是 c 的做法吧。。。,最少也得支持 throw 才行

@mohanson
Copy link
Contributor Author

这是 c 的做法吧。。。,最少也得支持 throw 才行

嗯, 可以. 已修改.

@orangemio
Copy link

我躺好了,坐等当小白鼠

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants