<HTML> <HEAD> <!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 --> <LINK rel="stylesheet" href="ciao.css" type="text/css"> <TITLE>The Ciao Prolog System - String processing</TITLE> </HEAD> <BODY> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_68.html">previous</A>, <A HREF="ciao_70.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. <P><HR><P> <H1><A NAME="SEC300" HREF="ciao_toc.html#TOC300">String processing</A></H1> <P> <A NAME="IDX4320"></A> <P> <STRONG>Author(s):</STRONG> Daniel Cabeza. <P> <STRONG>Version:</STRONG> 0.4#5 (1998/2/24) <P> This module provides predicates for doing input/output with strings (character code lists) and for including in grammars defining strings. <UL> <LI><A HREF="ciao_69.html#SEC301">Usage and interface (strings)</A> <LI><A HREF="ciao_69.html#SEC302">Documentation on exports (strings)</A> <LI><A HREF="ciao_69.html#SEC303">Documentation on internals (strings)</A> </UL> <H2><A NAME="SEC301" HREF="ciao_toc.html#TOC301">Usage and interface (<CODE>strings</CODE>)</A></H2> <div class="cartouche"> <UL> <LI><STRONG>Library usage:</STRONG> <CODE>:- use_module(library(strings)).</CODE> <LI><STRONG>Exports:</STRONG> <UL> <LI><EM>Predicates:</EM> <A NAME="IDX4321"></A> <CODE>get_line/2</CODE>, <A NAME="IDX4322"></A> <CODE>get_line/1</CODE>, <A NAME="IDX4323"></A> <CODE>write_string/2</CODE>, <A NAME="IDX4324"></A> <CODE>write_string/1</CODE>, <A NAME="IDX4325"></A> <CODE>whitespace/2</CODE>, <A NAME="IDX4326"></A> <CODE>whitespace0/2</CODE>, <A NAME="IDX4327"></A> <CODE>string/3</CODE>. </UL> </UL> </div class="cartouche"> <H2><A NAME="SEC302" HREF="ciao_toc.html#TOC302">Documentation on exports (<CODE>strings</CODE>)</A></H2> <P> <A NAME="IDX4328"></A> <A NAME="IDX4329"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>get_line/2:</B> <DD><A NAME="IDX4330"></A> <P> <CODE>get_line(Stream, Line)</CODE> <P> Reads from <CODE>Stream</CODE> a line of text and unifies <CODE>Line</CODE> with it. The end of the line can have UNIX [10] or MS-DOS [13 10] termination, which is not included in <CODE>Line</CODE>. At EOF, the term end_of_file is returned. </DL> <P> <A NAME="IDX4331"></A> <A NAME="IDX4332"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>get_line/1:</B> <DD><A NAME="IDX4333"></A> <P> <CODE>get_line(Line)</CODE> <P> Behaves like <CODE>current_input(S), get_line(S,Line)</CODE>. </DL> <P> <A NAME="IDX4334"></A> <A NAME="IDX4335"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>write_string/2:</B> <DD><A NAME="IDX4336"></A> <P> <CODE>write_string(Stream, String)</CODE> <P> Writes <CODE>String</CODE> onto <CODE>Stream</CODE>. </DL> <P> <A NAME="IDX4337"></A> <A NAME="IDX4338"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>write_string/1:</B> <DD><A NAME="IDX4339"></A> <P> <CODE>write_string(String)</CODE> <P> Behaves like <CODE>current_input(S), write_string(S, String)</CODE>. </DL> <P> <A NAME="IDX4340"></A> <A NAME="IDX4341"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>whitespace/2:</B> <DD><A NAME="IDX4342"></A> <P> <CODE>whitespace(String, Rest)</CODE> <P> In a grammar rule, as <CODE>whitespace/0</CODE>, represents whitespace (a positive number of space (32), tab (9), newline (10) or return (13) characters). Thus, <CODE>Rest</CODE> is a proper suffix of <CODE>String</CODE> with one or more whitespace characters removed. An example of use would be: <PRE> attrs([]) --> "" attrs([N|Ns]) --> whitespace, attr(N), attrs(Ns). </PRE> </DL> <P> <A NAME="IDX4343"></A> <A NAME="IDX4344"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>whitespace0/2:</B> <DD><A NAME="IDX4345"></A> <P> <CODE>whitespace0(String, Rest)</CODE> <P> In a grammar rule, as <CODE>whitespace0/0</CODE>, represents possible whitespace (any number of space (32), tab (9), newline (10) or return (13) characters). Thus, <CODE>Rest</CODE> is <CODE>String</CODE> or a proper suffix of <CODE>String</CODE> with one or more whitespace characters removed. An example of use would be: <PRE> assignment(N,V) --> variable_name(N), whitespace0, "=", whitespace0, value(V). </PRE> </DL> <P> <A NAME="IDX4346"></A> <A NAME="IDX4347"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>string/3:</B> <DD><A NAME="IDX4348"></A> <P> <CODE>string(String, Head, Tail)</CODE> <P> In a <A NAME="IDX4349"></A> grammar rule, as <CODE>string/1</CODE>, represents literally <CODE>String</CODE>. An example of use would be: <PRE> double(A) --> string(A), string(A). </PRE> </DL> <H2><A NAME="SEC303" HREF="ciao_toc.html#TOC303">Documentation on internals (<CODE>strings</CODE>)</A></H2> <P> <A NAME="IDX4350"></A> <A NAME="IDX4351"></A> <DL> <DT><span class="define">PROPERTY:</span> <B>line/1:</B> <DD><A NAME="IDX4352"></A> <P> A property, defined as follows: <PRE> <PRE> line(L) :- string(L). line(end_of_file). </PRE> </PRE> </DL> <P><HR><P> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_68.html">previous</A>, <A HREF="ciao_70.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. </BODY> </HTML>