Solid.Lexer (solid v1.0.0-rc.0)

View Source

Lexer module for Solid. It is responsible for tokenizing the input text inside an object or a tag.

Summary

Functions

Tokenize the input text inside an object

Tokenize the input text as a complete tag

Tokenize the rest of the tag after the tag name

Tokenize the tag name for a tag

Types

column()

@type column() :: pos_integer()

line()

@type line() :: pos_integer()

loc()

@type loc() :: %{line: line(), column: column()}

operator()

@type operator() :: :== | :!= | :> | :>= | :< | :<= | :<> | :contains

special()

@type special() ::
  :dot
  | :pipe
  | :open_round
  | :close_round
  | :open_square
  | :close_square
  | :colon
  | :comma
  | :assignment

token()

@type token() ::
  {:string, loc(), binary(), 39 | 34}
  | {:integer, loc(), integer()}
  | {:float, loc(), float()}
  | {special(), loc()}
  | {:comparison, loc(), operator()}
  | {:identifier, loc(), binary()}
  | {:end, loc()}

tokens()

@type tokens() :: [token()]

Functions

tokenize_object(context)

@spec tokenize_object(Solid.ParserContext.t()) ::
  {:ok, tokens(), Solid.ParserContext.t()}
  | {:error, reason :: term(), rest :: binary(), loc()}

Tokenize the input text inside an object

tokenize_tag(context, opts \\ [])

@spec tokenize_tag(
  Solid.ParserContext.t(),
  keyword()
) ::
  {:ok, tag_name :: binary(), tokens(), Solid.ParserContext.t()}
  | {:liquid_tag, Solid.ParserContext.t()}
  | {:end_liquid_tag, Solid.ParserContext.t()}
  | {:error, reason :: term(), rest :: binary(), loc()}
  | {:error, :not_expected_tag}

Tokenize the input text as a complete tag

tokenize_tag_end(context)

@spec tokenize_tag_end(Solid.ParserContext.t()) ::
  {:ok, tokens(), Solid.ParserContext.t()}
  | {:error, reason :: term(), rest :: binary(), loc()}

Tokenize the rest of the tag after the tag name

tokenize_tag_start(context, opts \\ [])

@spec tokenize_tag_start(
  Solid.ParserContext.t(),
  keyword()
) ::
  {:ok, tag_name :: binary(), Solid.ParserContext.t()}
  | {:liquid_tag, Solid.ParserContext.t()}
  | {:end_liquid_tag, Solid.ParserContext.t()}
  | {:error, reason :: term(), rest :: binary(), loc()}
  | {:error, :not_expected_tag}

Tokenize the tag name for a tag