Unity.GnuUnitsImporter.Parser (Unity v0.7.0)

Copy Markdown View Source

Pass 1: parses a GNU units definition file into raw data structures.

Reads line by line, handling continuation lines, comments, directives, and different definition types. Produces a map suitable for the resolver.

Summary

Functions

Parses GNU units definition content (as a string) into raw data structures.

Parses a GNU units definition file into raw data structures.

Types

parsed()

@type parsed() :: %{
  primitives: %{required(String.t()) => :base | :dimensionless},
  prefixes: %{required(String.t()) => String.t()},
  definitions: %{required(String.t()) => String.t()},
  aliases: %{required(String.t()) => String.t()},
  functions: %{required(String.t()) => String.t()},
  skipped: [{String.t(), String.t()}]
}

Functions

parse_content(content)

@spec parse_content(String.t()) :: parsed()

Parses GNU units definition content (as a string) into raw data structures.

parse_file(path)

@spec parse_file(String.t()) :: {:ok, parsed()} | {:error, String.t()}

Parses a GNU units definition file into raw data structures.

Arguments

  • path — path to the definitions file.

Returns

  • {:ok, parsed} with the parsed data.

  • {:error, reason} if the file cannot be read.