A research C# compiler

David R. Hanson, Todd A Proebsting

Research output: Contribution to journalArticle

5 Citations (Scopus)

Abstract

C# is the new flagship language in the Microsoft .NET platform. C# is an attractive vehicle for language design research not only because it shares many characteristics with Java, the current language of choice for such research, but also because it is likely to see wide use. Language research needs a large investment in infrastructure, even for relatively small studies. This paper describes a new C# compiler designed specifically to provide that infrastructure. The overall design is deceptively simple. The parser is generated automatically from a possibly ambiguous grammar, accepts C# source, perhaps with new features, and produces an abstract syntax tree, or AST. Subsequent phases - dubbed visitors - traverse the AST, perhaps modifying it, annotating it or emitting output, and pass it along to the next visitor. Visitors are specified entirely at compilation time and are loaded dynamically as needed. There is no fixed set of visitors, and visitors are completely unconstrained. Some visitors perform traditional compilation phases, but the more interesting ones do code analysis, emit non-traditional data such as XML, and display data structures for debugging. Indeed, most usage to date has been for tools, not for language design experiments. Such experiments use source-to-source transformations or extend existing visitors to handle new language features. These approaches are illustrated by adding a statement that switches on a type instead of a value, which can be implemented in a few hundred lines. The compiler also exemplifies the value of dynamic loading and of type reflection.

Original languageEnglish (US)
Pages (from-to)1211-1224
Number of pages14
JournalSoftware - Practice and Experience
Volume34
Issue number13
DOIs
StatePublished - Nov 10 2004
Externally publishedYes

Fingerprint

XML
Data structures
Experiments
Display devices
Switches

Keywords

  • .NET
  • Abstract syntax trees;
  • C# programming language
  • Compiler architecture
  • Object-oriented programming
  • Visitor pattern

ASJC Scopus subject areas

  • Computer Graphics and Computer-Aided Design
  • Software

Cite this

A research C# compiler. / Hanson, David R.; Proebsting, Todd A.

In: Software - Practice and Experience, Vol. 34, No. 13, 10.11.2004, p. 1211-1224.

Research output: Contribution to journalArticle

Hanson, David R. ; Proebsting, Todd A. / A research C# compiler. In: Software - Practice and Experience. 2004 ; Vol. 34, No. 13. pp. 1211-1224.
@article{e5601c39d8174ee29417f8e5790314c8,
title = "A research C# compiler",
abstract = "C# is the new flagship language in the Microsoft .NET platform. C# is an attractive vehicle for language design research not only because it shares many characteristics with Java, the current language of choice for such research, but also because it is likely to see wide use. Language research needs a large investment in infrastructure, even for relatively small studies. This paper describes a new C# compiler designed specifically to provide that infrastructure. The overall design is deceptively simple. The parser is generated automatically from a possibly ambiguous grammar, accepts C# source, perhaps with new features, and produces an abstract syntax tree, or AST. Subsequent phases - dubbed visitors - traverse the AST, perhaps modifying it, annotating it or emitting output, and pass it along to the next visitor. Visitors are specified entirely at compilation time and are loaded dynamically as needed. There is no fixed set of visitors, and visitors are completely unconstrained. Some visitors perform traditional compilation phases, but the more interesting ones do code analysis, emit non-traditional data such as XML, and display data structures for debugging. Indeed, most usage to date has been for tools, not for language design experiments. Such experiments use source-to-source transformations or extend existing visitors to handle new language features. These approaches are illustrated by adding a statement that switches on a type instead of a value, which can be implemented in a few hundred lines. The compiler also exemplifies the value of dynamic loading and of type reflection.",
keywords = ".NET, Abstract syntax trees;, C# programming language, Compiler architecture, Object-oriented programming, Visitor pattern",
author = "Hanson, {David R.} and Proebsting, {Todd A}",
year = "2004",
month = "11",
day = "10",
doi = "10.1002/spe.610",
language = "English (US)",
volume = "34",
pages = "1211--1224",
journal = "Software - Practice and Experience",
issn = "0038-0644",
publisher = "John Wiley and Sons Ltd",
number = "13",

}

TY - JOUR

T1 - A research C# compiler

AU - Hanson, David R.

AU - Proebsting, Todd A

PY - 2004/11/10

Y1 - 2004/11/10

N2 - C# is the new flagship language in the Microsoft .NET platform. C# is an attractive vehicle for language design research not only because it shares many characteristics with Java, the current language of choice for such research, but also because it is likely to see wide use. Language research needs a large investment in infrastructure, even for relatively small studies. This paper describes a new C# compiler designed specifically to provide that infrastructure. The overall design is deceptively simple. The parser is generated automatically from a possibly ambiguous grammar, accepts C# source, perhaps with new features, and produces an abstract syntax tree, or AST. Subsequent phases - dubbed visitors - traverse the AST, perhaps modifying it, annotating it or emitting output, and pass it along to the next visitor. Visitors are specified entirely at compilation time and are loaded dynamically as needed. There is no fixed set of visitors, and visitors are completely unconstrained. Some visitors perform traditional compilation phases, but the more interesting ones do code analysis, emit non-traditional data such as XML, and display data structures for debugging. Indeed, most usage to date has been for tools, not for language design experiments. Such experiments use source-to-source transformations or extend existing visitors to handle new language features. These approaches are illustrated by adding a statement that switches on a type instead of a value, which can be implemented in a few hundred lines. The compiler also exemplifies the value of dynamic loading and of type reflection.

AB - C# is the new flagship language in the Microsoft .NET platform. C# is an attractive vehicle for language design research not only because it shares many characteristics with Java, the current language of choice for such research, but also because it is likely to see wide use. Language research needs a large investment in infrastructure, even for relatively small studies. This paper describes a new C# compiler designed specifically to provide that infrastructure. The overall design is deceptively simple. The parser is generated automatically from a possibly ambiguous grammar, accepts C# source, perhaps with new features, and produces an abstract syntax tree, or AST. Subsequent phases - dubbed visitors - traverse the AST, perhaps modifying it, annotating it or emitting output, and pass it along to the next visitor. Visitors are specified entirely at compilation time and are loaded dynamically as needed. There is no fixed set of visitors, and visitors are completely unconstrained. Some visitors perform traditional compilation phases, but the more interesting ones do code analysis, emit non-traditional data such as XML, and display data structures for debugging. Indeed, most usage to date has been for tools, not for language design experiments. Such experiments use source-to-source transformations or extend existing visitors to handle new language features. These approaches are illustrated by adding a statement that switches on a type instead of a value, which can be implemented in a few hundred lines. The compiler also exemplifies the value of dynamic loading and of type reflection.

KW - .NET

KW - Abstract syntax trees;

KW - C# programming language

KW - Compiler architecture

KW - Object-oriented programming

KW - Visitor pattern

UR - http://www.scopus.com/inward/record.url?scp=8344237443&partnerID=8YFLogxK

UR - http://www.scopus.com/inward/citedby.url?scp=8344237443&partnerID=8YFLogxK

U2 - 10.1002/spe.610

DO - 10.1002/spe.610

M3 - Article

VL - 34

SP - 1211

EP - 1224

JO - Software - Practice and Experience

JF - Software - Practice and Experience

SN - 0038-0644

IS - 13

ER -