附录 D: UNOIDL 语法规范
From Apache OpenOffice Wiki
< Zh | Documentation
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
以下列表以伪 BNF 表示法 列出 UNOIDL 语言规范的各个组成部分。
idl-specification ::= declaration+
declaration ::= enum-decl
| plain-struct-decl
| poly-struct-template-decl
| exception-decl
| interface-forward-decl
| interface-decl
| typedef-decl
| constant-decl
| constants-decl
| module-decl
| interface-service-decl
| accumulated-service-decl
| interface-singleton-decl
| service-singleton-decl
enum-decl ::= ["published"] "enum" identifier "{" enum-member-decl ("," enum-member-decl)* "}" ";"
enum-member-decl ::= identifier ["=" expr]
plain-struct-decl ::= ["published"] "struct" identifier [single-inheritance] "{" struct-member-decl+ "}" ";"
single-inheritance ::= ":" name
struct-member-decl ::= type identifier ";"
poly-struct-template-decl ::= ["published"] "struct" identifier struct-params
"{" poly-struct-member-decl+ "}" ";"
struct-params ::= "<" identifier ("," identifier)* ">"
poly-struct-member-decl ::= struct-member-decl | parametric-member-decl
parametric-member-decl ::= identifier identifier ";"
exception-decl ::= ["published"] "exception" identifier [single-inheritance] "{" struct-member-decl+ "}" ";"
interface-forward-decl ::= ["published"] "interface" identifier ";"
interface-decl ::= ["published"] "interface" identifier [single-inheritance] "{" interface-member-decl* "}" ";"
interface-member-decl ::= interface-inheritance-decl | attribute-decl | method-decl
interface-inheritance-decl ::= ["[" "optional" "]"] "interface" name ";"
attribute-decl ::= attribute-flags type identifier ["{" attribute-access-decl* "}"] ";"
attribute-flags ::= "[" (attribute-flag ",")* "attribute" ("," attribute-flag)* "]"
attribute-flag ::= "bound" | "readonly"
attribute-access-decl ::= attribute-get-decl | attribute-set-decl
attribute-get-decl ::= "get" exception-spec ";"
attribute-set-decl ::= "set" exception-spec ";"
exception-spec ::= "raises" "(" name ("," name)* ")"
method-decl ::= ["[" "oneway" "]"] type identifier "(" [method-param ("," method-param)*] ")" [exception-spec]
method-param ::= "[" direction "]" type identifier
direction ::= "in" | "out" | "inout"
typedef-decl ::= ["published"] "typedef" type identifier ";"
constant-decl ::= ["published"] const-decl
const-decl ::= "const" type identifier "=" expr ";"
constants-decl ::= ["published"] "constants" identifier "{" const-decl+ "}" ";"
module-decl ::= "module" identifier "{" declaration+ "}" ";"
interface-service-decl ::= ["published"] "service" identifier ":" name ["{" constructor-decl* "}"] ";"
constructor-decl ::= identifier "(" [constructor-params] ")" [exception-spec]
constructor-params ::= rest-param | ctor-param ("," ctor-param)*
rest-param ::= "[" "in" "]" "any" "..." identifier
ctor-param ::= "[" "in" "]" type identifier
accumulated-service-decl ::= ["published"] "service" identifier ":" name"{" service-member-decl+ "}" ";"
service-member-decl ::= service-inheritance-decl | interface-inheritance-decl | property-decl
service-inheritance-decl ::= ["[" "optional" "]"] "service" name ";"
property-decl ::= property-flags type identifier ";"
property-flags ::= "[" (property-flag ",")* "property" ("," property-flag)* "]"
property-flag ::= "bound" | "constrained" | "maybeambiguous" | "maybedefault" | "maybevoid" | "optional" | "readonly" | "removable" | "transient"
interface-singleton-decl ::= ["published"] "singleton" identifier ":" name ";"
service-singleton-decl ::= ["published"] "singleton" identifier "{" "service" name ";" "}" ";"
type ::= simple-type | sequence-type | poly-struct-type | name
simple-type ::= "void" | "boolean" | "byte" | "short" | "unsigned" "short" | "long" | "unsigned" "long" | "hyper" | "unsigned" "hyper" | "float" | "double" | "char" | "string" | "type" | "any"
sequence-type ::= "sequence" "<" type ">"
poly-struct-type ::= name "<" type ("," type)* ">"
expr ::= [expr "|"] xor-expr
xor-expr ::= [xor-expr "^"] and-expr
and-expr ::= [and-expr "&"] shift-expr
shift-expr ::= [shift-expr shift-op] add-expr
shift-op ::= "<<" | ">>"
add-expr ::= [add-expr add-op] mult-expr
add-op ::= "+" | "-"
mult-expr ::= [mult-expr mult-op] unary-expr
mult-op ::= "*" | "/" | "%"
unary-expr ::= [unary-op] primary-expr
unary-op ::= "+" | "-" | "~"
primary-expr ::= name | literal | "(" expr ")"
literal ::= boolean-literal | <INTEGER-LITERAL> | <FLOATING-POINT-LITERAL>
boolean-literal ::= "False" | "FALSE" | "True" | "TRUE"
name ::= ["::"] (identifier "::")* identifier
identifier ::= <IDENTIFIER>
| Content on this page is licensed under the Public Documentation License (PDL). |