BAP Online Manuals : Library Reference : Library by Name : fronttoken
Previous: frontstr
Next: get

6.2.63. fronttoken

extracts the first token in front of a string

SYNOPSIS

fronttoken("Hello World",Token,RestString)

SYNTAX

fronttoken(String,Token,RestString) (i,x,x)

ARGUMENTS

string(String) (i) string to be separated
string(Token) (x) first Token contained in String
string(RestString) (x) String without its leading white spaces characters and Token

DESCRIPTION

Fronttoken() skips all white space characters (blanks,tabs) and separates from the resulting string the first valid token. The remainder is matched with RestString. A valid token is either a variable or name 'A'...'Z','a'...'z',' ','0'...'9', a number '0'...'9' or a single character. It fails if String was empty or contained only whitespace.

EXAMPLE

readln(Input),		% e.g. enter "3+5", 
"4*6" 
fronttoken(Input,T1,,R1),
fronttoken(R1,Op,T2),
str_int(T1,I1),str_int(T2,I2),
Expr =.. [Op,I1,I2],
Sum is Expr,
write(Sum),nl.

ERRORS

A runtime error occurs if the arguments belong to the wrong domain.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

frontchar , str_char , frontchar ,

prologtoken , concat , str_len


BAP Online Manuals : Library Reference : Library by Name : fronttoken
Previous: frontstr
Next: get