#include "parse.h"

This page has information from files parse.h and parse.c.

Contents


Public Routines in File parse.c

Index

declare_parse_typeget_cons_charread_termsplit_string
declare_quantifier_precedenceget_quote_charredeclare_symbol_and_copy_parsetypesread_term
declare_standard_parse_typesordinary_constant_stringsb_write_termtranslate_neg_equalities
fprint_parse_memp_parse_memset_cons_char
fwrite_termparenthesizeset_quote_char
fwrite_term_nlparse_term_from_stringskip_to_nl

Details


void declare_parse_type(char *str, int precedence, Parsetype type);

void declare_quantifier_precedence(int prec);

void declare_standard_parse_types(void);

void fprint_parse_mem(FILE *fp, BOOL heading);
This routine prints (to FILE *fp) memory usage statistics for data types associated with the parse package. The Boolean argument heading tells whether to print a heading on the table.
void fwrite_term(FILE *fp, Term t);
This routine prints a term (to FILE *fp) in readable form, that is, infix where appropriate and without extra parentheses. A period and newline are not printed.

See the documentation on mixfix terms and the routine set_parse_type().


void fwrite_term_nl(FILE *fp, Term t);
This routine prints a term (to FILE *fp) in readable form, that is, infix where appropriate and without extra parentheses. Also printed is ".\n".

See the documentation on mixfix terms and the routine set_parse_type().


char get_cons_char(void);

char get_quote_char(void);

BOOL ordinary_constant_string(char *s);

void p_parse_mem(void);
This routine prints (to stdout) memory usage statistics for data types associated with the parse package.
void parenthesize(BOOL setting);

Term parse_term_from_string(char *s);

Term read_term(FILE *fin, FILE *fout);
This routine reads a term (from FILE *fin). The term may be in readable form, that is with infix operations and without extra parentheses.

If there is no term to be read, NULL is returned. If an error occurs, a message is sent to FILE *fout, and fatal error occurs.

See the documentation on mixfix terms and the routine set_parse_type().


BOOL redeclare_symbol_and_copy_parsetype(char *operation, char *str,
					 BOOL echo, FILE *fout);

void sb_write_term(String_buf sb, Term t);
This routine prints a term to a String_buf in readable form, that is, infix where appropriate and without extra parentheses. A period and newline are not printed.

See the documentation on mixfix terms and the routine set_parse_type().


void set_cons_char(char c);

void set_quote_char(char c);

void skip_to_nl(FILE *fp);
Read characters up to the first newline (or EOF).
Plist split_string(char *onlys);
This splits a string of symbols, separated by whitespace, into a list of strings. A Plist of (malloced) strings is returned.
Term sread_term(String_buf sb, FILE *fout);
This routine reads a term (from String_buf *sb). The term may be in readable form, that is with infix operations and without extra parentheses.

If there is no term to be read, NULL is returned. If an error occurs, a message is sent to FILE *fout, and fatal error occurs.

See the documentation on mixfix terms and the routine set_parse_type().


void translate_neg_equalities(BOOL flag);
This routine sets or clears the flag which tells the parser to automatically translate alpha!=beta to ~(alpha=beta). This happens in read_term(), which is called by read_clause(), read_formula(), and read_term_list().

Public Definitions in File parse.h


Introduction

This package has routines for reading and writing terms in human-readable form. Binary function symbols can be declared to be infix with a precedence and left or right association, so that many parentheses can be omitted. Unary symbols can be declared to be prefix or postfix. In addition, prolog-style list-notation and quantified formulas are supported.

The symbol declarations and parse rules are similar to the method used by many Prolog systems (although we use mnemonic names instead of xfy, yfx, yf, etc.). The symbol declarations are made with set_parse_type().

This package is based on code taked form Otter and EQP, but there are some important differences. Detailed documentation should be available elsewhere.

The intension is to use this package for reading and writing all types of data (terms, clauses, formulas, control information, etc.), with outside routines to translate to/from the appropriate internal data structure when necessary.