# `PgRest.Grammar.Common`
[🔗](https://github.com/agoodway/pgrest/blob/v0.2.0/lib/pg_rest/grammar/common.ex#L1)

Building blocks shared by the PostgREST grammars: quoted values, identifiers,
field names with JSON paths, tree paths, the cast-name rule, and error helpers.

The `defcombinator` pieces are reused by other grammar modules through
`parsec({PgRest.Grammar.Common, name})`.

# `blank__0`

# `blank__1`

# `blank__2`

# `blank__3`

# `blank__4`

# `blank__5`

# `cast_name?`

```elixir
@spec cast_name?(term()) :: boolean()
```

Whether `name` is an acceptable cast type name (see the module attributes for the
rule). This is the single definition used by the select grammar and `Builder.cast/2`.

# `field__0`

# `field__1`

# `field__2`

# `field__3`

# `field__4`

# `field_name__0`

# `field_name__1`

# `field_name__2`

# `field_name__3`

# `field_name__4`

# `field_name__5`

# `field_name__6`

# `field_name__7`

# `field_name__8`

# `field_name__9`

# `field_name__10`

# `field_name__11`

# `field_name__12`

# `field_name__13`

# `field_name__14`

# `field_name__15`

# `field_name__16`

# `identifier__0`

# `identifier__1`

# `identifier__2`

# `identifier__3`

# `identifier__4`

# `identifier__5`

# `identifier__6`

# `identifier__7`

# `json_path__0`

# `json_path__1`

# `json_path__2`

# `json_path__3`

# `json_path__4`

# `json_path__5`

# `json_path__6`

# `json_path__7`

# `json_path__8`

# `json_path__9`

# `json_path__10`

# `json_path__11`

# `json_path__12`

# `json_path__13`

# `json_path__14`

# `json_path__15`

# `json_path__16`

# `json_path__17`

# `json_path__18`

# `json_path__19`

# `json_path__20`

# `json_path__21`

# `json_path__22`

# `json_path__23`

# `json_path__24`

# `json_path__25`

# `json_path__26`

# `json_path__27`

# `json_path__28`

# `json_path__29`

# `json_path__30`

# `json_path__31`

# `json_path__32`

# `json_path__33`

# `json_path__34`

# `json_path__35`

# `json_path__36`

# `json_path__37`

# `json_path__38`

# `json_path__39`

# `json_path__40`

# `json_path__41`

# `json_path__42`

# `json_path__43`

# `json_path__44`

# `json_path__45`

# `json_path__46`

# `json_path__47`

# `name_expecting`

```elixir
@spec name_expecting() :: String.t()
```

The expectation text for a missing field name.

# `parse_field`

```elixir
@spec parse_field(String.t()) ::
  {:ok, PgRest.AST.Field.t(), String.t()} | {:error, String.t()}
```

Parses a field (name plus JSON path), ignoring spaces and tabs around it.

Returns the field and the unparsed rest, or `{:error, input}` when no field starts
the input.

# `parse_field`

```elixir
@spec parse_field(String.t(), String.t()) ::
  {:ok, PgRest.AST.Field.t(), String.t()} | {:fail, String.t(), String.t()}
```

Like `parse_field/1`, but a failure is `{:fail, input, expecting}`.

# `parse_name`

```elixir
@spec parse_name(String.t()) :: {:ok, String.t(), String.t()} | :no_match
```

Parses a bare name (no JSON path), returning it and the rest, or `:no_match`.

# `parse_names`

```elixir
@spec parse_names(String.t(), String.t()) ::
  {:ok, [String.t()]} | {:error, PgRest.Error.t()}
```

Parses dotted names (`client.not.or`), consuming the whole text. Returns the names or
a `PGRST100` error naming `what`.

# `parse_tree_path`

```elixir
@spec parse_tree_path(String.t()) ::
  {:ok, {[String.t()], PgRest.AST.Field.t()}} | {:error, PgRest.Error.t()}
```

Parses a query-string key such as `a.b.col->x` into its embed path and column field
(upstream `pTreePath`). The whole key must be consumed.

# `quoted_value__0`

# `quoted_value__1`

# `quoted_value__2`

# `quoted_value__3`

# `quoted_value__4`

# `quoted_value__5`

# `quoted_value__6`

# `quoted_value__7`

# `quoted_value__8`

# `quoted_value__9`

# `quoted_value__10`

# `quoted_value__11`

# `quoted_value__12`

# `quoted_value__13`

# `quoted_value__14`

# `quoted_value__15`

# `quoted_value__16`

# `quoted_value__17`

# `raw_value__0`

# `raw_value__1`

# `raw_value__2`

# `raw_value__3`

# `raw_value__4`

# `raw_value__5`

# `raw_value__6`

# `raw_value__7`

# `raw_value__8`

# `raw_value__9`

# `raw_value__10`

# `raw_value__11`

# `reject_nul`

```elixir
@spec reject_nul(String.t() | [String.t()]) :: :ok | {:error, PgRest.Error.t()}
```

Rejects a text (or a list of texts) that contains a NUL byte, for identifiers.

# `syntax_error`

```elixir
@spec syntax_error(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  PgRest.Error.t()
```

Builds a PostgREST-style parse error: the message names the parsed `what` and the
column of the failure, the details say what was found and what was expected.

`full_input` is the text the parser saw, `rest` the unparsed remainder at the failure
point, `shown` the text echoed in the message. Option `quote: :string` shows the
unexpected character as a string (`"x"`) even where Parsec would show a character.

# `take_cast`

```elixir
@spec take_cast(String.t()) ::
  {:ok, String.t(), String.t()} | {:fail, String.t(), String.t()}
```

Takes the cast name at the start of `rest` (after a `::`) and validates it with
`cast_name?/1`. Returns the name and the rest with blanks skipped.

# `validate_field`

```elixir
@spec validate_field(PgRest.AST.Field.t()) :: :ok | {:error, PgRest.Error.t()}
```

Rejects a field whose name or JSON-path keys contain a NUL byte.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
