License: Creative Commons Attribution 3.0 Unported license (CC BY 3.0)
When quoting this document, please refer to the following
DOI: 10.4230/OASIcs.SLATE.2019.7
URN: urn:nbn:de:0030-drops-108743
URL: http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2019/10874/
Nogatz, Falco ;
Seipel, Dietmar ;
Abreu, Salvador
Definite Clause Grammars with Parse Trees: Extension for Prolog
Abstract
Definite Clause Grammars (DCGs) are a convenient way to specify possibly non-context-free grammars for natural and formal languages. They can be used to progressively build a parse tree as grammar rules are applied by providing an extra argument in the DCG rule's head. In the simplest way, this is a structure that contains the name of the used nonterminal. This extension of a DCG has been proposed for natural language processing in the past and can be done automatically in Prolog using term expansion.
We extend this approach by a meta-nonterminal to specify optional and sequences of nonterminals, as these structures are common in grammars for formal, domain-specific languages. We specify a term expansion that represents these sequences as lists while preserving the grammar's ability to be used both for parsing and serialising, i.e. to create a parse tree by a given source code and vice-versa. We show that this mechanism can be used to lift grammars specified in extended Backus-Naur form (EBNF) to generate parse trees. As a case study, we present a parser for the Prolog programming language itself based only on the grammars given in the ISO Prolog standard which produces corresponding parse trees.
BibTeX - Entry
@InProceedings{nogatz_et_al:OASIcs:2019:10874,
author = {Falco Nogatz and Dietmar Seipel and Salvador Abreu},
title = {{Definite Clause Grammars with Parse Trees: Extension for Prolog}},
booktitle = {8th Symposium on Languages, Applications and Technologies (SLATE 2019)},
pages = {7:1--7:14},
series = {OpenAccess Series in Informatics (OASIcs)},
ISBN = {978-3-95977-114-6},
ISSN = {2190-6807},
year = {2019},
volume = {74},
editor = {Ricardo Rodrigues and Jan Janousek and Lu{\'\i}s Ferreira and Lu{\'\i}sa Coheur and Fernando Batista and Hugo Gon{\c{c}}alo Oliveira},
publisher = {Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik},
address = {Dagstuhl, Germany},
URL = {http://drops.dagstuhl.de/opus/volltexte/2019/10874},
URN = {urn:nbn:de:0030-drops-108743},
doi = {10.4230/OASIcs.SLATE.2019.7},
annote = {Keywords: Definite Clause Grammar, Prolog, Term Expansion, Parse Tree, EBNF}
}
Keywords: |
|
Definite Clause Grammar, Prolog, Term Expansion, Parse Tree, EBNF |
Collection: |
|
8th Symposium on Languages, Applications and Technologies (SLATE 2019) |
Issue Date: |
|
2019 |
Date of publication: |
|
24.07.2019 |
Supplementary Material: |
|
The source codes of library(dcg4pt) and library(plammar) are available on GitHub at https://github.com/fnogatz/dcg4pt and https://github.com/fnogatz/plammar (MIT License). |