r4 - 01 Mar 2007 - 22:28:08 - Yuri KlimovYou are here: TWiki >  Refaldevel Web > AbstractImperativeLanguage

ASAIL

Версия на 10.02.2007

t.module := (MODULE (e.module-name) e.module-body)

e.module-name := ???

e.module-body := t.module-item*

t.module-item :=
      (FUNC s.linkage t.func-name (e.args) (e.ress) e.body)
    | (FUNC? s.linkage t.func-name (e.args) (e.ress) e.body)
    | (OBJ s.linkage s.tag t.obj-name)
    | (CONSTEXPR s.linkage t.const-name (e.comment) e.const-expr)
    | (DECL-OBJ t.obj-name)
    | (DECL-FUNC t.func-name)
    | (TRACE t.trace-name)

e.body := t.body-item*

t.body-item :=
      (DECL s.var-type t.var)
    | (ASSIGN t.var e.ref-expr)
    | (INT t.var e.int-expr)
    | (EXPR t.var e.ref-expr)
    | (DEREF t.var e.ref-expr (e.int-expr))
    | (SUBEXPR t.var e.ref-expr (e.int-expr) (e.int-expr))
    | (LSPLIT e.ref-expr (e.int-expr) t.var t.var)
    | (RSPLIT e.ref-expr (e.int-expr) t.var t.var)
    | (IF-INT-CMP s.cmp-op (e.int-expr) (e.int-expr) e.body)
    | (IF t.cond e.body)
    | (FOR (e.label) (e.label) () (e.step) e.body)
    | (LABEL (t.label) e.body)
    | (CONTINUE t.label)
    | (BREAK t.label)
    | RETFAIL
    | (CALL t.func-name (e.ref-exprs) (e.ress))
    | (TAILCALL t.func-name (e.ref-exprs) (e.ress))
    | (TAILCALL? t.func-name (e.ref-exprs) (e.ress))
    | (TRY e.body)
    | (CATCH-ERROR e.body)
    | FATAL
    | (ERROR e.expr)

e.ref-exprs := (e.ref-expr)*

e.ref-expr := t.ref-term*

t.ref-term :=
      (PAREN e.ref-expr)
    | (DEREF e.ref-expr (e.int-expr))
    | (SUBEXPR e.ref-expr (e.int-expr) (e.int-expr))
    | (REF (s.module s.name))
    | (STATIC (e))
    | ERROR-EXPR 
    | t.var

e.int-exprs := (e.int-expr)*

e.int-expr :=
      s.Integer
    | (LENGTH e.ref-expr)
    | (MIN (e.int-expr) (e.int-expr))
    | (MAX (e.int-expr) (e.int-expr))
    | (INFIX s.infix-op e.int-exprs)
    | t.var
    | e.int-expr*

s.infix-op :=
      "+"
    | "-"
    | "%"
    | "*"
    | "/"

t.cond :=
      (CALL-FAILS (CALL t.func-name (e.ref-exprs) (e.ress)))
    | (SYMBOL? e.ref-expr (e.int-expr))
    | (ITER-FAILS e.ref-expr)
    | (EQ e.ref-expr (e.ref-expr) (e.int-expr))
    | (TERM-EQ e.ref-expr (e.ref-expr) (e.int-expr))
    | (NOT t.cond)

s.linkage :=
      LOCAL
    | EXPORT

s.var-type :=
      Expr
    | Result

e.step :=
      /*empty*/
    | (INC-ITER e.ref-expr)
    | (DEC-ITER e.ref-expr)

s.cmp-op :=
      "!="
    | "<"
    | ">"

e.args := t.var*
e.ress := t.var*

t.var :=
      VAR e
    | SVAR e
    | TVAR e
    | EVAR e
    | VVAR e

e.label := /*empty*/ | t.label

t.label := unknown

t.func-name := (s.module-name s.func-name)
t.const-name := ???
t.obj-name := ???
t.trace-name := ???

t.obj-const-name :=
      t.obj-name
    | t.const-name

e.const-expr :=
      /*empty*/
    | (SUBEXPR t.obj-const-name s.int s.int)
    | t.const-term*

t.const-term :=
      s.char
    | (PAREN e.const-expr)
    | t.obj-const-name
    | (FUNC t.func-name)
    | (FUNC? t.func-name)
    | s.int
    | s.word

Предложения по улучшению

t.module := (MODULE (e.moduleName) e.moduleItems)

e.moduleItems := t.moduleItem*
t.moduleItem :=
      (FUNC s.linkage t.funcName (e.vars) (e.vars) e.body)
    | (OBJ s.linkage t.objName t.refExpr)
    | (TRACE t.funcName)

e.body := t.bodyItem*
t.bodyItem :=
      (DECL t.var)
    | (ASSIGN t.var t.expr)
    | (BLOCK t.labelId e.body)
    | (BREAK t.labelId)
    | (SPLIT s.splitType t.refExpr t.intExpr t.var t.var e.body)
    | (LOOP e.body)
    | (IF t.cond e.body)
    | (CALL s.callType t.qualifiedFuncName (e.refExprs) (e.vars))
    | RETFAIL
    | (TRY e.body (t.var e.body))
    | (ERROR t.refExpr)

t.cond :=
      (CALLFAILS t.qualifiedFuncName  (e.refExprs) (e.vars))
    | (ISSYMBOL t.refExpr t.intExpr)
    | (EQ t.refExpr t.refExpr t.intExpr)
    | (TERMEQ t.refExpr t.refExpr t.intExpr)
    | (CMP s.cmpOp t.intExpr t.intExpr)
    | (NOT t.cond)

t.refExpr := (t.elemRefExpr*)
t.elemRefExpr :=
      s.value
    | (PAREN t.refExpr)
    | (FUNC t.qualifiedFuncName)
    | (DEREF t.refExpr t.intExpr)
    | (SUBEXPR t.refExpr t.intExpr t.intExpr)
    | (OBJ t.qualifiedObjName)
    | (VAR t.var)

t.intExpr :=
      s.int
    | (VAR t.var)
    | (LENGTH t.refExpr)
    | (OP s.intOp t.intExpr t.intExpr)

e.moduleName := s.name*

s.linkage := LOCAL | EXPORT

t.funcName := (s.funcType t.name)
t.qualifiedFuncName := (s.funcType e.moduleName t.name)
s.funcType := FUNC | FUNC?

t.objName := (s.objType t.name)
t.qualifiedObjName := (s.objType e.moduleName t.name)
s.objType := BOX | CHANNEL | STRING | TABLE | VECTOR | EXPR

t.name := s.name | (e.any) -- для объектов/констант, сгенерированных компилятором.

t.expr := t.refExpr | t.intExpr

e.refExprs := t.refExpr*

e.vars := t.var*
t.var := (s.varType t.varId)
s.varType := EXPR | RESULT | INT

s.splitType := L | R

s.callType := CALL | TAILCALL

s.cmpOp := NE | GT | LT

s.intOp := ADD | SUB | MUL | DIV | REM | MIN | MAX

t.labelId := unknown

t.varId := unknown
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
R+

This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback