Skip to content

Add --parse-ast#2541

Merged
plajjan merged 1 commit into
mainfrom
parse-ast
Nov 30, 2025
Merged

Add --parse-ast#2541
plajjan merged 1 commit into
mainfrom
parse-ast

Conversation

@plajjan

@plajjan plajjan commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

This shows a rather raw output of the AST. For example:

$ actonc examples/helloworld.act --parse --parse-ast Building file examples/helloworld.act using temporary scratch directory

== parse: helloworld ================================

actor main (env):
    print("Hello, world!")
    env.exit(0)
=====================================================

== parse-ast: helloworld ================================
Module
  { modname = ModName [ Name NoLoc "helloworld" ]
  , imps = []
  , mbody =
      [ Decl
          { sloc = Loc 0 60
          , decls =
              [ Actor
                  { dloc = Loc 0 60
                  , dname = Name (Loc 6 10) "main"
                  , qbinds = []
                  , pos = PosNIL
                  , kwd = KwdPar (Name (Loc 11 14) "env") Nothing Nothing KwdNIL
                  , dbody =
                      [ Expr
                          { sloc = Loc 21 43
                          , expr =
                              Call
                                { eloc = Loc 21 43
                                , fun = Var { eloc = Loc 21 26 , var = NoQ { noq = Name (Loc 21 26) "print" } }
                                , pargs = PosArg Strings { eloc = Loc 27 42 , sval = [ "Hello, world!" ] } PosNil
                                , kargs = KwdNil
                                }
                          }
                      , Expr
                          { sloc = Loc 48 59
                          , expr =
                              Call
                                { eloc = Loc 48 59
                                , fun =
                                    Dot
                                      { eloc = Loc 48 56
                                      , exp1 = Var { eloc = Loc 48 51 , var = NoQ { noq = Name (Loc 48 51) "env" } }
                                      , attr = Name (Loc 52 56) "exit"
                                      }
                                , pargs = PosArg Int { eloc = Loc 57 58 , ival = 0 , lexeme = "0" } PosNil
                                , kargs = KwdNil
                                }
                          }
                      ]
                  , ddoc = Nothing
                  }
              ]
          }
      ]
  }
=========================================================

Great for debugging the parser!

This shows a rather raw output of the AST. For example:

$ actonc examples/helloworld.act --parse --parse-ast
Building file examples/helloworld.act using temporary scratch directory

== parse: helloworld ================================

actor main (env):
    print("Hello, world!")
    env.exit(0)
=====================================================

== parse-ast: helloworld ================================
Module
  { modname = ModName [ Name NoLoc "helloworld" ]
  , imps = []
  , mbody =
      [ Decl
          { sloc = Loc 0 60
          , decls =
              [ Actor
                  { dloc = Loc 0 60
                  , dname = Name (Loc 6 10) "main"
                  , qbinds = []
                  , pos = PosNIL
                  , kwd = KwdPar (Name (Loc 11 14) "env") Nothing Nothing KwdNIL
                  , dbody =
                      [ Expr
                          { sloc = Loc 21 43
                          , expr =
                              Call
                                { eloc = Loc 21 43
                                , fun = Var { eloc = Loc 21 26 , var = NoQ { noq = Name (Loc 21 26) "print" } }
                                , pargs = PosArg Strings { eloc = Loc 27 42 , sval = [ "Hello, world!" ] } PosNil
                                , kargs = KwdNil
                                }
                          }
                      , Expr
                          { sloc = Loc 48 59
                          , expr =
                              Call
                                { eloc = Loc 48 59
                                , fun =
                                    Dot
                                      { eloc = Loc 48 56
                                      , exp1 = Var { eloc = Loc 48 51 , var = NoQ { noq = Name (Loc 48 51) "env" } }
                                      , attr = Name (Loc 52 56) "exit"
                                      }
                                , pargs = PosArg Int { eloc = Loc 57 58 , ival = 0 , lexeme = "0" } PosNil
                                , kargs = KwdNil
                                }
                          }
                      ]
                  , ddoc = Nothing
                  }
              ]
          }
      ]
  }
=========================================================

Great for debugging the parser!
@plajjan plajjan added this to Acton Nov 30, 2025
@plajjan plajjan self-assigned this Nov 30, 2025
@plajjan plajjan enabled auto-merge November 30, 2025 16:39
@plajjan plajjan merged commit 70a8af4 into main Nov 30, 2025
34 of 36 checks passed
@plajjan plajjan deleted the parse-ast branch November 30, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant