YAP 7.1.0
readterm.c File Reference

glue code between parser and streams More...

#include "Yap.h"
#include "YapEval.h"
#include "YapFlags.h"
#include "YapHeap.h"
#include "YapText.h"
#include "Yatom.h"
#include "yapio.h"
#include <stdlib.h>
#include "iopreds.h"

Go to the source code of this file.

Macros

#define strncat(X, Y, Z)   strcat(X, Y)
 
#define strncpy(X, Y, Z)   strcpy(X, Y)
 
#define SYSTEM_STAT   stat
 
#define READ_DEFS()
 
#define PAR(x, y, z)   z
 
#define PAR(x, y, z)
 
#define PUSHFET(X)   *HR++ = fe->X
 
#define POPFET(X)   fe->X = *--HR
 
#define READ_CLAUSE_DEFS()
 
#define PAR(x, y, z)   z
 
#define PAR(x, y, z)
 

Typedefs

typedef enum open_enum_choices read_choices_t
 
typedef struct FEnv FEnv
 
typedef struct renv REnv
 
typedef enum read_clause_enum_choices read_clause_choices_t
 

Enumerations

enum  open_enum_choices { OPEN_DEFS =() , READ_DEFS =() }
 
enum  parser_state_t {
  YAP_START_PARSING , YAP_SCANNING , YAP_SCANNING_ERROR , YAP_PARSING ,
  YAP_PARSING_ERROR , YAP_PARSING_FINISHED
}
 
enum  read_clause_enum_choices { READ_CLAUSE_DEFS =() }
 

Functions

Term Yap_syntax_error (TokEntry *errtok, int sno, const char *msg)
 
Int Yap_FirstLineInParse (void)
 
Term Yap_read_term (int sno, Term opts, bool clause)
 generic routine to read terms from a stream More...
 
Term Yap_BufferToTerm (const char *s, Term opts)
 
Term Yap_UBufferToTerm (const unsigned char *s, Term opts)
 
X_API Term Yap_BufferToTermWithPrioBindings (const char *s, Term ctl, Term bindings, size_t len, int prio)
 
void Yap_InitReadTPreds (void)
 

Detailed Description

glue code between parser and streams

for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,

Definition in file readterm.c.

Macro Definition Documentation

◆ PAR [1/4]

#define PAR (   x,
  y,
 
)    z

Definition at line 1436 of file readterm.c.

◆ PAR [2/4]

#define PAR (   x,
  y,
 
)
Value:
{ \
x, y, z \
}

Definition at line 1436 of file readterm.c.

◆ PAR [3/4]

#define PAR (   x,
  y,
 
)    z

Definition at line 1436 of file readterm.c.

◆ PAR [4/4]

#define PAR (   x,
  y,
 
)
Value:
{ \
x, y, z \
}

Definition at line 1436 of file readterm.c.

◆ POPFET

#define POPFET (   X)    fe->X = *--HR

Definition at line 736 of file readterm.c.

◆ PUSHFET

#define PUSHFET (   X)    *HR++ = fe->X

Definition at line 735 of file readterm.c.

◆ READ_CLAUSE_DEFS

#define READ_CLAUSE_DEFS ( )
Value:
PAR("comments", list_filler, READ_CLAUSE_COMMENTS) \
, PAR("module", isatom, READ_CLAUSE_MODULE), \
PAR("variable_names", filler, READ_CLAUSE_VARIABLE_NAMES), \
PAR("variables", filler, READ_CLAUSE_VARIABLES), \
PAR("term_position", filler, READ_CLAUSE_TERM_POSITION), \
PAR("syntax_errors", isatom, READ_CLAUSE_SYNTAX_ERRORS), \
PAR("output", isatom, READ_CLAUSE_OUTPUT), \
PAR(NULL, ok, READ_CLAUSE_END)

Definition at line 1417 of file readterm.c.

◆ READ_DEFS

#define READ_DEFS ( )
Value:
PAR("comments", list_filler, READ_COMMENTS), \
PAR("module", isatom, READ_MODULE), PAR("priority", nat, READ_PRIORITY), \
PAR("output", filler, READ_OUTPUT), \
PAR("quasi_quotations", filler, READ_QUASI_QUOTATIONS), \
PAR("term_position", filler, READ_TERM_POSITION), \
PAR("syntax_errors", isatom, READ_SYNTAX_ERRORS), \
PAR("singletons", filler, READ_SINGLETONS), \
PAR("variables", filler, READ_VARIABLES), \
PAR("variable_names", filler, READ_VARIABLE_NAMES), \
PAR("character_escapes", booleanFlag, READ_CHARACTER_ESCAPES), \
PAR("input_closing_blank", booleanFlag, READ_INPUT_CLOSING_BLANK), \
PAR("backquoted_string", isatom, READ_BACKQUOTED_STRING), \
PAR("singlequoted_string", isatom, READ_SINGLEQUOTED_STRING), \
PAR("doublequoted_string", isatom, READ_DOUBLEQUOTED_STRING), \
PAR("var_prefix", isatom, READ_VAR_PREFIX), \
PAR("allow_variable_name_as_functor", isatom, \
READ_ALLOW_VARIABLE_NAME_AS_FUNCTOR), \
PAR("cycles", booleanFlag, READ_CYCLES), PAR(NULL, ok, READ_END)

Definition at line 205 of file readterm.c.

◆ strncat

#define strncat (   X,
  Y,
 
)    strcat(X, Y)

Definition at line 80 of file readterm.c.

◆ strncpy

#define strncpy (   X,
  Y,
 
)    strcpy(X, Y)

Definition at line 83 of file readterm.c.

◆ SYSTEM_STAT

#define SYSTEM_STAT   stat

Definition at line 99 of file readterm.c.

Enumeration Type Documentation

◆ open_enum_choices

enum open_enum_choices

Definition at line 227 of file readterm.c.

◆ parser_state_t

Enumerator
YAP_SCANNING 

initialization

YAP_SCANNING_ERROR 

input to list of tokens

YAP_PARSING 

serious error (eg oom); trying error handling, followd

by either restart or failure

YAP_PARSING_ERROR 

list of tokens to term

YAP_PARSING_FINISHED 

oom or syntax error

exit parser

Definition at line 718 of file readterm.c.

◆ read_clause_enum_choices

enum read_clause_enum_choices

Definition at line 1429 of file readterm.c.

Function Documentation

◆ Yap_BufferToTerm()

Term Yap_BufferToTerm ( const char *  s,
Term  opts 
)

Definition at line 1762 of file readterm.c.

◆ Yap_BufferToTermWithPrioBindings()

X_API Term Yap_BufferToTermWithPrioBindings ( const char *  s,
Term  ctl,
Term  bindings,
size_t  len,
int  prio 
)

Definition at line 1793 of file readterm.c.

◆ Yap_FirstLineInParse()

Int Yap_FirstLineInParse ( void  )

Definition at line 729 of file readterm.c.

◆ Yap_InitReadTPreds()

void Yap_InitReadTPreds ( void  )

Definition at line 2020 of file readterm.c.

◆ Yap_read_term()

Term Yap_read_term ( int  sno,
Term  opts,
bool  clause 
)

generic routine to read terms from a stream

  • inp_stream: where we read from
  • : opts, a list with options
  • : if called from read_term, arity called from read_clause, -arity
Returns
the term or 0 in case of error

Implementation uses a state machine: default is init, scan, parse, complete

Definition at line 1324 of file readterm.c.

◆ Yap_syntax_error()

Term Yap_syntax_error ( TokEntry errtok,
int  sno,
const char *  msg 
)

Definition at line 508 of file readterm.c.

◆ Yap_UBufferToTerm()

Term Yap_UBufferToTerm ( const unsigned char *  s,
Term  opts 
)

Definition at line 1778 of file readterm.c.