ASTLOG(ID:3737/ast003)


for Abstract Syntax Tree proLOG

Roger F Crew, Microsoft Research, 1997

Variant on Prolog that can read abstract syntax trees as a database natively, obviating the necessity of translating source data into the form f a regular Prolog database.


Structures:
Related languages
Prolog => ASTLOG   Augmentation of

References:
  • R.F. Crew, "ASTLOG: A Language for Examining Abstract Syntax Trees" pp229-242 view details Abstract: We desired a facility for locating/analyzing syntactic artifacts in abstract syntax trees of C/C++ programs, similar to the facility grep or awk provides for locating artifacts at the lexical level. Prolog, with its implicit pattern-matching and backtracking capabilities, is a natural choice for such an application. We have developed a Prolog variant that avoids the overhead of translating the source syntactic structures into the form of a Prolog database; this is crucial to obtaining acceptable performance on large programs. An interpreter for this language has been implemented and used to find various kinds of syntactic bugs and other questionable constructs in real programs like Microsoft SQL server (450Klines) and Microsoft Word (2Mlines) in time comparable to the runtime of the actual compiler. The model in which terms are matched against an implicit current object, rather than simply proven against a database of facts, leads to a distinct "inside-out functional" programming style that is quite unlike typical Prolog, but one that is, in fact, well-suited to the examination of trees. Also, various second-order Prolog set-predicates may be implemented via manipulation of the current object, thus retaining an important feature without entailing that the database be dynamically extensible as the usual implementation does. ps
          in Proceedings of the USENIX Conference on Domain-Specific Languages, Berkeley, CA, October 15–17 1997. J. C. Ramming, editor. USENIX Association view details