JsonRemedy.Layer3.SyntaxHelpers (json_remedy v0.1.3)

View Source

Helper functions for Layer 3 syntax normalization operations.

Contains utilities for character recognition, text processing, and common operations used across the syntax normalization layer.

Summary

Functions

Consume identifier characters from input starting at position.

Consume number characters from input starting at position.

Generic consume while predicate is true.

Consume whitespace from input and return {whitespace_string, new_position}.

Create a repair action record.

Check if a character can be part of an identifier.

Check if a character can start an identifier (letter, underscore, or UTF-8).

Check if a character can start an identifier in binary optimized mode.

Check if a character is part of a number.

Check if a character is a UTF-8 letter (simplified approach).

Check if a token match is at a word boundary.

Check if a string matches at a specific position (UTF-8 safe).

Safely pop from stack.

Functions

consume_identifier(content, start_pos)

@spec consume_identifier(String.t(), non_neg_integer()) ::
  {String.t(), non_neg_integer()}

Consume identifier characters from input starting at position.

consume_number(content, start_pos)

@spec consume_number(String.t(), non_neg_integer()) :: {String.t(), non_neg_integer()}

Consume number characters from input starting at position.

consume_while(content, start_pos, predicate)

@spec consume_while(String.t(), non_neg_integer(), (String.t() -> boolean())) ::
  {String.t(), non_neg_integer()}

Generic consume while predicate is true.

consume_whitespace(input, pos)

@spec consume_whitespace(String.t(), non_neg_integer()) ::
  {String.t(), non_neg_integer()}

Consume whitespace from input and return {whitespace_string, new_position}.

create_repair(action, description, position)

@spec create_repair(String.t(), String.t(), non_neg_integer()) :: map()

Create a repair action record.

is_identifier_char(char)

@spec is_identifier_char(String.t()) :: boolean()

Check if a character can be part of an identifier.

is_identifier_start(char)

@spec is_identifier_start(String.t()) :: boolean()

Check if a character can start an identifier (letter, underscore, or UTF-8).

is_identifier_start_char_simple(char)

@spec is_identifier_start_char_simple(integer()) :: boolean()

Check if a character can start an identifier in binary optimized mode.

is_number_char(char)

@spec is_number_char(String.t()) :: boolean()

Check if a character is part of a number.

is_utf8_letter(char)

@spec is_utf8_letter(String.t()) :: boolean()

Check if a character is a UTF-8 letter (simplified approach).

is_word_boundary(input, pos, token)

@spec is_word_boundary(String.t(), non_neg_integer(), String.t()) :: boolean()

Check if a token match is at a word boundary.

match_at_position?(input, pos, search_string)

@spec match_at_position?(String.t(), non_neg_integer(), String.t()) :: boolean()

Check if a string matches at a specific position (UTF-8 safe).

pop_stack_safe(list)

@spec pop_stack_safe(list()) :: {list(), any()}

Safely pop from stack.