Skip to content

How to obtain an AST from a source file? #461

Open

Description

@IanTrudel

Discussed in #455

Originally posted by IanTrudel May 2, 2024
Would it be possible to obtain the AST (or S-Exp) from a given source file in Unicon?

Activity

  1. Don-Ward commented on Feb 3, 2025

    @Don-Ward
    Collaborator

    There is a way (now) after some work I did late last year. It's not documented and may yet be removed. Look at the procedure Progend in .../uni/unicon/unigram.y for details.

  2. IanTrudel commented on Feb 26, 2025

    @IanTrudel
    ContributorAuthor

    This is a special case, isn't it? Not only it happens after the big inhale but it's hidden behind yacc. That most likely means there is no way to use this in a normal Unicon program. Or is there? It might be difficult to replicate because there is a lot of magic from x1 to classes.

  3. Don-Ward commented on Apr 9, 2025

    @Don-Ward
    Collaborator

    As of 24th March, there is now a -printAST option in the compiler. To get access to the AST from a normal Unicon program you could run the compiler in a child process and capture the standard output.

  4. IanTrudel commented on Apr 9, 2025

    @IanTrudel
    ContributorAuthor

    Thank you! I'm looking forward trying this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions