Logtalk reference manual
Built-in method: phrase/2

phrase/2

Description

phrase(NonTerminal, Input)
phrase(::NonTerminal, Input)
phrase(Object::NonTerminal, Input)

True if the list Input of tokens can be parsed using the specified non-terminal NonTerminal. This method also accepts grammar rule bodies in the first argument. This built-in method is declared private and thus cannot be used as a message to an object. When using a back-end Prolog compiler supporting a module system, calls in the format phrase(Module:NonTerminal, Input) may also be used.

This method is opaque to cuts in the first argument.

Template and modes

phrase(+callable, ?list)

Errors

NonTerminal is a variable:
instantiation_error
NonTerminal is neither a variable nor a callable term:
type_error(callable, NonTerminal)
Input is neither a partial list nor a list:
type_error(list, Input)
The grammar rule non-terminal NonTerminal is private:
permission_error(access, private_non_terminal, NonTerminal)
The grammar rule non-terminal NonTerminal is protected:
permission_error(access, protected_non_terminal, NonTerminal)
The grammar rule non-terminal NonTerminal is not declared:
existence_error(non_terminal_declaration, NonTerminal)

Examples

To parse a list of tokens using a local non-terminal:
phrase(NonTerminal, Input)
To parse a list of tokens using a non-terminal within the scope of self:
phrase(::NonTerminal, Input)
To parse a list of tokens using a public non-terminal of an explicit object:
phrase(Object::NonTerminal, Input)