The Hummanta banner

Hummanta is a collection of modular, reusable compiler technologies and a comprehensive framework for rapidly building smart contracts. Designed with flexibility and scalability in mind, Hummanta empowers developers to create efficient, reliable, and secure smart contracts with ease.

The documentation is divided into two main sections:

  • Developers Section: For developers looking to integrate with Hummanta or extend its features by leveraging our modular tools, APIs, and smart contract framework.

  • Users Section: For users who want to learn how to utilize the Hummanta toolchain and framework to streamline their smart contract development workflows.

To join our community and get involved in the development of the Hummanta ecosystem, check out our GitHub repository.

Let’s Get Started!

Solidity Language Grammar v0.8.28

Solidity is a statically typed, contract-oriented, high-level language for implementing smart contracts on the Ethereum platform.

Parser Grammar

source-unit

On top level, Solidity allows pragmas, import directives, and definitions of contracts, interfaces, libraries, structs, enums and constants.

Rule source-unit

import-directive

Import directives import identifiers from different files.

Rule import-directive

path

Path of a file to be imported.

Rule path

symbol-aliases

List of aliases for symbols to be imported.

Rule symbol-aliases

contract-definition

Top-level definition of a contract.

Rule contract-definition

interface-definition

Top-level definition of an interface.

Rule interface-definition

library-definition

Top-level definition of a library.

Rule library-definition

inheritance-specifier

Inheritance specifier for contracts and interfaces. Can optionally supply base constructor arguments.

Rule inheritance-specifier

contract-body-element

Declarations that can be used in contracts, interfaces and libraries.

Rule contract-body-element

Note that interfaces and libraries may not contain constructors, interfaces may not contain state variables and libraries may not contain fallback, receive functions nor non-constant state variables.

call-argument-list

Arguments when calling a function or a similar callable object. The arguments are either given as comma separated list or as map of named arguments.

Rule call-argument-list

identifier-path

Qualified name.

Rule identifier-path

modifier-invocation

Call to a modifier. If the modifier takes no arguments, the argument list can be skipped entirely (including opening and closing parentheses).

Rule modifier-invocation

visibility

Visibility for functions and function types.

Rule visibility

parameter-list

A list of parameters, such as function arguments or return values.

Rule parameter-list

constructor-definition

Definition of a constructor. Must always supply an implementation. Note that specifying internal or public visibility is deprecated.

Rule constructor-definition

state-mutability

State mutability for function types. The default mutability ‘non-payable’ is assumed if no mutability is specified.

Rule state-mutability

override-specifier

An override specifier used for functions, modifiers or state variables. In cases where there are ambiguous declarations in several base contracts being overridden, a complete list of base contracts has to be given.

Rule override-specifier

function-definition

The definition of contract, library, interface or free functions. Depending on the context in which the function is defined, further restrictions may apply, e.g. functions in interfaces have to be unimplemented, i.e. may not contain a body block.

Rule function-definition

modifier-definition

The definition of a modifier. Note that within the body block of a modifier, the underscore cannot be used as identifier, but is used as placeholder statement for the body of a function to which the modifier is applied.

Rule modifier-definition

fallback-function-definition

Definition of the special fallback function.

Rule fallback-function-definition

receive-function-definition

Definition of the special receive function.

Rule receive-function-definition

struct-definition

Definition of a struct. Can occur at top-level within a source unit or within a contract, library or interface.

Rule struct-definition

struct-member

The declaration of a named struct member.

Rule struct-member

enum-definition

Definition of an enum. Can occur at top-level within a source unit or within a contract, library or interface.

Rule enum-definition

user-defined-value-type-definition

Definition of a user defined value type. Can occur at top-level within a source unit or within a contract, library or interface.

Rule user-defined-value-type-definition

state-variable-declaration

The declaration of a state variable.

Rule state-variable-declaration

constant-variable-declaration

The declaration of a constant variable.

Rule constant-variable-declaration

event-parameter

Parameter of an event.

Rule event-parameter

event-definition

Definition of an event. Can occur in contracts, libraries or interfaces.

Rule event-definition

error-parameter

Parameter of an error.

Rule error-parameter

error-definition

Definition of an error.

Rule error-definition

user-definable-operator

Operators that users are allowed to implement for some types with using for.

Rule user-definable-operator

using-directive

Using directive to attach library functions and free functions to types. Can occur within contracts and libraries and at the file level.

Rule using-directive

using-aliases

Rule using-aliases

type-name

A type name can be an elementary type, a function type, a mapping type, a user-defined type (e.g. a contract or struct) or an array type.

Rule type-name

elementary-type-name

Rule elementary-type-name

function-type-name

Rule function-type-name

variable-declaration

The declaration of a single variable.

Rule variable-declaration

data-location

Rule data-location

expression

Complex expression. Can be an index access, an index range access, a member access, a function call (with optional function call options), a type conversion, an unary or binary expression, a comparison or assignment, a ternary expression, a new-expression (i.e. a contract creation or the allocation of a dynamic memory array), a tuple, an inline array or a primary expression (i.e. an identifier, literal or type name).

Rule expression

tuple-expression

Rule tuple-expression

inline-array-expression

An inline array expression denotes a statically sized array of the common type of the contained expressions.

Rule inline-array-expression

identifier

Besides regular non-keyword Identifiers, some keywords like ‘from’ and ‘error’ can also be used as identifiers.

Rule identifier

literal

Rule literal

literal-with-sub-denomination

Rule literal-with-sub-denomination

boolean-literal

Rule boolean-literal

string-literal

A full string literal consists of either one or several consecutive quoted strings.

Rule string-literal

hex-string-literal

A full hex string literal that consists of either one or several consecutive hex strings.

Rule hex-string-literal

unicode-string-literal

A full unicode string literal that consists of either one or several consecutive unicode strings.

Rule unicode-string-literal

number-literal

Number literals can be decimal or hexadecimal numbers with an optional unit.

Rule number-literal

block

A curly-braced block of statements. Opens its own scope.

Rule block

unchecked-block

Rule unchecked-block

statement

Rule statement

if-statement

If statement with optional else part.

Rule if-statement

for-statement

For statement with optional init, condition and post-loop part.

Rule for-statement

while-statement

Rule while-statement

do-while-statement

Rule do-while-statement

continue-statement

A continue statement. Only allowed inside for, while or do-while loops.

Rule continue-statement

break-statement

A break statement. Only allowed inside for, while or do-while loops.

Rule break-statement

try-statement

A try statement. The contained expression needs to be an external function call or a contract creation.

Rule try-statement

catch-clause

The catch clause of a try statement.

Rule catch-clause

return-statement

Rule return-statement

emit-statement

An emit statement. The contained expression needs to refer to an event.

Rule emit-statement

revert-statement

A revert statement. The contained expression needs to refer to an error.

Rule revert-statement

assembly-statement

An inline assembly block. The contents of an inline assembly block use a separate scanner/lexer, i.e. the set of keywords and allowed identifiers is different inside an inline assembly block.

Rule assembly-statement

assembly-flags

Assembly flags. Comma-separated list of double-quoted strings as flags.

Rule assembly-flags

variable-declaration-tuple

A tuple of variable names to be used in variable declarations. May contain empty fields.

Rule variable-declaration-tuple

variable-declaration-statement

A variable declaration statement. A single variable may be declared without initial value, whereas a tuple of variables can only be declared with initial value.

Rule variable-declaration-statement

expression-statement

Rule expression-statement

mapping-type

Rule mapping-type

mapping-key-type

Only elementary types or user defined types are viable as mapping keys.

Rule mapping-key-type

yul-statement

A Yul statement within an inline assembly block. continue and break statements are only valid within for loops. leave statements are only valid within function bodies.

Rule yul-statement

yul-block

Rule yul-block

yul-variable-declaration

The declaration of one or more Yul variables with optional initial value. If multiple variables are declared, only a function call is a valid initial value.

Rule yul-variable-declaration

yul-assignment

Any expression can be assigned to a single Yul variable, whereas multi-assignments require a function call on the right-hand side.

Rule yul-assignment

yul-if-statement

Rule yul-if-statement

yul-for-statement

Rule yul-for-statement

yul-switch-statement

A Yul switch statement can consist of only a default-case (deprecated) or one or more non-default cases optionally followed by a default-case.

Rule yul-switch-statement

yul-function-definition

Rule yul-function-definition

yul-path

While only identifiers without dots can be declared within inline assembly, paths containing dots can refer to declarations outside the inline assembly block.

Rule yul-path

yul-function-call

A call to a function with return values can only occur as right-hand side of an assignment or a variable declaration.

Rule yul-function-call

yul-boolean

Rule yul-boolean

yul-literal

Rule yul-literal

yul-expression

Rule yul-expression

Lexer Grammar

fixed-bytes

Bytes types of fixed length.

Rule fixed-bytes

sub-denomination

Unit denomination for numbers.

Rule sub-denomination

signed-integer-type

Sized signed integer types. int is an alias of int256.

Rule signed-integer-type

unsigned-integer-type

Sized unsigned integer types. uint is an alias of uint256.

Rule unsigned-integer-type

non-empty-string-literal

A non-empty quoted string literal restricted to printable characters.

Rule non-empty-string-literal

empty-string-literal

An empty string literal

Rule empty-string-literal

single-quoted-printable

Any printable character except single quote or back slash.

Rule single-quoted-printable

double-quoted-printable

Any printable character except double quote or back slash.

Rule double-quoted-printable

escape-sequence

Escape sequence. Apart from common single character escape sequences, line breaks can be escaped as well as four hex digit unicode escapes \uXXXX and two digit hex escape sequences \xXX are allowed.

Rule escape-sequence

unicode-string-literal

A single quoted string literal allowing arbitrary unicode characters.

Rule unicode-string-literal

hex-string

Hex strings need to consist of an even number of hex digits that may be grouped using underscores.

Rule hex-string

hex-number

Hex numbers consist of a prefix and an arbitrary number of hex digits that may be delimited by underscores.

Rule hex-number

decimal-number

A decimal number literal consists of decimal digits that may be delimited by underscores and an optional positive or negative exponent. If the digits contain a decimal point, the literal has fixed point type.

Rule decimal-number

identifier

An identifier in solidity has to start with a letter, a dollar-sign or an underscore and may additionally contain numbers after the first symbol.

Rule identifier

yul-evm-builtin

Builtin functions in the EVM Yul dialect.

Rule yul-evm-builtin

yul-identifier

Yul identifiers consist of letters, dollar signs, underscores and numbers, but may not start with a number. In inline assembly there cannot be dots in user-defined identifiers. Instead see yulPath for expressions consisting of identifiers with dots.

Rule yul-identifier

yul-hex-number

Hex literals in Yul consist of a prefix and one or more hexadecimal digits.

Rule yul-hex-number

yul-decimal-number

Decimal literals in Yul may be zero or any sequence of decimal digits without leading zeroes.

Rule yul-decimal-number

yul-string-literal

String literals in Yul consist of one or more double-quoted or single-quoted strings that may contain escape sequences and printable characters except unescaped line breaks or unescaped double-quotes or single-quotes, respectively.

Rule yul-string-literal

pragma-token

Pragma token. Can contain any kind of symbol except a semicolon. Note that currently the solidity parser only allows a subset of this.

References

Sway Language Grammar v0.66.5

Sway is a domain-specific programming language for implementing smart contracts on blockchain platforms, most notably for the Fuel Virtual Machine (Fuel VM).

Parser Grammar

module

On top level, Sway allows module kind and definitions of submodule, storage, contracts, traits, libraries, structs, enums and constants. (AST: Module)

Rule module

submodule

The mod keyword registers a submodule, making its items (such as functions and structs) accessible from the parent library. If used at the top level it will refer to a file in the src folder and in other cases in a folder named after the library in which it is defined. (AST: Submodule)

Rule submodule

use

Provides several utility types and methods we can use in our contract. (AST: ItemUse)

Rule use

use-tree

Path of a types or methods to be imported. (AST: UseTree)

Rule use-tree

struct

Definition of a struct. Can occur at top-level within a source unit or within a contract, library or interface. (AST: ItemStruct)

Rule struct

type-field

Definition of TypeField. (AST: TypeField)

Rule type-field

type-name

Definition of TypeName. (AST: Ty)

Rule type-name

enum

Definition of an enum. Can occur at top-level within a source unit or within a contract, library or interface. (AST: ItemEnum)

Rule enum

traits

Definition of traits. Can be used for abi and trait.(AST: Traits)

Rule traits

trait-item

Define an item of an trait. (AST: ItemTraitItem).

Rule trait-item

abi

ABI stands for Application Binary Interface.(AST: ItemAbi, doc: The ABI Declaration).

Rule abi

const

Define constant items. (AST: ItemConst)

Rule const

configurable

Configurable constants are special constants that behave like regular constants in the sense that they cannot change during program execution, but they can be configured after the Sway program has been built. (AST: ItemConfigurable, doc: Configurable Constants)

Rule configurable

type-alias

Definition of type-alias. To declare a type alias to give an existing type another name. (AST: ItemTypeAlias)

Rule type-alias

fn

Functions in Sway are declared with the fn keyword. (AST: ItemFn, doc: Functions)

Rule fn

fn-signature

fn-signature declares signature for function. (AST: FnSignature, doc: Functions)

Rule fn-signature

generic-params

Generic types are a way to refer to types in general, meaning without specifying a single type. (AST: GenericParams, doc: Generic Types).

Rule generic-params

where-clause

Where clause can be used to specify the required traits for the generic argument. (AST: WhereClause, doc: Trait Constraints).

Rule where-clause

code-block-contents

A CodeBlockContents represents the body of a code block, which contains a sequence of statements and expressions. (AST: CodeBlockContents, doc: Functions). Rule code-block-contents

fn-arg

A fn-arg represents function arguments. (AST: FnArg, doc: Functions). Rule fn-arg

pattern

A pattern is a construct used to match and destructure data. (AST: Pattern, doc: match expressions). Rule pattern

trait

A trait opts a type into a certain type of behavior or functionality that can be shared among types. This allows for easy reuse of code and generic programming. (AST: ItemTrait, doc: Declaring a Trait). Rule trait

impl

Implement inherent or trait functionality. (AST: ItemImpl, doc: Implementing a Trait)

Rule impl

storage

In smart contract development, persistent storage (storage) is used to store values that persist after the contract exits, unlike regular memory values that disappear. (AST: ItemStorage, doc: Declaring storage)

Rule storage

storage-entry

Define storage entry. (AST: StorageEntry, doc: Declaring storage)

Rule storage-entry

expr

Define types of expressions. (AST: Expr, doc: If Expressions)

Rule expr