# Module `pl.sip`

Simple Input Patterns (SIP).

SIP patterns start with '$', then a one-letter type, and then an optional variable in curly braces.

sip.match('$v=$q','name="dolly"',res) ==> res=={'name','dolly'} sip.match('($q{first},$q{second})','("john","smith")',res) ==> res=={second='smith',first='john'}

''Type names''

v identifier i integer f floating-point q quoted string ([{< match up to closing bracket

See the Guide

## Functions

create_pattern (spec, options) | convert a SIP pattern into the equivalent Lua string pattern.
compile (spec, options) | convert a SIP pattern into a matching function.
match (spec, line, res, options) | match a SIP pattern against a string.
match_at_start (spec, line, res) | match a SIP pattern against the start of a string.
fields (spec, f) | given a pattern and a file object, return an iterator over the results
pattern (spec, fun) | register a match which will be used in the read function.
read (f) | enter a loop which applies all registered matches to the input file.

## Functions

create_pattern (spec, options)
  convert a SIP pattern into the equivalent Lua string pattern.

  ### Parameters:

  - spec a SIP pattern
  - options a table; only the `at_start` field is currently meaningful and esures that the pattern is anchored at the start of the string.

  ### Returns:

  a Lua string pattern.
compile (spec, options)
  convert a SIP pattern into a matching function. The returned function takes two arguments, the line and an empty table. If the line matched the pattern, then this function return true and the table is filled with field-value pairs.

  ### Parameters:

  - spec a SIP pattern
  - options optional table; {anywhere=true} will stop pattern anchoring at start

  ### Returns:

  a function if successful, or nil,<error>
match (spec, line, res, options)
  match a SIP pattern against a string.

  ### Parameters:

  - spec a SIP pattern
  - line a string
  - res a table to receive values
  - options (optional) option table

  ### Returns:

  true or false
match_at_start (spec, line, res)
  match a SIP pattern against the start of a string.

  ### Parameters:

  - spec a SIP pattern
  - line a string
  - res a table to receive values

  ### Returns:

  true or false
fields (spec, f)
  given a pattern and a file object, return an iterator over the results

  ### Parameters:

  - spec a SIP pattern
  - f a file - use standard input if not specified.
pattern (spec, fun)
  register a match which will be used in the read function.

  ### Parameters:

  - spec a SIP pattern
  - fun a function to be called with the results of the match

  ### see also:

  read
read (f)
  enter a loop which applies all registered matches to the input file.

  ### Parameters:

  - f a file object; if nil, then io.stdin is assumed.

generated by LDoc 1.3.12