Did you know ... | Search Documentation: |

library(dcg/basics): Various general DCG utilities |

- Documentation
- Reference manual
- The SWI-Prolog library
- library(aggregate): Aggregation operators on backtrackable predicates
- library(ansi_term): Print decorated text to ANSI consoles
- library(apply): Apply predicates on a list
- library(assoc): Association lists
- library(broadcast): Broadcast and receive event notifications
- library(charsio): I/O on Lists of Character Codes
- library(check): Consistency checking
- library(clpb): CLP(B): Constraint Logic Programming over Boolean Variables
- library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
- library(clpqr): Constraint Logic Programming over Rationals and Reals
- library(csv): Process CSV (Comma-Separated Values) data
- library(dcg/basics): Various general DCG utilities
- library(dcg/high_order): High order grammar operations
- library(debug): Print debug messages and test assertions
- library(dicts): Dict utilities
- library(error): Error generating support
- library(gensym): Generate unique identifiers
- library(intercept): Intercept and signal interface
- library(iostream): Utilities to deal with streams
- library(lists): List Manipulation
- library(main): Provide entry point for scripts
- library(nb_set): Non-backtrackable set
- library(www_browser): Activating your Web-browser
- library(occurs): Finding and counting sub-terms
- library(option): Option list processing
- library(optparse): command line parsing
- library(ordsets): Ordered set manipulation
- library(pairs): Operations on key-value lists
- library(persistency): Provide persistent dynamic predicates
- library(pio): Pure I/O
- library(predicate_options): Declare option-processing of predicates
- library(prolog_jiti): Just In Time Indexing (JITI) utilities
- library(prolog_pack): A package manager for Prolog
- library(prolog_xref): Prolog cross-referencer data collection
- library(quasi_quotations): Define Quasi Quotation syntax
- library(random): Random numbers
- library(readutil): Read utilities
- library(record): Access named fields in a term
- library(registry): Manipulating the Windows registry
- library(settings): Setting management
- library(simplex): Solve linear programming problems
- library(solution_sequences): Modify solution sequences
- library(thread): High level thread primitives
- library(thread_pool): Resource bounded thread management
- library(ugraphs): Unweighted Graphs
- library(url): Analysing and constructing URL
- library(varnumbers): Utilities for numbered terms
- library(yall): Lambda expressions

- The SWI-Prolog library
- Packages

- Reference manual

- To be done
- This is just a starting point. We need a comprehensive set of generally useful DCG primitives.

This library provides various commonly used DCG primitives acting on
list of character **codes**. Character classification is based on
code_type/2.

This module started its life as `library(http/dcg_basics)`

to support the HTTP protocol. Since then, it was increasingly used in
code that has no relation to HTTP and therefore this library was moved
to the core library.

- [det]
**string_without**(`+EndCodes, -Codes`)`//`

- Take as many codes from the input until the next character code appears
in the list
`EndCodes`. The terminating code itself is left on the input. Typical use is to read upto a defined delimiter such as a newline or other reserved character. For example:..., string_without("\n", RestOfLine)

`EndCodes`is a list of character codes. - See also
- string//1.

- [nondet]
**string**(`-Codes`)`//`

- Take as few as possible tokens from the input, taking one more each time
on backtracking. This code is normally followed by a test for a
delimiter. For example:
upto_colon(Atom) --> string(Codes), ":", !, { atom_codes(Atom, Codes) }.

- See also
- string_without//2.

- [det]
**blanks**`//`

- Skip zero or more white-space characters.
- [semidet]
**blank**`//`

- Take next
`space`

character from input. Space characters include newline.- See also
- white//0

- [det]
**nonblanks**(`-Codes`)`//`

- Take all
`graph`

characters - [semidet]
**nonblank**(`-Code`)`//`

`Code`is the next non-blank (`graph`

) character.- [semidet]
**blanks_to_nl**`//`

- Take a sequence of blank//0 codes if blanks are followed by a newline or end of the input.
- [det]
**whites**`//`

- Skip white space
*inside*a line.- See also
- blanks//0 also skips newlines.

- [semidet]
**white**`//`

- Take next
`white`

character from input. White characters do*not*include newline. - [semidet]
**alpha_to_lower**(`?C`)`//`

- Read a letter (class
`alpha`

) and return it as a lowercase letter. If`C`is instantiated and the DCG list is already bound,`C`must be`lower`

and matches both a lower and uppercase letter. If the output list is unbound, its first element is bound to`C`. For example:?- alpha_to_lower(0'a, `AB`, R). R = [66]. ?- alpha_to_lower(C, `AB`, R). C = 97, R = [66]. ?- alpha_to_lower(0'a, L, R). L = [97|R].

- [det]
**digits**(`?Chars`)`//`

- [det]
**digit**(`?Char`)`//`

- [det]
**integer**(`?Integer`)`//`

- Number processing. The predicate digits//1 matches a posibly empty set of digits, digit//1 processes a single digit and integer processes an optional sign followed by a non-empty sequence of digits into an integer.
- [det]
**float**(`?Float`)`//`

- Process a floating point number. The actual conversion is controlled by number_codes/2.
- [det]
**number**(`+Number`)`//`

- [semidet]
**number**(`-Number`)`//`

- Generate extract a number. Handles both integers and floating point numbers.
- [det]
**xinteger**(`+Integer`)`//`

- [semidet]
**xinteger**(`-Integer`)`//`

- Generate or extract an integer from a sequence of hexadecimal digits. Hexadecimal characters include both uppercase (A-F) and lowercase (a-f) letters. The value may be preceeded by a sign (+/-)
- [semidet]
**xdigit**(`-Weight`)`//`

- True if the next code is a hexdecimal digit with
`Weight`.`Weight`is between 0 and 15. Hexadecimal characters include both uppercase (A-F) and lowercase (a-f) letters. - [det]
**xdigits**(`-WeightList`)`//`

- List of weights of a sequence of hexadecimal codes.
`WeightList`may be empty. Hexadecimal characters include both uppercase (A-F) and lowercase (a-f) letters. **eos**`//`

- Matches end-of-input. The implementation behaves as the following
portable implementation:
eos --> call(eos_). eos_([], []).

- To be done
- This is a difficult concept and violates the
*context free*property of DCGs. Explain the exact problems.

**remainder**(`-List`)`//`

- Unify
`List`with the remainder of the input. - [semidet]
**prolog_var_name**(`-Name:atom`)`//`

- Matches a Prolog variable name. Primarily intended to deal with quasi quotations that embed Prolog variables.
- [det]
**atom**(`++Atom`)`//`

- Generate codes of
`Atom`. Current implementation uses write/1, dealing with any Prolog term.`Atom`must be ground though.

Tag confusing pages with **doc-needs-help**|Tags are associated to your profile if you are logged in

Tags: