about the "xpr" module

crux-00035: $SRC/xpr/README.xpr

* "xpr": Polymorphic expression values

  The "xpr" module provides polymorophic
  expression values.

  It will take several revisions to lay out the 
  full xpr functionality.

  For now, xpr provides only type-tagged values of type:


* The "xpr" interface

  #include "strt/strt.h"
  #include "xpr/xpr.h"

  struct xpr_ref v = {0,};

  void xpr_load_nil (struct xpr_ref * r);
  void xpr_load_boolean (struct xpr_ref * r, int x);
  void xpr_load_int (struct xpr_ref * r, int v);
  void xpr_load_float (struct xpr_ref * r, int v);
  void xpr_load_string (struct xpr_ref *, int l, char const * s);
  void xpr_load_string0 (struct xpr_ref *, char const * s);
    Change the value of an xpr_ref.

  enum xpr_type xpr_type (struct xpr_ref const * r);
    Returns xpr_is_nil, xpr_is_int or xpr_is_float.

  void xpr_check (struct xpr_ref const * r, enum xpr_type type);
    Panic if the value in *r is not of the indicated type.

  int xpr_read_boolean (struct xpr_read const * r);
  int xpr_read_int (struct xpr_read const * r);
  float xpr_read_float (struct xpr_read const * r);
    Return the boolean (int), int or float in r (respectively).
    Panic if r is not of the anticipated type.

  void xpr_fmt (strt s, struct xpr_ref const * r);
    Convert the value in r to a string.

  int xpr_string_length (struct xpr_ref const *);
  char const * xpr_string_view_ro (struct xpr_ref const *, int pos, int l);
  char * xpr_string_view_rw (struct xpr_ref *, int pos, int l);
  void xpr_string_adjoin (struct xpr_ref *, char c);
  void xpr_string_append (struct xpr_ref *, int l, char const * c);
  void xpr_string_append0 (struct xpr_ref *, char const * c);
  void xpr_string_cat (struct xpr_ref *, struct xpr_ref const *);
  void xpr_string_trim (struct xpr_ref *);
  int xpr_string_overlaps (struct xpr_ref const *, int l, char const * c);
    String functions.  See README.str for comparison.

  void xpr_load_tuple (struct xpr_ref * r, int l);
    Load a tuple of length l, filled with nil, in r.

  int xpr_tuple_length (struct xpr_ref const *);
    Return the length of a tuple.
  struct xpr_ref const * xpr_tuple_view_ro (struct xpr_ref const *, int pos, int l);
  struct xpr_ref * xpr_tuple_view_rw (struct xpr_ref *, int pos, int l);
    Return a view of tuple elements.
  void xpr_tuple_set_length (struct xpr_ref *, int l);
    Change the length of a tuple.

  void xpr_tuple_trim (struct xpr_ref *);
    Compact a tuple in memory, if possible.



    This file is part of Crux.

    Crux is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Crux is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Crux.  If not, see <http://www.gnu.org/licenses/>.


basiscraft - the crux project - xpr/README.xpr about the "xpr" module

crux-00035: $SRC/xpr/README.xpr