Contents

1 PSYC Packets

This page describes the syntax and parts of the Semantic of a PSYC packet.

(this is only a draft, the current spec is still in the git)

1.1 ABNF

PSYC packets are byte sequences which have the following syntax:

  packet     = [ mmp-mods nl ] [ psyc-mods ] [ body nl ] "." nl
  
  mmp-mods   = 1*modifier
  psyc-mods  = 1*modifier
  
  modifier   = glyph var-part ( *(tab argument nl) / nl )
  glyph      = "=" / "+" / "-" / ":"
  var-part   = *type variable
  type       = "@" | "|"
  variable   = *varchar
   
  argument   = array-arg / list-arg / opaque
  array-arg  = *arrchar [ ";" array-arg ]
  list-arg   = list-key tab list-value
  list-key   = *varchar
  list-value = *nonlchar
  opaque     = *nonlchar
  
  body       = method [ nl data ]
  method     = "_" *nonlchar
  data       = <any bytes until the sequence (nl "." nl) has been encountered>
  
  nl         = %x0A
  tab        = %x09
  nonlchar   = %x00-09 / %x0B-FF           ; basically any byte except newline
  arrchar    = %x00-09 / %x0B-2B / %x4B-FF ; basically any byte except newline and ";"
  varchar    = %x00-08 / %x0B-FF           ; basically any byte except tab and newline

1.2 Encoding

Variable names and methods are ASCII encoded strings. While the contents of body or the arguments of variables usually have no specific encoding (which means that it is later determined by specific variables).

1.3 Variables

The packet has modifiers which contain variable definitions. There are two sets of variables: The current variables (cvars) and the persistent variables (pvars). The 'glyph' part of a 'modifier' defines how the variable modifies the current and the persistent variables.

Current variables belong to a packet and the persistent variables belong to the connection.

Variables usually start with a "_".

1.4 MMP- and PSYC-modifiers

In PSYC packets there are two sets of mutually exclusive variables. The variables of the MMP set and the ones of the PSYC set. The two sets are usually seperated by a newline in the packet header, but the newline is not mandatory. That means that 'psyc-mods' can contain adjustments of MMP variables.

The MMP variables control routing and the PSYC variables are for other purposes.

For a listing of the MMP variables consult the mmp_vars.txt spec.

1.5 Empty variable names

If the 'var-part' is omitted, the name of the last used variable is used. That means, this:

  :_members  knuddel://my.example.org/~stan
  :          knuddel://my.example.org/~ollie

Means this:

  :_members  knuddel://my.example.org/~stan
  :_members  knuddel://my.example.org/~ollie

1.6 Glyphs

Following glyphs are defined:

  • ":" - If this glyph is used the defined variable is only used as cvar.
  • "=" - This glyph says that the variable is used in the cvars _and_ overrides the pvar.
  • "+" - If this glyph is used the arguments of the variable are appended to the arguments of the pvar and the contents of the pvar is used as cvar.
  • "-" - This glyph removes the variable from cvars and pvars.

Other glyphs are currently unused or undefined.

1.7 Packet ID

Sometimes you want to refer to a packet (eg. in the _relay variable, see also routing.txt). Then you compute the packet id as follows:

  packet-id = concat (source, logical taget, counter, [fragment])

(For a definition of logical target see routing.txt.)

TODO: how is source defined?

1.8 Example

  .
  :_source        psyc://fi.ve.symlynx.com/~fippo
  :_target        psyc://ente.aquarium:-32872
  
  :_nick  fippo
  _info_nickname
  Hello [_nick].
  .

1.9 Implementation Note

There is a the Wiki page Parse which describes how a Parser may be implemented (might not match this spec completely).