@harmoniclabs/pebble 0.1.3-dev1 → 0.1.3-dev3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IR/tree_utils/intToUtf8Bytes.d.ts +8 -0
- package/dist/IR/tree_utils/intToUtf8Bytes.js +49 -0
- package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
- package/dist/ast/nodes/statements/PebbleStmt.js +2 -0
- package/dist/ast/nodes/statements/TraceStmt.d.ts +11 -0
- package/dist/ast/nodes/statements/TraceStmt.js +10 -0
- package/dist/compiler/AstCompiler/AstCompiler.d.ts +11 -0
- package/dist/compiler/AstCompiler/AstCompiler.js +185 -0
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +8 -0
- package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -0
- package/dist/compiler/AstCompiler/internal/statements/_compileTraceStmt.d.ts +4 -0
- package/dist/compiler/AstCompiler/internal/statements/_compileTraceStmt.js +15 -0
- package/dist/compiler/Compiler.d.ts +5 -0
- package/dist/compiler/Compiler.js +25 -1
- package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +5 -3
- package/dist/compiler/TirCompiler/expressify/expressify.js +8 -0
- package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +2 -0
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +10 -1
- package/dist/compiler/tir/expressions/TirExpr.d.ts +2 -1
- package/dist/compiler/tir/expressions/TirExpr.js +2 -0
- package/dist/compiler/tir/expressions/TirTraceExpr.d.ts +22 -0
- package/dist/compiler/tir/expressions/TirTraceExpr.js +53 -0
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +6 -0
- package/dist/compiler/tir/statements/TirStmt.d.ts +2 -1
- package/dist/compiler/tir/statements/TirStmt.js +2 -0
- package/dist/compiler/tir/statements/TirTraceStmt.d.ts +15 -0
- package/dist/compiler/tir/statements/TirTraceStmt.js +20 -0
- package/dist/parser/Parser.d.ts +2 -0
- package/dist/parser/Parser.js +15 -0
- package/dist/tokenizer/Token.d.ts +82 -81
- package/dist/tokenizer/Token.js +82 -81
- package/dist/tokenizer/utils/tokenFromKeyword.js +2 -0
- package/dist/utils/array/keepSortedArrInplace.js +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { _ir_apps } from "../../../IR/IRNodes/IRApp.js";
|
|
2
|
+
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
3
|
+
import { hoisted_intToUtf8Bytes } from "../../../IR/tree_utils/intToUtf8Bytes.js";
|
|
4
|
+
import { mergeSortedStrArrInplace } from "../../../utils/array/mergeSortedStrArrInplace.js";
|
|
5
|
+
import { TirIntT } from "../types/TirNativeType/index.js";
|
|
6
|
+
import { getUnaliased } from "../types/utils/getUnaliased.js";
|
|
7
|
+
export class TirTraceExpr {
|
|
8
|
+
traceExpr;
|
|
9
|
+
continuation;
|
|
10
|
+
range;
|
|
11
|
+
get type() { return this.continuation.type; }
|
|
12
|
+
constructor(
|
|
13
|
+
/** must be bytes or int (converted to string via decodeUtf8 in toIR) */
|
|
14
|
+
traceExpr, continuation, range) {
|
|
15
|
+
this.traceExpr = traceExpr;
|
|
16
|
+
this.continuation = continuation;
|
|
17
|
+
this.range = range;
|
|
18
|
+
}
|
|
19
|
+
toString() {
|
|
20
|
+
return `(trace ${this.traceExpr.toString()} ${this.continuation.toString()})`;
|
|
21
|
+
}
|
|
22
|
+
pretty(indent) {
|
|
23
|
+
const singleIndent = " ";
|
|
24
|
+
const indent_base = singleIndent.repeat(indent);
|
|
25
|
+
const indent_1 = indent_base + singleIndent;
|
|
26
|
+
return (`(trace` +
|
|
27
|
+
`\n${indent_1}${this.traceExpr.pretty(indent + 1)}` +
|
|
28
|
+
`\n${indent_1}${this.continuation.pretty(indent + 1)}` +
|
|
29
|
+
`\n${indent_base})`);
|
|
30
|
+
}
|
|
31
|
+
clone() {
|
|
32
|
+
return new TirTraceExpr(this.traceExpr.clone(), this.continuation.clone(), this.range.clone());
|
|
33
|
+
}
|
|
34
|
+
deps() {
|
|
35
|
+
return mergeSortedStrArrInplace(this.traceExpr.deps(), this.continuation.deps());
|
|
36
|
+
}
|
|
37
|
+
get isConstant() { return this.traceExpr.isConstant && this.continuation.isConstant; }
|
|
38
|
+
toIR(ctx) {
|
|
39
|
+
let bytesIR;
|
|
40
|
+
const exprType = getUnaliased(this.traceExpr.type);
|
|
41
|
+
if (exprType instanceof TirIntT) {
|
|
42
|
+
// int -> bytes via intToUtf8Bytes
|
|
43
|
+
bytesIR = _ir_apps(hoisted_intToUtf8Bytes.clone(), this.traceExpr.toIR(ctx));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// assume bytes
|
|
47
|
+
bytesIR = this.traceExpr.toIR(ctx);
|
|
48
|
+
}
|
|
49
|
+
return _ir_apps(IRNative.trace,
|
|
50
|
+
// bytes -> string via decodeUtf8
|
|
51
|
+
_ir_apps(IRNative.decodeUtf8, bytesIR), this.continuation.toIR(ctx));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -5,6 +5,7 @@ import { TirBytesT } from "../types/TirNativeType/native/bytes.js";
|
|
|
5
5
|
import { TirDataT } from "../types/TirNativeType/native/data.js";
|
|
6
6
|
import { TirIntT } from "../types/TirNativeType/native/int.js";
|
|
7
7
|
import { TirDataOptT } from "../types/TirNativeType/native/Optional/data.js";
|
|
8
|
+
import { TirStringT } from "../types/TirNativeType/native/string.js";
|
|
8
9
|
import { TirDataStructType } from "../types/TirStructType.js";
|
|
9
10
|
import { getUnaliased } from "../types/utils/getUnaliased.js";
|
|
10
11
|
import { _inlineFromData } from "./TirFromDataExpr.js";
|
|
@@ -69,6 +70,11 @@ export class TirTypeConversionExpr {
|
|
|
69
70
|
return _ir_apps(IRNative._intToBool, exprIR);
|
|
70
71
|
throw new Error(`Cannot convert from ${from_t.toString()} to ${to_t.toString()}`);
|
|
71
72
|
}
|
|
73
|
+
if (to_t instanceof TirStringT) {
|
|
74
|
+
if (from_t instanceof TirBytesT)
|
|
75
|
+
return _ir_apps(IRNative.decodeUtf8, exprIR);
|
|
76
|
+
throw new Error(`Cannot convert from ${from_t.toString()} to ${to_t.toString()}`);
|
|
77
|
+
}
|
|
72
78
|
throw new Error(`Cannot convert from ${from_t.toString()} to ${to_t.toString()}`);
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -4,6 +4,7 @@ import { TirBlockStmt } from "./TirBlockStmt.js";
|
|
|
4
4
|
import { TirBreakStmt } from "./TirBreakStmt.js";
|
|
5
5
|
import { TirContinueStmt } from "./TirContinueStmt.js";
|
|
6
6
|
import { TirFailStmt } from "./TirFailStmt.js";
|
|
7
|
+
import { TirTraceStmt } from "./TirTraceStmt.js";
|
|
7
8
|
import { TirForOfStmt } from "./TirForOfStmt.js";
|
|
8
9
|
import { TirForStmt } from "./TirForStmt.js";
|
|
9
10
|
import { TirIfStmt } from "./TirIfStmt.js";
|
|
@@ -30,5 +31,5 @@ export interface ITirStmt extends HasSourceRange {
|
|
|
30
31
|
toString: () => string;
|
|
31
32
|
pretty: (indent: number) => string;
|
|
32
33
|
}
|
|
33
|
-
export type TirStmt = TirVarDecl | TirIfStmt | TirForStmt | TirForOfStmt | TirWhileStmt | TirReturnStmt | TirBlockStmt | TirBreakStmt | TirContinueStmt | TirFailStmt | TirAssertStmt | TirMatchStmt | TirAssignmentStmt;
|
|
34
|
+
export type TirStmt = TirVarDecl | TirIfStmt | TirForStmt | TirForOfStmt | TirWhileStmt | TirReturnStmt | TirBlockStmt | TirBreakStmt | TirContinueStmt | TirFailStmt | TirAssertStmt | TirTraceStmt | TirMatchStmt | TirAssignmentStmt;
|
|
34
35
|
export declare function isTirStmt(thing: any): thing is TirStmt;
|
|
@@ -5,6 +5,7 @@ import { TirBlockStmt } from "./TirBlockStmt.js";
|
|
|
5
5
|
import { TirBreakStmt } from "./TirBreakStmt.js";
|
|
6
6
|
import { TirContinueStmt } from "./TirContinueStmt.js";
|
|
7
7
|
import { TirFailStmt } from "./TirFailStmt.js";
|
|
8
|
+
import { TirTraceStmt } from "./TirTraceStmt.js";
|
|
8
9
|
import { TirForOfStmt } from "./TirForOfStmt.js";
|
|
9
10
|
import { TirForStmt } from "./TirForStmt.js";
|
|
10
11
|
import { TirIfStmt } from "./TirIfStmt.js";
|
|
@@ -32,6 +33,7 @@ export function isTirStmt(thing) {
|
|
|
32
33
|
|| thing instanceof TirContinueStmt
|
|
33
34
|
|| thing instanceof TirFailStmt
|
|
34
35
|
|| thing instanceof TirAssertStmt
|
|
36
|
+
|| thing instanceof TirTraceStmt
|
|
35
37
|
// || thing instanceof TirTestStmt
|
|
36
38
|
|| thing instanceof TirMatchStmt
|
|
37
39
|
|| thing instanceof TirAssignmentStmt
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SourceRange } from "../../../ast/Source/SourceRange.js";
|
|
2
|
+
import { TirExpr } from "../expressions/TirExpr.js";
|
|
3
|
+
import { ITirStmt } from "./TirStmt.js";
|
|
4
|
+
export declare class TirTraceStmt implements ITirStmt {
|
|
5
|
+
/** must be string */
|
|
6
|
+
expr: TirExpr;
|
|
7
|
+
readonly range: SourceRange;
|
|
8
|
+
constructor(
|
|
9
|
+
/** must be string */
|
|
10
|
+
expr: TirExpr, range: SourceRange);
|
|
11
|
+
toString(): string;
|
|
12
|
+
pretty(indent: number): string;
|
|
13
|
+
definitelyTerminates(): boolean;
|
|
14
|
+
deps(): string[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class TirTraceStmt {
|
|
2
|
+
expr;
|
|
3
|
+
range;
|
|
4
|
+
constructor(
|
|
5
|
+
/** must be string */
|
|
6
|
+
expr, range) {
|
|
7
|
+
this.expr = expr;
|
|
8
|
+
this.range = range;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return `trace ${this.expr.toString()}`;
|
|
12
|
+
}
|
|
13
|
+
pretty(indent) {
|
|
14
|
+
return `trace ${this.expr.pretty(indent)}`;
|
|
15
|
+
}
|
|
16
|
+
definitelyTerminates() { return false; }
|
|
17
|
+
deps() {
|
|
18
|
+
return this.expr.deps();
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/parser/Parser.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { IfStmt } from "../ast/nodes/statements/IfStmt.js";
|
|
|
22
22
|
import { ReturnStmt } from "../ast/nodes/statements/ReturnStmt.js";
|
|
23
23
|
import { FuncDecl } from "../ast/nodes/statements/declarations/FuncDecl.js";
|
|
24
24
|
import { FailStmt } from "../ast/nodes/statements/FailStmt.js";
|
|
25
|
+
import { TraceStmt } from "../ast/nodes/statements/TraceStmt.js";
|
|
25
26
|
import { AssertStmt } from "../ast/nodes/statements/AssertStmt.js";
|
|
26
27
|
import { TestStmt } from "../ast/nodes/statements/TestStmt.js";
|
|
27
28
|
import { MatchStmt } from "../ast/nodes/statements/MatchStmt.js";
|
|
@@ -131,6 +132,7 @@ export declare class Parser extends DiagnosticEmitter {
|
|
|
131
132
|
parseTestStatement(): TestStmt | undefined;
|
|
132
133
|
parseMatchStatement(): MatchStmt | undefined;
|
|
133
134
|
parseFailStatement(): FailStmt | undefined;
|
|
135
|
+
parseTraceStatement(): TraceStmt | undefined;
|
|
134
136
|
parseAssertStatement(): AssertStmt | undefined;
|
|
135
137
|
parseWhileStatement(): WhileStmt | undefined;
|
|
136
138
|
/**
|
package/dist/parser/Parser.js
CHANGED
|
@@ -41,6 +41,7 @@ import { ReturnStmt } from "../ast/nodes/statements/ReturnStmt.js";
|
|
|
41
41
|
import { EmptyStmt } from "../ast/nodes/statements/EmptyStmt.js";
|
|
42
42
|
import { FuncDecl } from "../ast/nodes/statements/declarations/FuncDecl.js";
|
|
43
43
|
import { FailStmt } from "../ast/nodes/statements/FailStmt.js";
|
|
44
|
+
import { TraceStmt } from "../ast/nodes/statements/TraceStmt.js";
|
|
44
45
|
import { AssertStmt } from "../ast/nodes/statements/AssertStmt.js";
|
|
45
46
|
import { TestStmt } from "../ast/nodes/statements/TestStmt.js";
|
|
46
47
|
import { MatchStmt, MatchStmtCase, MatchStmtElseCase } from "../ast/nodes/statements/MatchStmt.js";
|
|
@@ -1919,6 +1920,12 @@ export class Parser extends DiagnosticEmitter {
|
|
|
1919
1920
|
break;
|
|
1920
1921
|
}
|
|
1921
1922
|
;
|
|
1923
|
+
case Token.Trace:
|
|
1924
|
+
{
|
|
1925
|
+
statement = this.parseTraceStatement();
|
|
1926
|
+
break;
|
|
1927
|
+
}
|
|
1928
|
+
;
|
|
1922
1929
|
// case Token.Try: {
|
|
1923
1930
|
// statement = this.parseTryStatement();
|
|
1924
1931
|
// break;
|
|
@@ -2319,6 +2326,14 @@ export class Parser extends DiagnosticEmitter {
|
|
|
2319
2326
|
return undefined;
|
|
2320
2327
|
return new FailStmt(expr, tn.range());
|
|
2321
2328
|
}
|
|
2329
|
+
parseTraceStatement() {
|
|
2330
|
+
const tn = this.tn;
|
|
2331
|
+
// at 'trace': Expression ';'?
|
|
2332
|
+
const expr = this.parseExpr();
|
|
2333
|
+
if (!expr)
|
|
2334
|
+
return this.error(DiagnosticCode.Expression_expected, tn.range());
|
|
2335
|
+
return new TraceStmt(expr, tn.range());
|
|
2336
|
+
}
|
|
2322
2337
|
parseAssertStatement() {
|
|
2323
2338
|
const tn = this.tn;
|
|
2324
2339
|
const startPos = tn.tokenPos;
|
|
@@ -41,129 +41,130 @@ export declare enum Token {
|
|
|
41
41
|
Test = 38,
|
|
42
42
|
Fail = 39,
|
|
43
43
|
Assert = 40,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
Trace = 41,
|
|
45
|
+
Contract = 42,
|
|
46
|
+
Param = 43,
|
|
47
|
+
Spend = 44,
|
|
48
|
+
Mint = 45,
|
|
49
|
+
Certify = 46,
|
|
50
|
+
Withdraw = 47,
|
|
51
|
+
Propose = 48,
|
|
52
|
+
Vote = 49,
|
|
53
|
+
Context = 50,
|
|
53
54
|
/** `{` */
|
|
54
|
-
OpenBrace =
|
|
55
|
+
OpenBrace = 51,
|
|
55
56
|
/** `}` */
|
|
56
|
-
CloseBrace =
|
|
57
|
-
OpenParen =
|
|
58
|
-
CloseParen =
|
|
57
|
+
CloseBrace = 52,
|
|
58
|
+
OpenParen = 53,
|
|
59
|
+
CloseParen = 54,
|
|
59
60
|
/** `[` */
|
|
60
|
-
OpenBracket =
|
|
61
|
+
OpenBracket = 55,
|
|
61
62
|
/** `]` */
|
|
62
|
-
CloseBracket =
|
|
63
|
+
CloseBracket = 56,
|
|
63
64
|
/** `.` */
|
|
64
|
-
Dot =
|
|
65
|
+
Dot = 57,
|
|
65
66
|
/** `...` */
|
|
66
|
-
Dot_Dot_Dot =
|
|
67
|
+
Dot_Dot_Dot = 58,
|
|
67
68
|
/** `;` */
|
|
68
|
-
Semicolon =
|
|
69
|
+
Semicolon = 59,
|
|
69
70
|
/** `,` */
|
|
70
|
-
Comma =
|
|
71
|
+
Comma = 60,
|
|
71
72
|
/** `<` */
|
|
72
|
-
LessThan =
|
|
73
|
+
LessThan = 61,
|
|
73
74
|
/** `>` */
|
|
74
|
-
GreaterThan =
|
|
75
|
+
GreaterThan = 62,
|
|
75
76
|
/** `<=` */
|
|
76
|
-
LessThan_Equals =
|
|
77
|
+
LessThan_Equals = 63,
|
|
77
78
|
/** `>=` */
|
|
78
|
-
GreaterThan_Equals =
|
|
79
|
+
GreaterThan_Equals = 64,
|
|
79
80
|
/** `==` */
|
|
80
|
-
Equals_Equals =
|
|
81
|
+
Equals_Equals = 65,
|
|
81
82
|
/** `!=` */
|
|
82
|
-
Exclamation_Equals =
|
|
83
|
+
Exclamation_Equals = 66,
|
|
83
84
|
/** `===` */
|
|
84
|
-
Equals_Equals_Equals =
|
|
85
|
+
Equals_Equals_Equals = 67,
|
|
85
86
|
/** `!==` */
|
|
86
|
-
Exclamation_Equals_Equals =
|
|
87
|
+
Exclamation_Equals_Equals = 68,
|
|
87
88
|
/** `=>` */
|
|
88
|
-
FatArrow =
|
|
89
|
+
FatArrow = 69,
|
|
89
90
|
/** `+` */
|
|
90
|
-
Plus =
|
|
91
|
+
Plus = 70,
|
|
91
92
|
/** `-` */
|
|
92
|
-
Minus =
|
|
93
|
+
Minus = 71,
|
|
93
94
|
/** `**` */
|
|
94
|
-
Asterisk_Asterisk =
|
|
95
|
+
Asterisk_Asterisk = 72,
|
|
95
96
|
/** `*` */
|
|
96
|
-
Asterisk =
|
|
97
|
+
Asterisk = 73,
|
|
97
98
|
/** `/` */
|
|
98
|
-
Slash =
|
|
99
|
+
Slash = 74,
|
|
99
100
|
/** `%` */
|
|
100
|
-
Percent =
|
|
101
|
+
Percent = 75,
|
|
101
102
|
/** `++` */
|
|
102
|
-
Plus_Plus =
|
|
103
|
+
Plus_Plus = 76,
|
|
103
104
|
/** `--` */
|
|
104
|
-
Minus_Minus =
|
|
105
|
+
Minus_Minus = 77,
|
|
105
106
|
/** `<<` */
|
|
106
|
-
LessThan_LessThan =
|
|
107
|
+
LessThan_LessThan = 78,
|
|
107
108
|
/** `>>` */
|
|
108
|
-
GreaterThan_GreaterThan =
|
|
109
|
+
GreaterThan_GreaterThan = 79,
|
|
109
110
|
/** `>>>` */
|
|
110
|
-
GreaterThan_GreaterThan_GreaterThan =
|
|
111
|
+
GreaterThan_GreaterThan_GreaterThan = 80,
|
|
111
112
|
/** `+` */
|
|
112
|
-
Ampersand =
|
|
113
|
+
Ampersand = 81,
|
|
113
114
|
/** `|` */
|
|
114
|
-
Bar =
|
|
115
|
+
Bar = 82,
|
|
115
116
|
/** `^` */
|
|
116
|
-
Caret =
|
|
117
|
+
Caret = 83,
|
|
117
118
|
/** `!` */
|
|
118
|
-
Exclamation =
|
|
119
|
+
Exclamation = 84,
|
|
119
120
|
/** `~` */
|
|
120
|
-
Tilde =
|
|
121
|
+
Tilde = 85,
|
|
121
122
|
/** `&&` */
|
|
122
|
-
Ampersand_Ampersand =
|
|
123
|
+
Ampersand_Ampersand = 86,
|
|
123
124
|
/** `||` */
|
|
124
|
-
Bar_Bar =
|
|
125
|
+
Bar_Bar = 87,
|
|
125
126
|
/** `?` */
|
|
126
|
-
Question =
|
|
127
|
+
Question = 88,
|
|
127
128
|
/** `:` */
|
|
128
|
-
Colon =
|
|
129
|
+
Colon = 89,
|
|
129
130
|
/** `=` */
|
|
130
|
-
Equals =
|
|
131
|
-
Plus_Equals =
|
|
132
|
-
Minus_Equals =
|
|
133
|
-
Asterisk_Equals =
|
|
134
|
-
Asterisk_Asterisk_Equals =
|
|
135
|
-
Slash_Equals =
|
|
136
|
-
Percent_Equals =
|
|
137
|
-
LessThan_LessThan_Equals =
|
|
138
|
-
GreaterThan_GreaterThan_Equals =
|
|
139
|
-
GreaterThan_GreaterThan_GreaterThan_Equals =
|
|
140
|
-
Ampersand_Equals =
|
|
141
|
-
Bar_Equals =
|
|
142
|
-
Caret_Equals =
|
|
143
|
-
At =
|
|
131
|
+
Equals = 90,
|
|
132
|
+
Plus_Equals = 91,
|
|
133
|
+
Minus_Equals = 92,
|
|
134
|
+
Asterisk_Equals = 93,
|
|
135
|
+
Asterisk_Asterisk_Equals = 94,
|
|
136
|
+
Slash_Equals = 95,
|
|
137
|
+
Percent_Equals = 96,
|
|
138
|
+
LessThan_LessThan_Equals = 97,
|
|
139
|
+
GreaterThan_GreaterThan_Equals = 98,
|
|
140
|
+
GreaterThan_GreaterThan_GreaterThan_Equals = 99,
|
|
141
|
+
Ampersand_Equals = 100,
|
|
142
|
+
Bar_Equals = 101,
|
|
143
|
+
Caret_Equals = 102,
|
|
144
|
+
At = 103,
|
|
144
145
|
/** `??=` */
|
|
145
|
-
Question_Question_Equals =
|
|
146
|
+
Question_Question_Equals = 104,
|
|
146
147
|
/** `||=` */
|
|
147
|
-
Bar_Bar_Equals =
|
|
148
|
+
Bar_Bar_Equals = 105,
|
|
148
149
|
/** `&&=` */
|
|
149
|
-
Ampersand_Ampersand_Equals =
|
|
150
|
+
Ampersand_Ampersand_Equals = 106,
|
|
150
151
|
/** `??` */
|
|
151
|
-
Question_Question =
|
|
152
|
+
Question_Question = 107,
|
|
152
153
|
/** `?.` */
|
|
153
|
-
Question_Dot =
|
|
154
|
+
Question_Dot = 108,
|
|
154
155
|
/** `!.` */
|
|
155
|
-
Exclamation_Dot =
|
|
156
|
-
Data =
|
|
157
|
-
Bytes =
|
|
158
|
-
Optional =
|
|
159
|
-
List =
|
|
160
|
-
LinearMap =
|
|
161
|
-
Runtime =
|
|
162
|
-
Identifier =
|
|
163
|
-
StringLiteral =
|
|
164
|
-
HexBytesLiteral =
|
|
165
|
-
IntegerLiteral =
|
|
166
|
-
StringTemplateLiteralQuote =
|
|
167
|
-
Invalid =
|
|
168
|
-
EndOfFile =
|
|
156
|
+
Exclamation_Dot = 109,
|
|
157
|
+
Data = 110,
|
|
158
|
+
Bytes = 111,
|
|
159
|
+
Optional = 112,
|
|
160
|
+
List = 113,
|
|
161
|
+
LinearMap = 114,
|
|
162
|
+
Runtime = 115,
|
|
163
|
+
Identifier = 116,
|
|
164
|
+
StringLiteral = 117,
|
|
165
|
+
HexBytesLiteral = 118,
|
|
166
|
+
IntegerLiteral = 119,
|
|
167
|
+
StringTemplateLiteralQuote = 120,
|
|
168
|
+
Invalid = 121,
|
|
169
|
+
EndOfFile = 122
|
|
169
170
|
}
|
package/dist/tokenizer/Token.js
CHANGED
|
@@ -78,139 +78,140 @@ export var Token;
|
|
|
78
78
|
Token[Token["Test"] = 38] = "Test";
|
|
79
79
|
Token[Token["Fail"] = 39] = "Fail";
|
|
80
80
|
Token[Token["Assert"] = 40] = "Assert";
|
|
81
|
+
Token[Token["Trace"] = 41] = "Trace";
|
|
81
82
|
// contract keywords
|
|
82
|
-
Token[Token["Contract"] =
|
|
83
|
-
Token[Token["Param"] =
|
|
84
|
-
Token[Token["Spend"] =
|
|
85
|
-
Token[Token["Mint"] =
|
|
86
|
-
Token[Token["Certify"] =
|
|
87
|
-
Token[Token["Withdraw"] =
|
|
88
|
-
Token[Token["Propose"] =
|
|
89
|
-
Token[Token["Vote"] =
|
|
90
|
-
Token[Token["Context"] =
|
|
83
|
+
Token[Token["Contract"] = 42] = "Contract";
|
|
84
|
+
Token[Token["Param"] = 43] = "Param";
|
|
85
|
+
Token[Token["Spend"] = 44] = "Spend";
|
|
86
|
+
Token[Token["Mint"] = 45] = "Mint";
|
|
87
|
+
Token[Token["Certify"] = 46] = "Certify";
|
|
88
|
+
Token[Token["Withdraw"] = 47] = "Withdraw";
|
|
89
|
+
Token[Token["Propose"] = 48] = "Propose";
|
|
90
|
+
Token[Token["Vote"] = 49] = "Vote";
|
|
91
|
+
Token[Token["Context"] = 50] = "Context";
|
|
91
92
|
// punctuation
|
|
92
93
|
/** `{` */
|
|
93
|
-
Token[Token["OpenBrace"] =
|
|
94
|
+
Token[Token["OpenBrace"] = 51] = "OpenBrace";
|
|
94
95
|
/** `}` */
|
|
95
|
-
Token[Token["CloseBrace"] =
|
|
96
|
-
Token[Token["OpenParen"] =
|
|
97
|
-
Token[Token["CloseParen"] =
|
|
96
|
+
Token[Token["CloseBrace"] = 52] = "CloseBrace";
|
|
97
|
+
Token[Token["OpenParen"] = 53] = "OpenParen";
|
|
98
|
+
Token[Token["CloseParen"] = 54] = "CloseParen";
|
|
98
99
|
/** `[` */
|
|
99
|
-
Token[Token["OpenBracket"] =
|
|
100
|
+
Token[Token["OpenBracket"] = 55] = "OpenBracket";
|
|
100
101
|
/** `]` */
|
|
101
|
-
Token[Token["CloseBracket"] =
|
|
102
|
+
Token[Token["CloseBracket"] = 56] = "CloseBracket";
|
|
102
103
|
/** `.` */
|
|
103
|
-
Token[Token["Dot"] =
|
|
104
|
+
Token[Token["Dot"] = 57] = "Dot";
|
|
104
105
|
/** `...` */
|
|
105
|
-
Token[Token["Dot_Dot_Dot"] =
|
|
106
|
+
Token[Token["Dot_Dot_Dot"] = 58] = "Dot_Dot_Dot";
|
|
106
107
|
/** `;` */
|
|
107
|
-
Token[Token["Semicolon"] =
|
|
108
|
+
Token[Token["Semicolon"] = 59] = "Semicolon";
|
|
108
109
|
/** `,` */
|
|
109
|
-
Token[Token["Comma"] =
|
|
110
|
+
Token[Token["Comma"] = 60] = "Comma";
|
|
110
111
|
/** `<` */
|
|
111
|
-
Token[Token["LessThan"] =
|
|
112
|
+
Token[Token["LessThan"] = 61] = "LessThan";
|
|
112
113
|
/** `>` */
|
|
113
|
-
Token[Token["GreaterThan"] =
|
|
114
|
+
Token[Token["GreaterThan"] = 62] = "GreaterThan";
|
|
114
115
|
/** `<=` */
|
|
115
|
-
Token[Token["LessThan_Equals"] =
|
|
116
|
+
Token[Token["LessThan_Equals"] = 63] = "LessThan_Equals";
|
|
116
117
|
/** `>=` */
|
|
117
|
-
Token[Token["GreaterThan_Equals"] =
|
|
118
|
+
Token[Token["GreaterThan_Equals"] = 64] = "GreaterThan_Equals";
|
|
118
119
|
/** `==` */
|
|
119
|
-
Token[Token["Equals_Equals"] =
|
|
120
|
+
Token[Token["Equals_Equals"] = 65] = "Equals_Equals";
|
|
120
121
|
/** `!=` */
|
|
121
|
-
Token[Token["Exclamation_Equals"] =
|
|
122
|
+
Token[Token["Exclamation_Equals"] = 66] = "Exclamation_Equals";
|
|
122
123
|
/** `===` */
|
|
123
|
-
Token[Token["Equals_Equals_Equals"] =
|
|
124
|
+
Token[Token["Equals_Equals_Equals"] = 67] = "Equals_Equals_Equals";
|
|
124
125
|
/** `!==` */
|
|
125
|
-
Token[Token["Exclamation_Equals_Equals"] =
|
|
126
|
+
Token[Token["Exclamation_Equals_Equals"] = 68] = "Exclamation_Equals_Equals";
|
|
126
127
|
/** `=>` */
|
|
127
|
-
Token[Token["FatArrow"] =
|
|
128
|
+
Token[Token["FatArrow"] = 69] = "FatArrow";
|
|
128
129
|
/** `+` */
|
|
129
|
-
Token[Token["Plus"] =
|
|
130
|
+
Token[Token["Plus"] = 70] = "Plus";
|
|
130
131
|
/** `-` */
|
|
131
|
-
Token[Token["Minus"] =
|
|
132
|
+
Token[Token["Minus"] = 71] = "Minus";
|
|
132
133
|
/** `**` */
|
|
133
|
-
Token[Token["Asterisk_Asterisk"] =
|
|
134
|
+
Token[Token["Asterisk_Asterisk"] = 72] = "Asterisk_Asterisk";
|
|
134
135
|
/** `*` */
|
|
135
|
-
Token[Token["Asterisk"] =
|
|
136
|
+
Token[Token["Asterisk"] = 73] = "Asterisk";
|
|
136
137
|
/** `/` */
|
|
137
|
-
Token[Token["Slash"] =
|
|
138
|
+
Token[Token["Slash"] = 74] = "Slash";
|
|
138
139
|
/** `%` */
|
|
139
|
-
Token[Token["Percent"] =
|
|
140
|
+
Token[Token["Percent"] = 75] = "Percent";
|
|
140
141
|
/** `++` */
|
|
141
|
-
Token[Token["Plus_Plus"] =
|
|
142
|
+
Token[Token["Plus_Plus"] = 76] = "Plus_Plus";
|
|
142
143
|
/** `--` */
|
|
143
|
-
Token[Token["Minus_Minus"] =
|
|
144
|
+
Token[Token["Minus_Minus"] = 77] = "Minus_Minus";
|
|
144
145
|
/** `<<` */
|
|
145
|
-
Token[Token["LessThan_LessThan"] =
|
|
146
|
+
Token[Token["LessThan_LessThan"] = 78] = "LessThan_LessThan";
|
|
146
147
|
/** `>>` */
|
|
147
|
-
Token[Token["GreaterThan_GreaterThan"] =
|
|
148
|
+
Token[Token["GreaterThan_GreaterThan"] = 79] = "GreaterThan_GreaterThan";
|
|
148
149
|
/** `>>>` */
|
|
149
|
-
Token[Token["GreaterThan_GreaterThan_GreaterThan"] =
|
|
150
|
+
Token[Token["GreaterThan_GreaterThan_GreaterThan"] = 80] = "GreaterThan_GreaterThan_GreaterThan";
|
|
150
151
|
/** `+` */
|
|
151
|
-
Token[Token["Ampersand"] =
|
|
152
|
+
Token[Token["Ampersand"] = 81] = "Ampersand";
|
|
152
153
|
/** `|` */
|
|
153
|
-
Token[Token["Bar"] =
|
|
154
|
+
Token[Token["Bar"] = 82] = "Bar";
|
|
154
155
|
/** `^` */
|
|
155
|
-
Token[Token["Caret"] =
|
|
156
|
+
Token[Token["Caret"] = 83] = "Caret";
|
|
156
157
|
/** `!` */
|
|
157
|
-
Token[Token["Exclamation"] =
|
|
158
|
+
Token[Token["Exclamation"] = 84] = "Exclamation";
|
|
158
159
|
/** `~` */
|
|
159
|
-
Token[Token["Tilde"] =
|
|
160
|
+
Token[Token["Tilde"] = 85] = "Tilde";
|
|
160
161
|
/** `&&` */
|
|
161
|
-
Token[Token["Ampersand_Ampersand"] =
|
|
162
|
+
Token[Token["Ampersand_Ampersand"] = 86] = "Ampersand_Ampersand";
|
|
162
163
|
/** `||` */
|
|
163
|
-
Token[Token["Bar_Bar"] =
|
|
164
|
+
Token[Token["Bar_Bar"] = 87] = "Bar_Bar";
|
|
164
165
|
/** `?` */
|
|
165
|
-
Token[Token["Question"] =
|
|
166
|
+
Token[Token["Question"] = 88] = "Question";
|
|
166
167
|
/** `:` */
|
|
167
|
-
Token[Token["Colon"] =
|
|
168
|
+
Token[Token["Colon"] = 89] = "Colon";
|
|
168
169
|
/** `=` */
|
|
169
|
-
Token[Token["Equals"] =
|
|
170
|
-
Token[Token["Plus_Equals"] =
|
|
171
|
-
Token[Token["Minus_Equals"] =
|
|
172
|
-
Token[Token["Asterisk_Equals"] =
|
|
173
|
-
Token[Token["Asterisk_Asterisk_Equals"] =
|
|
174
|
-
Token[Token["Slash_Equals"] =
|
|
175
|
-
Token[Token["Percent_Equals"] =
|
|
176
|
-
Token[Token["LessThan_LessThan_Equals"] =
|
|
177
|
-
Token[Token["GreaterThan_GreaterThan_Equals"] =
|
|
178
|
-
Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] =
|
|
179
|
-
Token[Token["Ampersand_Equals"] =
|
|
180
|
-
Token[Token["Bar_Equals"] =
|
|
181
|
-
Token[Token["Caret_Equals"] =
|
|
182
|
-
Token[Token["At"] =
|
|
170
|
+
Token[Token["Equals"] = 90] = "Equals";
|
|
171
|
+
Token[Token["Plus_Equals"] = 91] = "Plus_Equals";
|
|
172
|
+
Token[Token["Minus_Equals"] = 92] = "Minus_Equals";
|
|
173
|
+
Token[Token["Asterisk_Equals"] = 93] = "Asterisk_Equals";
|
|
174
|
+
Token[Token["Asterisk_Asterisk_Equals"] = 94] = "Asterisk_Asterisk_Equals";
|
|
175
|
+
Token[Token["Slash_Equals"] = 95] = "Slash_Equals";
|
|
176
|
+
Token[Token["Percent_Equals"] = 96] = "Percent_Equals";
|
|
177
|
+
Token[Token["LessThan_LessThan_Equals"] = 97] = "LessThan_LessThan_Equals";
|
|
178
|
+
Token[Token["GreaterThan_GreaterThan_Equals"] = 98] = "GreaterThan_GreaterThan_Equals";
|
|
179
|
+
Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] = 99] = "GreaterThan_GreaterThan_GreaterThan_Equals";
|
|
180
|
+
Token[Token["Ampersand_Equals"] = 100] = "Ampersand_Equals";
|
|
181
|
+
Token[Token["Bar_Equals"] = 101] = "Bar_Equals";
|
|
182
|
+
Token[Token["Caret_Equals"] = 102] = "Caret_Equals";
|
|
183
|
+
Token[Token["At"] = 103] = "At";
|
|
183
184
|
/** `??=` */
|
|
184
|
-
Token[Token["Question_Question_Equals"] =
|
|
185
|
+
Token[Token["Question_Question_Equals"] = 104] = "Question_Question_Equals";
|
|
185
186
|
/** `||=` */
|
|
186
|
-
Token[Token["Bar_Bar_Equals"] =
|
|
187
|
+
Token[Token["Bar_Bar_Equals"] = 105] = "Bar_Bar_Equals";
|
|
187
188
|
/** `&&=` */
|
|
188
|
-
Token[Token["Ampersand_Ampersand_Equals"] =
|
|
189
|
+
Token[Token["Ampersand_Ampersand_Equals"] = 106] = "Ampersand_Ampersand_Equals";
|
|
189
190
|
/** `??` */
|
|
190
|
-
Token[Token["Question_Question"] =
|
|
191
|
+
Token[Token["Question_Question"] = 107] = "Question_Question";
|
|
191
192
|
/** `?.` */
|
|
192
|
-
Token[Token["Question_Dot"] =
|
|
193
|
+
Token[Token["Question_Dot"] = 108] = "Question_Dot";
|
|
193
194
|
/** `!.` */
|
|
194
|
-
Token[Token["Exclamation_Dot"] =
|
|
195
|
+
Token[Token["Exclamation_Dot"] = 109] = "Exclamation_Dot";
|
|
195
196
|
// custom native types for pebble
|
|
196
|
-
Token[Token["Data"] =
|
|
197
|
-
Token[Token["Bytes"] =
|
|
198
|
-
Token[Token["Optional"] =
|
|
199
|
-
Token[Token["List"] =
|
|
200
|
-
Token[Token["LinearMap"] =
|
|
197
|
+
Token[Token["Data"] = 110] = "Data";
|
|
198
|
+
Token[Token["Bytes"] = 111] = "Bytes";
|
|
199
|
+
Token[Token["Optional"] = 112] = "Optional";
|
|
200
|
+
Token[Token["List"] = 113] = "List";
|
|
201
|
+
Token[Token["LinearMap"] = 114] = "LinearMap";
|
|
201
202
|
// struct decl modifiers
|
|
202
203
|
// taggedModifier, // `tagged` data struct
|
|
203
|
-
Token[Token["Runtime"] =
|
|
204
|
+
Token[Token["Runtime"] = 115] = "Runtime";
|
|
204
205
|
// literals
|
|
205
|
-
Token[Token["Identifier"] =
|
|
206
|
-
Token[Token["StringLiteral"] =
|
|
207
|
-
Token[Token["HexBytesLiteral"] =
|
|
208
|
-
Token[Token["IntegerLiteral"] =
|
|
206
|
+
Token[Token["Identifier"] = 116] = "Identifier";
|
|
207
|
+
Token[Token["StringLiteral"] = 117] = "StringLiteral";
|
|
208
|
+
Token[Token["HexBytesLiteral"] = 118] = "HexBytesLiteral";
|
|
209
|
+
Token[Token["IntegerLiteral"] = 119] = "IntegerLiteral";
|
|
209
210
|
// FloatLiteral,
|
|
210
|
-
Token[Token["StringTemplateLiteralQuote"] =
|
|
211
|
+
Token[Token["StringTemplateLiteralQuote"] = 120] = "StringTemplateLiteralQuote";
|
|
211
212
|
// meta
|
|
212
|
-
Token[Token["Invalid"] =
|
|
213
|
-
Token[Token["EndOfFile"] =
|
|
213
|
+
Token[Token["Invalid"] = 121] = "Invalid";
|
|
214
|
+
Token[Token["EndOfFile"] = 122] = "EndOfFile";
|
|
214
215
|
})(Token || (Token = {}));
|
|
215
216
|
Object.freeze(Token);
|
|
216
217
|
/*
|
|
@@ -203,6 +203,8 @@ export function tokenFromKeyword(text) {
|
|
|
203
203
|
return Token.Type;
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
|
+
if (text === "trace")
|
|
207
|
+
return Token.Trace;
|
|
206
208
|
// if (text === "try") return Token.Try;
|
|
207
209
|
// if (text === "throw") return Token.Throw;
|
|
208
210
|
// if (text === "typeof") return Token.TypeOf;
|