ONC+ 開発ガイド

字句解析ノート

  1. コメントは、/**/ で囲む

  2. 空白は項目と項目の区切りに使用し、意味を持たない

  3. 識別子は英字で始まり、英字、数字、下線 (_) を含むことができる。識別子では、大文字と小文字を区別する

  4. 任意の桁数の 10 進数を定数といい、始めに負符号 (-)を付けることができる


    例 C-1 XDR 仕様

    Syntax Information
    declaration:
    	type-specifier identifier
    	| type-specifier identifier "[" value "]"
    	| type-specifier identifier "<" [ value ] ">"
    	| "opaque" identifier "[" value "]"
    	| "opaque" identifier "<" [ value ] ">"
    	| "string" identifier "<" [ value ] ">"
    	| type-specifier "*" identifier
    	| "void"
     
    value:
    	constant
    	| identifier
     
    type-specifier:
    	 [ "unsigned" ] "int"
    	| [ "unsigned" ] "hyper"
    	| "float"
    	| "double"
    	| "quadruple"
    	| "bool"
    	| enum-type-spec
    	| struct-type-spec
    	| union-type-spec
    	| identifier
     
    enum-type-spec:
    	"enum" enum-body
     
    enum-body:
    	"{"
    	( identifier "=" value )
    	( "," identifier "=" value )*
    	"}"
     
    struct-type-spec:
    	"struct" struct-body
     
    struct-body:
    	"{"
    	( declaration ";" )
    	( declaration ";" )*
    	"}"
     
     union-type-spec:
    	"union" union-body
     
    union-body:
    	"switch" "(" declaration ")" "{"
    	( "case" value ":" declaration ";" )
    	( "case" value ":" declaration ";" )*
    	[ "default" ":" declaration ";" ]
    	"}"
     
    constant-def:
    	"const" identifier "=" constant ";"
     
    type-def:
    	"typedef" declaration ";"
    	| "enum" identifier enum-body ";"
    	| "struct" identifier struct-body ";"
    	| "union" identifier union-body ";"
     
    definition:
    	type-def
    	| constant-def
     
    specification:
    	definition *