Skip to content

Commit

Permalink
wip (#654): added basic ast structure of the try-catch-statement.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzholzbauer committed Aug 17, 2024
1 parent f00a62c commit 7a72bdb
Show file tree
Hide file tree
Showing 20 changed files with 2,558 additions and 1,817 deletions.
162 changes: 162 additions & 0 deletions kipper/core/KipperLexer.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
FStringExpStart=1
BlockComment=2
LineComment=3
Pragma=4
Const=5
Var=6
As=7
Spread=8
Switch=9
Case=10
Default=11
Break=12
Continue=13
Do=14
While=15
If=16
Else=17
For=18
Enum=19
DefFunc=20
Return=21
CallFunc=22
RetIndicator=23
Class=24
Interface=25
Constructor=26
True=27
False=28
Typeof=29
Try=30
Catch=31
Finally=32
Void=33
Null=34
Undefined=35
Comma=36
SemiColon=37
QuestionMark=38
Colon=39
LeftParen=40
RightParen=41
LeftBracket=42
RightBracket=43
FStringExpEnd=44
LeftBrace=45
RightBrace=46
Plus=47
PlusPlus=48
Minus=49
MinusMinus=50
Star=51
Div=52
Mod=53
PowerTo=54
AndAnd=55
OrOr=56
Not=57
Assign=58
PlusAssign=59
MinusAssign=60
StarAssign=61
DivAssign=62
ModAssign=63
Equal=64
NotEqual=65
Less=66
LessEqual=67
Greater=68
GreaterEqual=69
BitwiseAnd=70
BitwiseOr=71
BitwiseXor=72
BitwiseNot=73
BitwiseZeroFillLeftShift=74
BitwiseSignedRightShift=75
BitwiseZeroFillRightShift=76
Dot=77
Identifier=78
IntegerConstant=79
SingleQuoteStringLiteral=80
DoubleQuoteStringLiteral=81
FloatingConstant=82
Whitespace=83
Newline=84
FStringSingleQuoteStart=85
FStringDoubleQuoteStart=86
FStringSingleQuoteEnd=87
FStringSingleQuoteAtom=88
FStringDoubleQuoteEnd=89
FStringDoubleQuoteAtom=90
'const'=5
'var'=6
'as'=7
'...'=8
'switch'=9
'case'=10
'default'=11
'break'=12
'continue'=13
'do'=14
'while'=15
'if'=16
'else'=17
'for'=18
'enum'=19
'def'=20
'return'=21
'call'=22
'->'=23
'class'=24
'interface'=25
'constructor'=26
'true'=27
'false'=28
'typeof'=29
'try'=30
'catch'=31
'finally'=32
'void'=33
'null'=34
'undefined'=35
','=36
';'=37
'?'=38
':'=39
'('=40
')'=41
'['=42
']'=43
'{'=45
'}'=46
'+'=47
'++'=48
'-'=49
'--'=50
'*'=51
'/'=52
'%'=53
'**'=54
'&&'=55
'||'=56
'!'=57
'='=58
'+='=59
'-='=60
'*='=61
'/='=62
'%='=63
'=='=64
'!='=65
'<'=66
'<='=67
'>'=68
'>='=69
'&'=70
'|'=71
'^'=72
'~'=73
'<<'=74
'>>'=75
'>>>'=76
'.'=77
162 changes: 162 additions & 0 deletions kipper/core/KipperParser.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
FStringExpStart=1
BlockComment=2
LineComment=3
Pragma=4
Const=5
Var=6
As=7
Spread=8
Switch=9
Case=10
Default=11
Break=12
Continue=13
Do=14
While=15
If=16
Else=17
For=18
Enum=19
DefFunc=20
Return=21
CallFunc=22
RetIndicator=23
Class=24
Interface=25
Constructor=26
True=27
False=28
Typeof=29
Try=30
Catch=31
Finally=32
Void=33
Null=34
Undefined=35
Comma=36
SemiColon=37
QuestionMark=38
Colon=39
LeftParen=40
RightParen=41
LeftBracket=42
RightBracket=43
FStringExpEnd=44
LeftBrace=45
RightBrace=46
Plus=47
PlusPlus=48
Minus=49
MinusMinus=50
Star=51
Div=52
Mod=53
PowerTo=54
AndAnd=55
OrOr=56
Not=57
Assign=58
PlusAssign=59
MinusAssign=60
StarAssign=61
DivAssign=62
ModAssign=63
Equal=64
NotEqual=65
Less=66
LessEqual=67
Greater=68
GreaterEqual=69
BitwiseAnd=70
BitwiseOr=71
BitwiseXor=72
BitwiseNot=73
BitwiseZeroFillLeftShift=74
BitwiseSignedRightShift=75
BitwiseZeroFillRightShift=76
Dot=77
Identifier=78
IntegerConstant=79
SingleQuoteStringLiteral=80
DoubleQuoteStringLiteral=81
FloatingConstant=82
Whitespace=83
Newline=84
FStringSingleQuoteStart=85
FStringDoubleQuoteStart=86
FStringSingleQuoteEnd=87
FStringSingleQuoteAtom=88
FStringDoubleQuoteEnd=89
FStringDoubleQuoteAtom=90
'const'=5
'var'=6
'as'=7
'...'=8
'switch'=9
'case'=10
'default'=11
'break'=12
'continue'=13
'do'=14
'while'=15
'if'=16
'else'=17
'for'=18
'enum'=19
'def'=20
'return'=21
'call'=22
'->'=23
'class'=24
'interface'=25
'constructor'=26
'true'=27
'false'=28
'typeof'=29
'try'=30
'catch'=31
'finally'=32
'void'=33
'null'=34
'undefined'=35
','=36
';'=37
'?'=38
':'=39
'('=40
')'=41
'['=42
']'=43
'{'=45
'}'=46
'+'=47
'++'=48
'-'=49
'--'=50
'*'=51
'/'=52
'%'=53
'**'=54
'&&'=55
'||'=56
'!'=57
'='=58
'+='=59
'-='=60
'*='=61
'/='=62
'%='=63
'=='=64
'!='=65
'<'=66
'<='=67
'>'=68
'>='=69
'&'=70
'|'=71
'^'=72
'~'=73
'<<'=74
'>>'=75
'>>>'=76
'.'=77
8 changes: 6 additions & 2 deletions kipper/core/src/compiler/ast/common/ast-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* AST pre-set types that are used throughout the compiler.
* @since 0.10.0
*/
import type {
import {
AdditiveExpressionContext,
ArrayPrimaryExpressionContext,
AssignmentExpressionContext,
Expand Down Expand Up @@ -49,12 +49,13 @@ import type {
ReturnStatementContext,
StringPrimaryExpressionContext,
SwitchStatementContext,
TangledPrimaryExpressionContext,
TangledPrimaryExpressionContext, TryCatchStatementContext,
TypeofTypeSpecifierExpressionContext,
VariableDeclarationContext,
VoidOrNullOrUndefinedPrimaryExpressionContext,
WhileLoopIterationStatementContext,
} from "../../lexer-parser";
import { TryCatchStatement } from "../nodes";

/**
* Union type of all usable expression rule context classes implemented by the {@link ParseRuleKindMapping} for an
Expand Down Expand Up @@ -105,6 +106,7 @@ export type ParserStatementContext =
| WhileLoopIterationStatementContext
| ForLoopIterationStatementContext
| JumpStatementContext
| TryCatchStatementContext
| ReturnStatementContext;

/**
Expand Down Expand Up @@ -162,6 +164,7 @@ export type ASTStatementKind =
| typeof ParseRuleKindMapping.RULE_whileLoopIterationStatement
| typeof ParseRuleKindMapping.RULE_forLoopIterationStatement
| typeof ParseRuleKindMapping.RULE_jumpStatement
| typeof ParseRuleKindMapping.RULE_tryCatchStatement
| typeof ParseRuleKindMapping.RULE_returnStatement;

/**
Expand Down Expand Up @@ -247,6 +250,7 @@ export type ASTStatementRuleName =
| (typeof KindParseRuleMapping)[typeof ParseRuleKindMapping.RULE_whileLoopIterationStatement]
| (typeof KindParseRuleMapping)[typeof ParseRuleKindMapping.RULE_forLoopIterationStatement]
| (typeof KindParseRuleMapping)[typeof ParseRuleKindMapping.RULE_jumpStatement]
| (typeof KindParseRuleMapping)[typeof ParseRuleKindMapping.RULE_tryCatchStatement]
| (typeof KindParseRuleMapping)[typeof ParseRuleKindMapping.RULE_returnStatement];

/**
Expand Down
1 change: 1 addition & 0 deletions kipper/core/src/compiler/ast/nodes/statements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from "./if-statement/";
export * from "./jump-statement/";
export * from "./return-statement/";
export * from "./switch-statement/";
export * from "./try-catch-statement/";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./try-catch-statement";
export * from "./try-catch-statement-semantics";
export * from "./try-catch-statement-type-semantics";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Semantics for AST Node {@link IfStatement}.
* @since 0.12.0
*/
import type { SemanticData } from "../../../ast-node";

/**
* Semantics for AST Node {@link IfStatement}.
* @since 0.12.0
*/
export interface TryCatchStatementSemantics extends SemanticData {

}
Loading

0 comments on commit 7a72bdb

Please sign in to comment.