Atom to term conversion

Author(s): Francisco Bueno, Daniel Cabeza, Manuel Hermenegildo.

This module implements predicates for atom or string to term conversion.

Usage and interface

Documentation on exports

PREDICATE

General properties: atom2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=a then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=a
atom2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=1 then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=1
atom2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=A then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=A
atom2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=f(a) then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f(a)
atom2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=f/2 then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f/2

Usage: atom2term(Atom,Term)

  • Description: Convert an atom into a term. Atom is an atom, but must have term syntax. Term is a term resulting from parsing Atom char by char. The term is assumed to be ground.
  • The following properties should hold at call time:
    (term_typing:nonvar/1)Atom is currently a term which is not a free variable.
    (term_typing:var/1)Term is a free variable.

PREDICATE

General properties: string2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[97] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=a
string2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[49] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=1
string2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[65] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=A
string2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,97,41] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f(a)
string2term(A,T)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,47,50] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f/2

Usage: string2term(String,Term)

  • Description: Same as atom2term/2 but first argument is a string (containing a term).
  • The following properties should hold at call time:
    (term_typing:nonvar/1)String is currently a term which is not a free variable.
    (term_typing:var/1)Term is a free variable.

PREDICATE

General properties: parse_term(A,T,R)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,97,41] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f(a)
    (term_basic:= /2)term_basic:R=[]
parse_term(A,T,R)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,97,41,32,102,111,111,32] then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f(a)
    (term_basic:= /2)term_basic:R=[32,102,111,111,32]

Usage: parse_term(String,Term,Rest)

  • Description: String is parsed into Term up to Rest (which is the non-parsed rest of the list). The term is assumed to be ground.
  • The following properties should hold at call time:
    (term_typing:nonvar/1)String is currently a term which is not a free variable.
    (term_typing:var/1)Term is a free variable.

PREDICATE

General properties: parse_term(A,T,R,V)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,88,41]
    (term_basic:= /2)term_basic:V=nonvars then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f(X)
    (term_basic:= /2)term_basic:R=[]
parse_term(A,T,R,V)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,88,41]
    (term_basic:= /2)term_basic:V=vars then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f([88])
    (term_basic:= /2)term_basic:R=[]
parse_term(A,T,R,V)
  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[102,40,88,41,32,102,111,111,32]
    (term_basic:= /2)term_basic:V=vars then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:T=f([88])
    (term_basic:= /2)term_basic:R=[32,102,111,111,32]

Usage: parse_term(String,Term,Rest,Vars)

  • Description: String is parsed into Term up to Rest (which is the non-parsed rest of the list). The term is assumed to be ground. If Vars is vars then upper case identifiers in the term are turned into variables.
  • The following properties should hold at call time:
    (term_typing:nonvar/1)String is currently a term which is not a free variable.
    (term_typing:var/1)Term is a free variable.
    (term_typing:nonvar/1)Vars is currently a term which is not a free variable.

Known bugs and planned improvements

  • This is just a quick hack written mainly for parsing daVinci's messages. There should be a call to the standard reader to do this!