Skip to content

Commit 9a3d249

Browse files
committed
Refresh grammar and internal function tests
1 parent 426b635 commit 9a3d249

8 files changed

Lines changed: 1212 additions & 1064 deletions

File tree

packages/cashc/src/compiler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import EnsureInvokedFunctionsSafeTraversal from './semantic/EnsureInvokedFunctio
1818
import InjectLocktimeGuardTraversal from './semantic/InjectLocktimeGuardTraversal.js';
1919
import EnsureContainerSemanticsTraversal from './semantic/EnsureContainerSemanticsTraversal.js';
2020
import { FunctionVisibility } from './ast/Globals.js';
21-
import { ParseError } from './Errors.js';
21+
import { NonSpendableCompilationError, ParseError } from './Errors.js';
2222
import { Point } from './ast/Location.js';
2323
import { ImportResolver, ImportedFunctionProvenance, preprocessImports } from './imports.js';
2424

@@ -54,6 +54,9 @@ export function compileString(code: string, compilerOptions: CompileOptions = {}
5454
source: code,
5555
...(sourcePath ? { sourceFile: normaliseSourcePath(sourcePath) } : {}),
5656
});
57+
if (ast.contract.kind === 'library') {
58+
throw new NonSpendableCompilationError(ast.contract);
59+
}
5760

5861
// Semantic analysis
5962
ast = ast.accept(new SymbolTableTraversal()) as Ast;

packages/cashc/src/grammar/CashScript.interp

Lines changed: 10 additions & 1 deletion
Large diffs are not rendered by default.

packages/cashc/src/grammar/CashScript.tokens

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,30 @@ T__54=55
5656
T__55=56
5757
T__56=57
5858
T__57=58
59-
VersionLiteral=59
60-
BooleanLiteral=60
61-
NumberUnit=61
62-
NumberLiteral=62
63-
NumberPart=63
64-
ExponentPart=64
65-
PrimitiveType=65
66-
UnboundedBytes=66
67-
BoundedBytes=67
68-
Bound=68
69-
StringLiteral=69
70-
DateLiteral=70
71-
HexLiteral=71
72-
TxVar=72
73-
UnsafeCast=73
74-
NullaryOp=74
75-
Identifier=75
76-
WHITESPACE=76
77-
COMMENT=77
78-
LINE_COMMENT=78
59+
T__58=59
60+
T__59=60
61+
T__60=61
62+
T__61=62
63+
VersionLiteral=63
64+
BooleanLiteral=64
65+
NumberUnit=65
66+
NumberLiteral=66
67+
NumberPart=67
68+
ExponentPart=68
69+
PrimitiveType=69
70+
UnboundedBytes=70
71+
BoundedBytes=71
72+
Bound=72
73+
StringLiteral=73
74+
DateLiteral=74
75+
HexLiteral=75
76+
TxVar=76
77+
UnsafeCast=77
78+
NullaryOp=78
79+
Identifier=79
80+
WHITESPACE=80
81+
COMMENT=81
82+
LINE_COMMENT=82
7983
'pragma'=1
8084
';'=2
8185
'cashscript'=3
@@ -94,44 +98,48 @@ LINE_COMMENT=78
9498
'('=16
9599
','=17
96100
')'=18
97-
'require'=19
98-
'console.log'=20
99-
'if'=21
100-
'else'=22
101-
'do'=23
102-
'while'=24
103-
'for'=25
104-
'new'=26
105-
'['=27
106-
']'=28
107-
'tx.outputs'=29
108-
'.value'=30
109-
'.lockingBytecode'=31
110-
'.tokenCategory'=32
111-
'.nftCommitment'=33
112-
'.tokenAmount'=34
113-
'tx.inputs'=35
114-
'.outpointTransactionHash'=36
115-
'.outpointIndex'=37
116-
'.unlockingBytecode'=38
117-
'.sequenceNumber'=39
118-
'.reverse()'=40
119-
'.length'=41
120-
'.split'=42
121-
'.slice'=43
122-
'!'=44
123-
'-'=45
124-
'*'=46
125-
'/'=47
126-
'%'=48
127-
'+'=49
128-
'>>'=50
129-
'<<'=51
130-
'=='=52
131-
'!='=53
132-
'&'=54
133-
'|'=55
134-
'&&'=56
135-
'||'=57
136-
'constant'=58
137-
'bytes'=66
101+
'+='=19
102+
'-='=20
103+
'++'=21
104+
'--'=22
105+
'require'=23
106+
'console.log'=24
107+
'if'=25
108+
'else'=26
109+
'do'=27
110+
'while'=28
111+
'for'=29
112+
'new'=30
113+
'['=31
114+
']'=32
115+
'tx.outputs'=33
116+
'.value'=34
117+
'.lockingBytecode'=35
118+
'.tokenCategory'=36
119+
'.nftCommitment'=37
120+
'.tokenAmount'=38
121+
'tx.inputs'=39
122+
'.outpointTransactionHash'=40
123+
'.outpointIndex'=41
124+
'.unlockingBytecode'=42
125+
'.sequenceNumber'=43
126+
'.reverse()'=44
127+
'.length'=45
128+
'.split'=46
129+
'.slice'=47
130+
'!'=48
131+
'-'=49
132+
'*'=50
133+
'/'=51
134+
'%'=52
135+
'+'=53
136+
'>>'=54
137+
'<<'=55
138+
'=='=56
139+
'!='=57
140+
'&'=58
141+
'|'=59
142+
'&&'=60
143+
'||'=61
144+
'constant'=62
145+
'bytes'=70

packages/cashc/src/grammar/CashScriptLexer.interp

Lines changed: 13 additions & 1 deletion
Large diffs are not rendered by default.

packages/cashc/src/grammar/CashScriptLexer.tokens

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,30 @@ T__54=55
5656
T__55=56
5757
T__56=57
5858
T__57=58
59-
VersionLiteral=59
60-
BooleanLiteral=60
61-
NumberUnit=61
62-
NumberLiteral=62
63-
NumberPart=63
64-
ExponentPart=64
65-
PrimitiveType=65
66-
UnboundedBytes=66
67-
BoundedBytes=67
68-
Bound=68
69-
StringLiteral=69
70-
DateLiteral=70
71-
HexLiteral=71
72-
TxVar=72
73-
UnsafeCast=73
74-
NullaryOp=74
75-
Identifier=75
76-
WHITESPACE=76
77-
COMMENT=77
78-
LINE_COMMENT=78
59+
T__58=59
60+
T__59=60
61+
T__60=61
62+
T__61=62
63+
VersionLiteral=63
64+
BooleanLiteral=64
65+
NumberUnit=65
66+
NumberLiteral=66
67+
NumberPart=67
68+
ExponentPart=68
69+
PrimitiveType=69
70+
UnboundedBytes=70
71+
BoundedBytes=71
72+
Bound=72
73+
StringLiteral=73
74+
DateLiteral=74
75+
HexLiteral=75
76+
TxVar=76
77+
UnsafeCast=77
78+
NullaryOp=78
79+
Identifier=79
80+
WHITESPACE=80
81+
COMMENT=81
82+
LINE_COMMENT=82
7983
'pragma'=1
8084
';'=2
8185
'cashscript'=3
@@ -94,44 +98,48 @@ LINE_COMMENT=78
9498
'('=16
9599
','=17
96100
')'=18
97-
'require'=19
98-
'console.log'=20
99-
'if'=21
100-
'else'=22
101-
'do'=23
102-
'while'=24
103-
'for'=25
104-
'new'=26
105-
'['=27
106-
']'=28
107-
'tx.outputs'=29
108-
'.value'=30
109-
'.lockingBytecode'=31
110-
'.tokenCategory'=32
111-
'.nftCommitment'=33
112-
'.tokenAmount'=34
113-
'tx.inputs'=35
114-
'.outpointTransactionHash'=36
115-
'.outpointIndex'=37
116-
'.unlockingBytecode'=38
117-
'.sequenceNumber'=39
118-
'.reverse()'=40
119-
'.length'=41
120-
'.split'=42
121-
'.slice'=43
122-
'!'=44
123-
'-'=45
124-
'*'=46
125-
'/'=47
126-
'%'=48
127-
'+'=49
128-
'>>'=50
129-
'<<'=51
130-
'=='=52
131-
'!='=53
132-
'&'=54
133-
'|'=55
134-
'&&'=56
135-
'||'=57
136-
'constant'=58
137-
'bytes'=66
101+
'+='=19
102+
'-='=20
103+
'++'=21
104+
'--'=22
105+
'require'=23
106+
'console.log'=24
107+
'if'=25
108+
'else'=26
109+
'do'=27
110+
'while'=28
111+
'for'=29
112+
'new'=30
113+
'['=31
114+
']'=32
115+
'tx.outputs'=33
116+
'.value'=34
117+
'.lockingBytecode'=35
118+
'.tokenCategory'=36
119+
'.nftCommitment'=37
120+
'.tokenAmount'=38
121+
'tx.inputs'=39
122+
'.outpointTransactionHash'=40
123+
'.outpointIndex'=41
124+
'.unlockingBytecode'=42
125+
'.sequenceNumber'=43
126+
'.reverse()'=44
127+
'.length'=45
128+
'.split'=46
129+
'.slice'=47
130+
'!'=48
131+
'-'=49
132+
'*'=50
133+
'/'=51
134+
'%'=52
135+
'+'=53
136+
'>>'=54
137+
'<<'=55
138+
'=='=56
139+
'!='=57
140+
'&'=58
141+
'|'=59
142+
'&&'=60
143+
'||'=61
144+
'constant'=62
145+
'bytes'=70

0 commit comments

Comments
 (0)