EpilogJS
What
versus
How
 

read


read(string) → expression

The subroutine read takes a string as argument and returns as value the internal representation of the first Epilog expression in the specified string. In the event of a syntactically illegal string, it returns error.

Call: read('a') Exit: a Call: read('X') Exit: X Call: read('p(a,f(b),c)') Exit: ["p","a",["f","b"],"c"] Call: read('p(a,b) p(b,c)') Exit: ["p","a","b"] Call: read('p(a ~& q') Exit: error

Note that read parses only the first expression in the string. It ignores all text thereafter.

Call: read('p(a,b) p(b,c)') Exit: ["p","a","b"] Call: read('p(a,b) )a ~& q') Exit: ["p","a","b"]

Note also that every occurrence of the anonymous variable _ parses as a variable beginning with _ and followed by a unique natural number.

Call: read('p(a,_,_,d)') Exit: ["p","a","_1","_2","b"]



Comments and complaints to genesereth@stanford.edu.