Module Surface.Lexer_common

Auxiliary functions used by all lexers.

type lexing_context =
| Law
| Code
| Directive
| Directive_args
val context : lexing_context Stdlib.ref

Reference, used by the lexer as the mutable state to distinguish whether it is lexing code or law.

val code_buffer : Stdlib.Buffer.t

Buffer that accumulates the string representation of the body of code being lexed. This string representation is used in the literate programming backends to faithfully capture the spacing pattern of the original program

val update_acc : Sedlexing.lexbuf -> unit

Updates code_buffer with the current lexeme

val raise_lexer_error : Catala_utils.Pos.t -> string -> 'a

Error-generating helper

val token_list_language_agnostic : (string * Tokens.token) list

Associative list matching each punctuation string part of the Catala syntax with its Surface.Parser token. Same for all the input languages (English, French, etc.)

val calc_precedence : string -> int

Calculates the precedence according a matched regex of the form : '#+'

val get_law_heading : Sedlexing.lexbuf -> Tokens.token

Gets the LAW_HEADING token from the current lexbuf

module type LocalisedLexer = sig ... end