Skip to content

Commit a143707

Browse files
committed
Update grammar for .slice() feature
1 parent 1e3cccd commit a143707

File tree

8 files changed

+653
-576
lines changed

8 files changed

+653
-576
lines changed

packages/cashc/src/grammar/CashScript.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ expression
114114
| scope='tx.inputs' '[' expression ']' op=('.value' | '.lockingBytecode' | '.outpointTransactionHash' | '.outpointIndex' | '.unlockingBytecode' | '.sequenceNumber' | '.tokenCategory' | '.nftCommitment' | '.tokenAmount') # UnaryIntrospectionOp
115115
| expression op=('.reverse()' | '.length') # UnaryOp
116116
| left=expression op='.split' '(' right=expression ')' # BinaryOp
117+
| element=expression '.slice' '(' start=expression ',' end=expression ')' # Slice
117118
| op=('!' | '-') expression # UnaryOp
118119
| left=expression op=('*' | '/' | '%') right=expression # BinaryOp
119120
| left=expression op=('+' | '-') right=expression # BinaryOp

packages/cashc/src/grammar/CashScript.interp

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

packages/cashc/src/grammar/CashScript.tokens

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,24 @@ T__53=54
5555
T__54=55
5656
T__55=56
5757
T__56=57
58-
VersionLiteral=58
59-
BooleanLiteral=59
60-
NumberUnit=60
61-
NumberLiteral=61
62-
NumberPart=62
63-
ExponentPart=63
64-
Bytes=64
65-
Bound=65
66-
StringLiteral=66
67-
DateLiteral=67
68-
HexLiteral=68
69-
TxVar=69
70-
NullaryOp=70
71-
Identifier=71
72-
WHITESPACE=72
73-
COMMENT=73
74-
LINE_COMMENT=74
58+
T__57=58
59+
VersionLiteral=59
60+
BooleanLiteral=60
61+
NumberUnit=61
62+
NumberLiteral=62
63+
NumberPart=63
64+
ExponentPart=64
65+
Bytes=65
66+
Bound=66
67+
StringLiteral=67
68+
DateLiteral=68
69+
HexLiteral=69
70+
TxVar=70
71+
NullaryOp=71
72+
Identifier=72
73+
WHITESPACE=73
74+
COMMENT=74
75+
LINE_COMMENT=75
7576
'pragma'=1
7677
';'=2
7778
'cashscript'=3
@@ -110,22 +111,23 @@ LINE_COMMENT=74
110111
'.reverse()'=36
111112
'.length'=37
112113
'.split'=38
113-
'!'=39
114-
'-'=40
115-
'*'=41
116-
'/'=42
117-
'%'=43
118-
'+'=44
119-
'=='=45
120-
'!='=46
121-
'&'=47
122-
'|'=48
123-
'&&'=49
124-
'||'=50
125-
'constant'=51
126-
'int'=52
127-
'bool'=53
128-
'string'=54
129-
'pubkey'=55
130-
'sig'=56
131-
'datasig'=57
114+
'.slice'=39
115+
'!'=40
116+
'-'=41
117+
'*'=42
118+
'/'=43
119+
'%'=44
120+
'+'=45
121+
'=='=46
122+
'!='=47
123+
'&'=48
124+
'|'=49
125+
'&&'=50
126+
'||'=51
127+
'constant'=52
128+
'int'=53
129+
'bool'=54
130+
'string'=55
131+
'pubkey'=56
132+
'sig'=57
133+
'datasig'=58

packages/cashc/src/grammar/CashScriptLexer.interp

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

packages/cashc/src/grammar/CashScriptLexer.tokens

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,24 @@ T__53=54
5555
T__54=55
5656
T__55=56
5757
T__56=57
58-
VersionLiteral=58
59-
BooleanLiteral=59
60-
NumberUnit=60
61-
NumberLiteral=61
62-
NumberPart=62
63-
ExponentPart=63
64-
Bytes=64
65-
Bound=65
66-
StringLiteral=66
67-
DateLiteral=67
68-
HexLiteral=68
69-
TxVar=69
70-
NullaryOp=70
71-
Identifier=71
72-
WHITESPACE=72
73-
COMMENT=73
74-
LINE_COMMENT=74
58+
T__57=58
59+
VersionLiteral=59
60+
BooleanLiteral=60
61+
NumberUnit=61
62+
NumberLiteral=62
63+
NumberPart=63
64+
ExponentPart=64
65+
Bytes=65
66+
Bound=66
67+
StringLiteral=67
68+
DateLiteral=68
69+
HexLiteral=69
70+
TxVar=70
71+
NullaryOp=71
72+
Identifier=72
73+
WHITESPACE=73
74+
COMMENT=74
75+
LINE_COMMENT=75
7576
'pragma'=1
7677
';'=2
7778
'cashscript'=3
@@ -110,22 +111,23 @@ LINE_COMMENT=74
110111
'.reverse()'=36
111112
'.length'=37
112113
'.split'=38
113-
'!'=39
114-
'-'=40
115-
'*'=41
116-
'/'=42
117-
'%'=43
118-
'+'=44
119-
'=='=45
120-
'!='=46
121-
'&'=47
122-
'|'=48
123-
'&&'=49
124-
'||'=50
125-
'constant'=51
126-
'int'=52
127-
'bool'=53
128-
'string'=54
129-
'pubkey'=55
130-
'sig'=56
131-
'datasig'=57
114+
'.slice'=39
115+
'!'=40
116+
'-'=41
117+
'*'=42
118+
'/'=43
119+
'%'=44
120+
'+'=45
121+
'=='=46
122+
'!='=47
123+
'&'=48
124+
'|'=49
125+
'&&'=50
126+
'||'=51
127+
'constant'=52
128+
'int'=53
129+
'bool'=54
130+
'string'=55
131+
'pubkey'=56
132+
'sig'=57
133+
'datasig'=58

0 commit comments

Comments
 (0)