首页> 外文学位 >Speaking for the Trees: a New (Old) Approach to Languages and Syntax.
【24h】

Speaking for the Trees: a New (Old) Approach to Languages and Syntax.

机译:为树木说话:一种新的(旧的)语言和语法方法。

获取原文
获取原文并翻译 | 示例

摘要

Programmers in many fields are interested in building new languages. In the same way that high-level languages increase productivity by allowing programmers to accomplish more with a given amount of code, a special-purpose language can reduce repetitive code and hide implementation detail, making a program's structure and function more evident. Sometimes an entire new language is called for, and other times an existing language serves most needs but could benefit from a few additional elements. However, current tools support this kind of extension poorly.;Language tools typically represent programs internally as trees which are easily extended with new types of nodes. However, in today's languages the programmer only indirectly manipulates this tree---through a parser which analyzes free-form text (that is, concrete syntax) and builds an abstract syntax tree (AST). The limitations of parsers make languages difficult to extend and severely constrain the choice of notation. In other words, what one writes and reads is dictated by what the parser is able to handle.;I explore an alternative approach: represent source code directly as an AST and derive both an executable program and a readable presentation from it. I present a flexible representation for ASTs, a general mechanism for transforming these trees, and a language for grammars which allows concrete syntax and semantics to be defined via these transformations. I show that this approach is modular, easy to understand, and expressive enough to define novel syntax and semantics.;My prototype system, Lorax, demonstrates the new approach. Reductions for presentation and execution are written in a functional language with meta-programming features. Syntax is not limited to simple text but may include richer notation for easier reading and understanding. A structure editor renders this rich syntax, using algorithms from TeX. In Lorax, the barrier to entry for the creation of languages is lowered, making it practical for programmers to express solutions in the terms and the notation which are closest to the problem domain.
机译:许多领域的程序员都对构建新语言感兴趣。与高级语言通过允许程序员使用给定数量的代码完成更多工作来提高生产率一样,一种特殊用途的语言可以减少重复的代码并隐藏实现细节,从而使程序的结构和功能更加明显。有时,需要一种全新的语言,而其他时候,一种现有的语言可以满足大多数需求,但可以从一些其他元素中受益。但是,当前的工具对这种扩展的支持很差。语言工具通常在内部将程序表示为树,这些树很容易通过新型节点进行扩展。但是,在当今的语言中,程序员只能通过解析器间接地操作此树-通过解析器分析自由格式的文本(即,具体语法)并构建抽象语法树(AST)。解析器的局限性使得语言难以扩展,并严重限制了符号的选择。换句话说,一个人的读写是由解析器能够处理的决定的。我提供了AST的灵活表示形式,用于转换这些树的通用机制以及用于通过这些转换定义具体语法和语义的语法语言。我证明了这种方法是模块化的,易于理解的,并且具有足够的表达能力来定义新颖的语法和语义。我的原型系统Lorax演示了这种新方法。使用具有元编程功能的功能性语言来编写表示和执行的缩减内容。语法不仅限于简单的文本,还可以包含更丰富的符号,以便于阅读和理解。结构编辑器使用TeX的算法来呈现这种丰富的语法。在Lorax中,降低了创建语言的入门门槛,使程序员可以用最接近问题域的术语和符号表示解决方案。

著录项

  • 作者

    Prescott, Moss.;

  • 作者单位

    University of Colorado at Boulder.;

  • 授予单位 University of Colorado at Boulder.;
  • 学科 Computer science.
  • 学位 M.S.
  • 年度 2010
  • 页码 78 p.
  • 总页数 78
  • 原文格式 PDF
  • 正文语种 eng
  • 中图分类
  • 关键词

  • 入库时间 2022-08-17 11:37:08

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号