Feel.Syntax.ScopeIndex (feel v0.1.0)

Copy Markdown View Source

What the parser needs to know of a scope, made once and added to one name at a time.

The parser matches the names of a scope as the longest names that the tokens make, so for each parse it takes the names of the scope (lexing each, to count its tokens) and the names of the types. That is the size of the scope for every text, which is nothing for one expression and the square of the size for a caller that parses a text for each of 4,000 entries of a context against a scope of 4,000 names. new/2 does it once, put_name/2 adds a name (the entry of a context, a parameter) in the time of its tokens, and Feel.parse/2 takes the index as its :scope_index.

The index is the scope it was made from, and the names added: Feel.parse/2 reads the names from it and not from the :scope (the scope still gives the types of instance of, unless the index was made with them, as it is).

Summary

Functions

The index of a scope: its names, with the built-in functions and the names of the functions that the extensions add, and its types.

The index with a name more. The name is lexed to count its tokens, since it may hold symbols (a-b is three); a text that does not lex as a name is left out, as new/2 leaves it out.

Types

t()

@opaque t()

Functions

new(scope, extensions \\ [])

@spec new(Feel.Scope.t(), Feel.Extensions.t() | [atom()]) :: t()

The index of a scope: its names, with the built-in functions and the names of the functions that the extensions add, and its types.

iex> index = Feel.Syntax.ScopeIndex.new(Feel.Scope.new(%{"first name" => :string}))
iex> {:ok, {:name, _meta, ["first", "name"]}} = Feel.parse("first name", scope_index: index)

put_name(index, name)

@spec put_name(t(), String.t()) :: t()

The index with a name more. The name is lexed to count its tokens, since it may hold symbols (a-b is three); a text that does not lex as a name is left out, as new/2 leaves it out.