Did you know ... Search Documentation:
Pack bibtex -- prolog/bibtex_dcg.pl
PublicShow source

DCG rules that can parse BibTeX elements.

In this text, a pseudo-EBNF syntax is used to explain some structures.

BibTeX entry format and token names

The following illustrates a BibTex entry and its format. The name of each element is used as a DCG rule's predicate name.

"@" name "{" label ","
    field ","
    field ","
    ...
"}"

Each field's format is as follows:

key "= {" value "},"

Important fields

Fields like author and keywords have their own format. DCG rules for them are included here. However, consult the bibtex_fields library for more information.

Author value

The author field format is as follows:

`author "and" author "and" author "and" ...`

There are two possible formats for each author's name:

  • `surname "," name`
  • `name surname`

Keywords

Keywords are phrases written in the article. There are other fields that use the same syntaxs for user-defined keywords.

The format is the same:

`a_phrase "," a_phrase "," ...`

The keywords separators supported are "," and ";". They can be mixed.

Important terms

  • entry/3 is entry(Name: term, Label: string, LstField: list).
  • field/2 is field(Key: atom, Value: string). @author Gimenez, Christian @license GPLv3
 entry(-Entry:pred)//
Return an entry/3 term corresponding with the codes parsed.
Arguments:
Entry- entry(Name:atom, Label:string, Lst: list).
See also
- field//2
 field(-Key:codes, -Value:codes)// is det
Return the Key = Value field from a bibtex field.
 fields(-Lst:list)// is det
Return a list of field/2 terms parsed from a bibtex fields string. Each element format is field(+Key: atom, +Value: string).
 author(-Surname:list, -Name:list)//
Two types of author field's value:
  • Surnames, Names
  • Name Surname
  • Names Surname
 authors(-Lst:list)//
Process a list of authors (i.e. author field value). Use it with a value string only.
Arguments:
Lst- is a list of author/2 terms: author(Surname:string, Name:string).
 k_sep(?Char:char)
True iff char is considered as separators.
 keyword_sep(-Keywords:list)//
True iff Keywords is a list of keywords parsed from the input. The separator should be one of k_sep/1.
Arguments:
Keywords- a list of strings.
See also
- keyword_spaces//1
 keyword_spaces(-Keywords:list)//
Retrieve all the keywords using spaces as separator.
Arguments:
Keywords- is a list of string codes.