Abstract Syntax Tree for Daml

How can I get the abstract syntax tree of Java Parser for DAML or Java parser code? I want to write a Python Parser for DAML. So I need help.

2 Likes

Hi @Iqra_Mustafa, our parser is implemented in Haskell not in Java. You can find the source code in our GHC fork. That said, the Daml syntax is relatively hard to parse so I expect a python translation to be quite challenging.

1 Like

Great goal, look forwarding to seeing test results here :+1:t2:

1 Like

Thanks.

Thanks. I appreciate for the quick and timely response

I have another query. Is there any dataset of DAML Contracts are available?

I’m not sure this question can be meaningfully answered. Daml contracts are records on a ledger with many privacy rules in play, so they’re generally not available to that many people. I’m not sure what a dataset means in this context.

Like a dataset of contracts in Solidity is available to train the models. Likewise, the DAML dataset is available or not. I need it for some experimental purposes. So I want to know that if enough data is available like (10,000 contracts dataset) then it would be great.

I am not aware of such a dataset; I also do not know much about Solidity so I can’t comment on the analogy.

Maybe others will be able to clarify.

Hey @Iqra_Mustafa if I understand correctly you need a bunch of data from varied contracts in order to develop your parser against. If that is the case what you can do is pull the contracts from a variety of our reference applications and then modify their Daml Scripts to generate the number of contracts you need.

Some actively maintained reference apps that you can use are:

Then you’d need to read the data from whichever ledger/database you’re using for data persistence, or perhaps leverage daml extractor for Postgres (but note extractor is in early stage development).

Do you have a specific ledger/database you’re working with? You might want to take a look at that specific driver to better understand the data layout used so you have an easier time parsing it. Also note that Daml Drivers are never guaranteed to have the same layout between versions and can and do change from time to time. So it may be more advantageous to use the Ledger API or JSON API to get data from your ledger which will come out in a much more consistent format.