Skip to content

Commit 28aa0ad

Browse files
committed
feat: support map literals
Fixes #69
1 parent 3f9aaaa commit 28aa0ad

File tree

6 files changed

+231
-5
lines changed

6 files changed

+231
-5
lines changed

src/main/gen/org/tonstudio/tact/lang/TactParser.java

Lines changed: 174 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/tonstudio/tact/lang/TactTypes.java

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/tonstudio/tact/lang/psi/TactVisitor.java

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/org/tonstudio/tact/lang/grammar/tact.bnf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ MapType ::= 'map' '<' Type ',' Type '>' {
578578
]
579579
}
580580

581+
SetType ::= 'set' '<' Type '>' {pin=1}
582+
581583
VarDefinition ::= identifier {
582584
pin=2
583585
methods=[getTypeInner getName getReference isReadonly]
@@ -588,6 +590,8 @@ DotExpression ::= DotPrimaryExpr RightHandExprs
588590

589591
private DotPrimaryExpr ::=
590592
LiteralValueExpression
593+
| MapLiteral
594+
| SetLiteral
591595
| ReferenceExpression
592596
| InitOfExpr
593597
| CodeOfExpr
@@ -633,6 +637,14 @@ fake BinaryExpr ::= Expression+ {
633637

634638
ParenthesesExpr ::= '(' Expression ')' {pin=3}
635639

640+
MapLiteral ::= MapType '{' MapEntries? '}'
641+
private MapEntries ::= MapEntry (',' MapEntry)* ','?
642+
MapEntry ::= Expression ':' Expression
643+
644+
SetLiteral ::= SetType '{' SetEntries? '}'
645+
private SetEntries ::= SetEntry (',' SetEntry)* ','?
646+
SetEntry ::= Expression
647+
636648
WhileStatement ::= while Expression Block {pin=1}
637649
RepeatStatement ::= repeat Expression Block {pin=1}
638650
UntilStatement ::= do Block until Expression semi {pin=1}

src/main/kotlin/org/tonstudio/tact/lang/psi/impl/TactTypeInferer.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ object TactTypeInferer {
125125
return TactPrimitiveTypeEx.CELL
126126
}
127127

128+
if (expr is TactMapLiteral) {
129+
return expr.mapType.toEx()
130+
}
131+
128132
return null
129133
}
130134

src/main/kotlin/org/tonstudio/tact/lang/stubs/TactElementTypeFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ object TactElementTypeFactory {
1212
put("TUPLE_TYPE", TactTupleTypeImpl::class.java)
1313
put("BOUNCED_TYPE", TactBouncedTypeImpl::class.java)
1414
put("MAP_TYPE", TactMapTypeImpl::class.java)
15+
put("SET_TYPE", TactSetTypeImpl::class.java)
1516
put("STRUCT_TYPE", TactStructTypeImpl::class.java)
1617
put("TYPE", TactTypeImpl::class.java)
1718
put("CONTRACT_TYPE", TactContractTypeImpl::class.java)

0 commit comments

Comments
 (0)