Skip to content
Discussions/App Development/Abstract Syntax Tree for DamlForum ↗

Abstract Syntax Tree for Daml

App Development10 posts625 views4 likesLast activity Mar 2021
IQ
Iqra_MustafaOP
Mar 2021

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.

CO
cocreature
Mar 2021

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.

QU
quidagis
Mar 2021
Iqra_Mustafa:

I want to write a Python Parser for DAML

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

IQ
Iqra_Mustafa
Mar 2021

Thanks.

IQ
Iqra_Mustafa
Mar 2021

Thanks. I appreciate for the quick and timely response

IQ
Iqra_Mustafa
Mar 2021

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

GA
Gary_Verhaegen
Mar 2021

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.

IQ
Iqra_Mustafa
Mar 2021

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.

GA
Gary_Verhaegen
Mar 2021

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.

AN
anthony
Mar 2021

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:

github.com

digital-asset/ex-cbdc

Contribute to digital-asset/ex-cbdc development by creating an account on GitHub.

github.com

digital-asset/ex-supply-chain

Reference DAML application demonstrating a supply chain use case.

github.com

digital-asset/ex-healthcare-claims-processing

Reference DAML application demonstrating a healthcare use case.

github.com

digital-asset/ex-bond-issuance

Reference DAML application demonstrating a bond issuance use case.

github.com

digital-asset/ex-know-your-customer

A reference application demonstrating the lifecycle of KYC (Know Your Customer) data subscriptions between data providers, analysts and customers.

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.

← Back to Discussions