Skip to main content

Module parser_sol

Module parser_sol 

Source
Expand description

Solidity-like parser for Rúnar contracts.

Parses a Solidity-style syntax into the same AST as the TypeScript parser. Hand-written tokenizer + recursive descent parser.

§Expected format

// SPDX-License-Identifier: MIT
contract P2PKH is SmartContract {
    immutable Addr pubKeyHash;

    constructor(Addr pubKeyHash) {
        super(pubKeyHash);
        this.pubKeyHash = pubKeyHash;
    }

    function unlock(Sig sig, PubKey pubKey) public {
        require(hash160(pubKey) == this.pubKeyHash);
        require(checkSig(sig, pubKey));
    }
}

Key mappings:

  • require(x) -> assert(x)
  • immutable -> readonly
  • == -> StrictEq (===)
  • != -> StrictNe (!==)
  • Types before names (Solidity convention)

Functions§

parse_solidity
Parse a Solidity-format Rúnar contract source.