User Tools

Site Tools


semantics_specification

This is an old revision of the document!


General considerations

  • native函数、普通函数、record名字,都不能重名,他们之间也不能重名
  • record的fields也不能重名(但可以和record本身同名,或与其他函数同名)
  • 函数内变量之间不能重名,与top level的native函数、普通函数、record名字也不能重名
  • continue和break必须在循环里(for或者while)
  • return的表达式类型与函数返回类型一致
  • 不需要检查函数所有control flow末端是否都有return语句
  • if/while/for的条件(cond)类型必须是int(0表示false,非零表示true)
  • [expr]前面必须是string或array,expr必须是int

Operator types

类型映射 说明
, (a,b)→b
= (a,a)→a null是任意record type
|| and && (int,int)→{0,1} 短路逻辑
== and != (a,a)→{0,1} record的比较是比较地址而不是值
字符串比较的是值而不是地址
<, <=, > and >= (a,a)→{0,1} 不能比较record
字符串按字典序比较
+ 见加法类型表
-, *, / and % (int,int)→int 不需要检查是否除零
! int→{0,1}
+ and - int→int 一元运算仅适合int类型
加法类型表 Right-hand side
int char string record
Left-hand side int int int string (error)
char int int string (error)
string string string string (error)
record (error) (error) (error) (error)

Native function semantics

char chr(int i) 只取参数的低8位
int ord(char c)
semantics_specification.1330098206.txt.gz · Last modified: 2012/02/24 15:43 by xjia

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki