2727package org .sireum .lang .ast
2828
2929import org .sireum ._
30+ import org .sireum .S32 ._
3031import org .sireum .lang .{ast => AST }
3132import org .sireum .message .Position
3233import org .sireum .parser .ParseTree
@@ -61,7 +62,7 @@ object SlangLl2AstBuilder {
6162
6263 @ strictpure def mkName (ids : ISZ [AST .Id ], tree : ParseTree ): AST .Name = AST .Name (ids, attr(tree))
6364
64- def children (tree : ParseTree ): ISZ [ ParseTree ] = {
65+ def children (tree : ParseTree ): IS [ S32 , ParseTree ] = {
6566 return tree.asInstanceOf [ParseTree .Node ].children
6667 }
6768
@@ -181,7 +182,7 @@ object SlangLl2AstBuilder {
181182 // ─── Annotations / mods ────────────────────────────────────────────
182183
183184 @ datatype class ModInfo (val names : ISZ [String ],
184- val args : ISZ [(String , ISZ [ ParseTree ])])
185+ val args : ISZ [(String , IS [ S32 , ParseTree ])])
185186
186187 def buildMods (mods : ISZ [ParseTree .Node ]): ISZ [ModInfo ] = {
187188 var r = ISZ [ModInfo ]()
@@ -197,7 +198,7 @@ object SlangLl2AstBuilder {
197198 val argsNode = findChild(node, " args" )
198199 argsNode match {
199200 case Some (an) =>
200- var argPairs = ISZ [(String , ISZ [ ParseTree ])]()
201+ var argPairs = ISZ [(String , IS [ S32 , ParseTree ])]()
201202 // For now, just store raw children
202203 argPairs = argPairs :+ ((name, an.children))
203204 return ModInfo (names = ISZ (name), args = argPairs)
@@ -226,15 +227,15 @@ object SlangLl2AstBuilder {
226227
227228 // ─── Annotations (LL2 annotation block) ────────────────────────────
228229
229- def buildAnnot (nodeOpt : Option [ParseTree .Node ], reporter : message.Reporter ): ISZ [(String , ISZ [ ParseTree ])] = {
230+ def buildAnnot (nodeOpt : Option [ParseTree .Node ], reporter : message.Reporter ): ISZ [(String , IS [ S32 , ParseTree ])] = {
230231 nodeOpt match {
231232 case Some (node) =>
232233 // annot: AT LSQUARE annotArg* RSQUARE
233234 val annotArgs = findChildren(node, " annotArg" )
234- var r = ISZ [(String , ISZ [ ParseTree ])]()
235+ var r = ISZ [(String , IS [ S32 , ParseTree ])]()
235236 for (aa <- annotArgs) {
236237 val key = firstLeaf(aa).text
237- var values = ISZ [ ParseTree ]()
238+ var values = IS [ S32 , ParseTree ]()
238239 for (c <- aa.children) {
239240 c match {
240241 case c : ParseTree .Leaf if c.ruleName == " ID" || c.ruleName == " STRING" =>
@@ -1473,9 +1474,9 @@ object SlangLl2AstBuilder {
14731474 def buildBinaryFromTree (tree : ParseTree , contextNode : ParseTree , reporter : message.Reporter ): AST .Exp = {
14741475 tree match {
14751476 case n : ParseTree .Node if n.ruleName == " Binary" =>
1476- val left = buildBinaryFromTree(n.children( 0 ), contextNode, reporter)
1477- val opLeaf = n.children( 1 ).asInstanceOf [ParseTree .Leaf ]
1478- val right = buildBinaryFromTree(n.children( 2 ), contextNode, reporter)
1477+ val left = buildBinaryFromTree(n.children.atS32( s32 " 0 " ), contextNode, reporter)
1478+ val opLeaf = n.children.atS32( s32 " 1 " ).asInstanceOf [ParseTree .Leaf ]
1479+ val right = buildBinaryFromTree(n.children.atS32( s32 " 2 " ), contextNode, reporter)
14791480 return AST .Exp .Binary (
14801481 left = left,
14811482 op = opLeaf.text,
@@ -1751,7 +1752,7 @@ object SlangLl2AstBuilder {
17511752 if (expNodes.nonEmpty) {
17521753 val innerExp = buildExp(expNodes(0 ), reporter)
17531754 // Check for num argument
1754- val numOpt : Option [AST .Exp .LitZ ] = if (aa.children.size > 1 ) {
1755+ val numOpt : Option [AST .Exp .LitZ ] = if (aa.children.sizeS32 > s32 " 1 " ) {
17551756 var found : Option [AST .Exp .LitZ ] = None ()
17561757 for (c <- aa.children) {
17571758 c match {
0 commit comments