brintos

brintos / linux-shallow public Read only

0
0
Text · 4.1 KiB · f3c4552 Raw
120 lines · plain
1// A Lark grammar for the XDR specification language based on2// https://tools.ietf.org/html/rfc4506 Section 6.33 4declaration             : "opaque" identifier "[" value "]"            -> fixed_length_opaque5                        | "opaque" identifier "<" [ value ] ">"        -> variable_length_opaque6                        | "string" identifier "<" [ value ] ">"        -> variable_length_string7                        | type_specifier identifier "[" value "]"      -> fixed_length_array8                        | type_specifier identifier "<" [ value ] ">"  -> variable_length_array9                        | type_specifier "*" identifier                -> optional_data10                        | type_specifier identifier                    -> basic11                        | "void"                                       -> void12 13value                   : decimal_constant14                        | hexadecimal_constant15                        | octal_constant16                        | identifier17 18constant                : decimal_constant | hexadecimal_constant | octal_constant19 20type_specifier          : unsigned_hyper21                        | unsigned_long22                        | unsigned_int23                        | hyper24                        | long25                        | int26                        | float27                        | double28                        | quadruple29                        | bool30                        | enum_type_spec31                        | struct_type_spec32                        | union_type_spec33                        | identifier34 35unsigned_hyper          : "unsigned" "hyper"36unsigned_long           : "unsigned" "long"37unsigned_int            : "unsigned" "int"38hyper                   : "hyper"39long                    : "long"40int                     : "int"41float                   : "float"42double                  : "double"43quadruple               : "quadruple"44bool                    : "bool"45 46enum_type_spec          : "enum" enum_body47 48enum_body               : "{" ( identifier "=" value ) ( "," identifier "=" value )* "}"49 50struct_type_spec        : "struct" struct_body51 52struct_body             : "{" ( declaration ";" )+ "}"53 54union_type_spec         : "union" union_body55 56union_body              : switch_spec "{" case_spec+ [ default_spec ] "}"57 58switch_spec             : "switch" "(" declaration ")"59 60case_spec               : ( "case" value ":" )+ declaration ";"61 62default_spec            : "default" ":" declaration ";"63 64constant_def            : "const" identifier "=" value ";"65 66type_def                : "typedef" declaration ";"                -> typedef67                        | "enum" identifier enum_body ";"          -> enum68                        | "struct" identifier struct_body ";"      -> struct69                        | "union" identifier union_body ";"        -> union70 71specification           : definition*72 73definition              : constant_def74                        | type_def75                        | program_def76                        | pragma_def77 78//79// RPC program definitions not specified in RFC 450680//81 82program_def             : "program" identifier "{" version_def+ "}" "=" constant ";"83 84version_def             : "version" identifier "{" procedure_def+ "}" "=" constant ";"85 86procedure_def           : type_specifier identifier "(" type_specifier ")" "=" constant ";"87 88pragma_def              : "pragma" directive identifier [ identifier ] ";"89 90directive               : exclude_directive91                        | header_directive92                        | pages_directive93                        | public_directive94                        | skip_directive95 96exclude_directive       : "exclude"97header_directive        : "header"98pages_directive         : "pages"99public_directive        : "public"100skip_directive          : "skip"101 102//103// XDR language primitives104//105 106identifier              : /([a-z]|[A-Z])(_|[a-z]|[A-Z]|[0-9])*/107 108decimal_constant        : /[\+-]?(0|[1-9][0-9]*)/109hexadecimal_constant    : /0x([a-f]|[A-F]|[0-9])+/110octal_constant          : /0[0-7]+/111 112PASSTHRU                : "%" | "%" /.+/113%ignore PASSTHRU114 115%import common.C_COMMENT116%ignore C_COMMENT117 118%import common.WS119%ignore WS120