Module Mlang.Parse_utils

Helpers for parsing

Frontend variable names

type parse_val =
| ParseVar of Mast.variable
| ParseInt of int

A parsed variable can be a regular variable or an integer literal

val mk_position : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> Pos.t
val parse_variable : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> Mast.variable

Checks whether the variable contains parameters

val parse_variable_name : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> string

Checks whether the string is entirely capitalized

val parse_parameter : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> char
val parse_string : string -> string

Removes the quotes

val parse_variable_or_int : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> parse_val
val parse_table_size : string -> Mast.table_size
val parse_func_name : 'a -> string -> string

Literal parsing

val parse_int : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> int

Checks whether is it actually an integer

val parse_literal : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> Com.literal
val parse_atom : (Stdlib.Lexing.position * Stdlib.Lexing.position) -> string -> Mast.variable Com.atom
val parse_function_name : string Pos.marked -> Com.func Pos.marked
val parse_if_then_etc : (Mast.expression Pos.marked option * Mast.instruction Pos.marked list * Pos.t) list -> Mast.instruction
type target_header =
| Target_apps of Mast.application Pos.marked list
| Target_input_arg of string Pos.marked list
| Target_tmp_vars of (string Pos.marked * Mast.table_size Pos.marked option) list
| Function_result of string Pos.marked
val parse_target_or_function_header : string Pos.marked -> bool -> target_header Pos.marked list -> Mast.application Pos.marked StrMap.t * string Pos.marked list * (string Pos.marked * Mast.table_size Pos.marked option) StrMap.t * string Pos.marked option