frostc-1.0.0.0: The Frost Programming Language Compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ast.Parser.Type

Synopsis

Documentation

parseType :: Parser Type Source #

Parse a general type. This function combines multiple specific type parsers. It tries to match typedefs, structs, unions, functions, mutable types, pointers, and base types.

parseTermType :: Parser Type Source #

Parses a terminal type, which can be a base type, custom integer size, mutable type, array, pointer, or custom type. Returns the parsed Type.

baseTypes :: [(String, Type)] Source #

A list of predefined base types along with their associated keywords. These include basic types such as int, float, double, char, bool, and void.

customIntType :: Parser Type Source #

Parses a user-defined integer size. Example: "int128" would result in AT.TInt 128.

baseType :: Parser Type Source #

Parses a base type by matching one of the predefined base type keywords. Example: "int" or "bool".

pointerType :: Parser Type Source #

Parses a pointer type. A pointer type is denoted by a * followed by another type. Example: "*int" results in a pointer to an integer.

mutableType :: Parser Type Source #

Parses a mutable type. A mutable type is prefixed by the keyword "mut" followed by the type. Example: "mut int" indicates a mutable integer type.

arrayType :: Parser Type Source #

Parses an array type. An array type is denoted by square brackets "[]" followed by the type. Example: "[]int" results in an array of integers.

functionType :: Parser Type Source #

Parses a function type. A function type is defined by its parameter types, followed by "->", and the return type also enclosed in parentheses. Example: "int -> float" or "int int -> void". TODO: find a way to do it without the parenthesis and avoid the infinite loop of parseType

customType :: Parser Type Source #

Parses a custom user-defined type by its name. If the type is not found in the environment, an UnknownType error is raised.