ACDK白皮书-AAL语言

ACDK白皮书-AAL语言

      

翻译:薛长宇
 

关于AAL语言(Artefaktur Aspects Language)的思想(因为这个语言还在初始开发阶段)

 

本章内容:

 

   整体概念

     前言

     AAL ACDK

     编译/解释

     DMI 集成

   AAL语言定义

     基础

     /弱类型绑定

     语言特性

       面向对象特性

       方法

       异常

       选择和循环

       其他

   AAL 编译器

     编译器审查

     编译器被集成在 AAL

     编译器框架

 

 

整体概念

前言

AAL作为一个基本的语言使用起来十分类似于java,但是有一些主要特性的增加。

A very powerfull feature of Lisp is the fact, that most language constructs which are hard wired in most language are simply also implemented inside the language itself. A simple if condition is just also implemented in Lisp. On a simplified view if is just an function which takes 2 or 3 arguments.

(if condition_expression then_expression else_expression).

This is also possible because Lisp has a very small core syntax definition - all programm and data are organized in lists. Unfortunatelly this fact give the universal power of lisp, but make it also quite hard to read. In higher languages different things are expressed with different syntax elements.

Semantik and syntax can express specific idiomatics.

 

举个例子:Perl中使用正则表达式是很容易的事情,因为它与其他的语言特性是相同的

 

在传统的语言中,例如javaC++,正则表达式是通过使用库函数来实现的.

AAL 的正则表达式中可以不仅仅具备普通的功能应该可以有特别的语法

使用接口可以编译/解释自己,这可以使用户在编译/运行的时候定义新的语法结构成为可能

 

AAL ACDK

 

    * AAL 语言基于并且运行在 ACDK.

    * AAL 可以实现 ACDK接口.

    * AAL 接口可以被ACDK类实现

    * 所有的 DMI 服务器和客户端都可以实现.

 

 

 编译/解释

 

    * 直接解释.

    * Compiler for C++ (ACDK)

    * Compiler for Java VM

    * Compiler for .NET VM

 

 

DMI 集成

一个好的功能就是可以允许几种语言在一个源代码中通过使用标记.

解释器可以是用这些标记选择适当的执行方式

 

 AAL 语言定义

 基础

语言将跟随 the ACDK/Java/C#/Python paradigma.

 

 /弱类型绑定

ALS 将支持类型和类型之间的绑定.

 

void foo(AClass cls); // 强类型

void foo(cls); // 若类型

void bar()

{

  AClass acls = new AClass();

  o = new AClass();

  foo(acls); // select first version

  foo(o); // select second version

  foo((AClass)o); // select first version

  o.method(); // uses invoke

  acls.method(); // uses direct method call

}

 

 

 语言特性

 

Preprocessor / Aspects

 

    *基本预处理程序完全可以使用

    * 语言机手可以被挂接到方法调用,等等.

      或许可能被连接到属性.

 

Unit 概念

 

    * Units, 类似于Java modell.

 

 

类型 Modell

 

    * 只要可能,堆栈的性能优先考虑.

    * ByVal 实例化.

    * 允许分别声明和定义(执行).

    * in, out, inout, byval 变量方向

 

 

 面向对象特性

 

    * 具有接口和父类的类

    * 属性以这一个类为连接

    * 构造函数/析构函数

    * 静态方法

    * 公有/私有

    * extending/overwriting 类使用类似于面向对象C / Smalltalk.方法

    * 匿名类

    * lamda表达式

    * 委托.

    * 信号/Slot

 

 

 方法

 

    * 自由的标准方法.

    * 多台函数.

    * 默认参数.

    * 对于太多的参数将使用收集来使他们可以访问.

    * 命名参数(在调用者或者被调用者方)

    * 用户自定义操作类似于 C++.

 

 

 异常

 

    *全部以异常为特色有目的子句处理.

 

 

选择和循环

 

    * 类似于 C++/Java

    * foreach 构造

 

 

 其他

 

    * RegExp(正则表达式处理包)作为语法元素

 

 

 

 AAL 编译器

编译器审查

 

   1. 文件表达式分析器检测语法声明.

   2. 语言表达式分析器构建语法树

   3. 连接器的决定使用语法树作为参考

   4. 翻译为其他代码或者执行

 

编译器被集成在 AAL

 

通过AAL语言编译器自己在编译时刻AAL编译器自己将可以被访问和扩展. 它可以用来去学习新的语言结构.

编译器构造应该有相同的范围规定类似于类型

 

定义新的操作的例子:

 

String add2Strings(String s1, String s2)

{

  StringBuffer sb(s1.length() + s2.length());

  sb.append(s1); sb.append(s2);

  return sb.toString();

}

 

void foo()

{

  asl.compiler.addOperator("<<", BinaerOperator);

  String s1 = "Hallo ";

  String s3 = s1 << "AAL";

}

 

 

定义新的 looptype的例子:

 

class MyKeywordParser

implements asl.compiler.KeywordParser

{

  void parse(asl.compiler.Parser p, asl.compiler.TreeNode cnode, TextScanner scanner)

  {

    // parse text until finished

  }

}

void foo()

{

   asl.compiler.addKeyword("mykeyword", new MyKeywordParser());

   mykeyword (ch, new String("asdf"))

   {

 

   }

}

backtick操作可能被用来去评估代码碎片在其他的编译器或者解释器

 

void foo()

{

  lisp = new LispCompiler();

  int i = 2;

 

  int j = lisp(` (+ $i 3)`);

}

 

 

 编译器框架

 

class Type

{

};

 

class Variable

{

  Type getType();

};

 

class Expression

{

  Type getResultType();

};

 

class Code

{

};

 

 

class Statement

extends Code

{

};

 

class CodeBlock

extends Code

{

 

};

 

interface CodeInterface

{

};

 

interface Function

implements CodeInterface

{

};

 

class ForStatement

extends Statement

implements CodeInterface

{

 

};

 

class Unit

{

};

 

class Function

extends Type

implements CodeInterface

{

};

 

class Interface

extends Type

implements CodeInterface // for constructors

{

};

 

class Class

extends Interface

{

};

 

class Scanner

{

};

 
很对不起大家,这个文章没有翻译完,中间有一段没有翻译,主要原因是翻译的时候不能肯定原文的意义,又不想翻译错了误导大家 :P,本人外语水平是在有限,sorry

翻译:薛长宇
changning@ynmail.com
2004-12

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值