Changeset 240 for trunk/enki/enki.bnf
- Timestamp:
- 08/13/06 16:33:29 (2 years ago)
- Files:
-
- trunk/enki/enki.bnf (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/enki/enki.bnf
r237 r240 51 51 52 52 WS 53 ::= ws [ ( SlashSlashComment | SlashStarComment) ws];53 ::= ws [ ( SlashSlashComment | SlashStarComment) WS]; 54 54 55 55 56 56 Syntax 57 57 = void createSyntax(SyntaxLine[] lines) 58 ::= WS { ( Rule:~lines | Comment:~lines | Directive:~lines) WS}eoi;58 ::= WS { ( Rule:~lines | Comment:~lines | Directive:~lines) WS} eoi; 59 59 60 60 # … … 64 64 Rule 65 65 = new Rule(String name,RulePredicate pred,Expression expr,RuleDecl decl) 66 ::= WS Identifier:name WS [ RuleDecl:decl WS] [ RulePredicate:pred] WS "::=" WS Expression:expr WS";";66 ::= Identifier:name WS [ RuleDecl:decl WS] [ RulePredicate:pred] WS "::=" WS Expression:expr WS ";"; 67 67 68 68 RuleDecl 69 69 = new RuleDecl(Param[] params) 70 ::= ParamsExpr:params;70 ::= ParamsExpr:params; 71 71 72 72 RulePredicate 73 73 = RulePredicate pred 74 ::= "=" WS ( ClassPredicate:pred | FunctionPredicate:pred |BindingPredicate:pred);74 ::= "=" WS ( ClassPredicate:pred | FunctionPredicate:pred | BindingPredicate:pred); 75 75 76 76 ClassPredicate 77 77 = new ClassPredicate(String name,Param[] params) 78 ::= "new" WS Identifier:name WSParamsExpr:params;78 ::= "new" WS Identifier:name WS ParamsExpr:params; 79 79 80 80 FunctionPredicate 81 81 = new FunctionPredicate(Param decl,Param[] params) 82 ::= ExplicitParam:decl WSParamsExpr:params;82 ::= ExplicitParam:decl WS ParamsExpr:params; 83 83 84 84 BindingPredicate 85 85 = new BindingPredicate(Param param) 86 ::= Param:param;86 ::= Param:param; 87 87 88 88 ParamsExpr 89 89 = Param[] params 90 ::= "(" WS [ Param:~params WS { "," WS Param:~params WS}]")";90 ::= "(" WS [ Param:~params WS { "," WS Param:~params WS}] ")"; 91 91 92 92 Param 93 93 = Param param 94 ::= ExplicitParam:param |WeakParam:param;94 ::= ExplicitParam:param | WeakParam:param; 95 95 96 96 WeakParam 97 97 = new Param(String name) 98 ::= Identifier:name;98 ::= Identifier:name; 99 99 100 100 ExplicitParam 101 101 = new Param(bool isArray,String type,String name) 102 ::= Identifier:type WS [ "[]":isArray Brackets WS]Identifier:name;102 ::= Identifier:type WS [ "[]":isArray Brackets WS] Identifier:name; 103 103 104 104 Brackets 105 ::= [ "[]"Brackets];105 ::= [ "[]" Brackets]; 106 106 # 107 107 # Expressions … … 110 110 Expression 111 111 = new Expression(Term[] terms) 112 ::= Term:~terms WS { "|" WS Term:~termsWS};112 ::= Term:~terms WS { "|" WS Term:~terms WS}; 113 113 114 114 Term 115 115 = SubExpression[] factors 116 ::= SubExpression:~factors WS { SubExpression:~factorsWS};116 ::= SubExpression:~factors WS { SubExpression:~factors WS}; 117 117 118 118 SubExpression 119 119 = SubExpression expr 120 ::= Production:expr | Substitution:expr | Terminal:expr | Range:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | LiteralExpr:expr |CustomTerminal:expr;120 ::= Production:expr | Substitution:expr | Terminal:expr | Range:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | LiteralExpr:expr | CustomTerminal:expr; 121 121 122 122 Production 123 123 = new Production(String name,Binding binding,ProductionArg[] args) 124 ::= Identifier:name WS [ "!(" WS ProductionArg:~args { WS "," WS ProductionArg:~args}")"] [Binding:binding];124 ::= Identifier:name WS [ "!(" WS ProductionArg:~args { WS "," WS ProductionArg:~args} ")"] [ Binding:binding]; 125 125 126 126 ProductionArg 127 127 = ProductionArg arg 128 ::= StringProductionArg:arg |BindingProductionArg:arg;128 ::= StringProductionArg:arg | BindingProductionArg:arg; 129 129 130 130 StringProductionArg 131 131 = new StringProductionArg(String value) 132 ::= String:value;132 ::= String:value; 133 133 134 134 BindingProductionArg 135 135 = new BindingProductionArg(String value) 136 ::= Identifier:value;136 ::= Identifier:value; 137 137 138 138 Substitution 139 139 = new Substitution(String name,Binding binding) 140 ::= "." Identifier:name WS [Binding:binding];140 ::= "." Identifier:name WS [ Binding:binding]; 141 141 142 142 GroupExpr 143 143 = new GroupExpr(Expression expr,Binding binding) 144 ::= "(" WS Expression:expr WS ")" WS [Binding:binding];144 ::= "(" WS Expression:expr WS ")" WS [ Binding:binding]; 145 145 146 146 OptionalExpr 147 147 = new OptionalExpr(Expression expr,Binding binding) 148 ::= "[" WS Expression:expr WS "]" WS [Binding:binding];148 ::= "[" WS Expression:expr WS "]" WS [ Binding:binding]; 149 149 150 150 ZeroOrMoreExpr 151 151 = new ZeroOrMoreExpr(Expression expr,Binding binding,SubExpression term) 152 ::= "{" WS Expression:expr WS "}" WS [ Binding:binding WS] [SubExpression:term];152 ::= "{" WS Expression:expr WS "}" WS [ Binding:binding WS] [ SubExpression:term]; 153 153 154 154 Terminal 155 155 = new Terminal(String text,Binding binding) 156 ::= String:text WS [Binding:binding];156 ::= String:text WS [ Binding:binding]; 157 157 158 158 Range 159 159 = new Range(String start,String end,Binding binding) 160 ::= HexExpr:start WS [ "-" WS HexExpr:end WS] [Binding:binding];160 ::= HexExpr:start WS [ "-" WS HexExpr:end WS] [ Binding:binding]; 161 161 162 162 Regexp 163 163 = new Regexp(String text,Binding binding) 164 ::= ( "r" String:text | "`" { any}:text"`") WS [Binding:binding];164 ::= ( "r" String:text | "`" { any}:text "`") WS [ Binding:binding]; 165 165 166 166 NegateExpr 167 167 = new Negate(SubExpression expr) 168 ::= "!" WSSubExpression:expr;168 ::= "!" WS SubExpression:expr; 169 169 170 170 TestExpr 171 171 = new Test(SubExpression expr) 172 ::= "/" WSSubExpression:expr;172 ::= "/" WS SubExpression:expr; 173 173 174 174 LiteralExpr 175 175 = new LiteralExpr(String name,Binding binding,ProductionArg[] args) 176 ::= "@" Identifier:name WS [ "!(" WS ProductionArg:~args { WS "," WS ProductionArg:~args}")"] [Binding:binding];176 ::= "@" Identifier:name WS [ "!(" WS ProductionArg:~args { WS "," WS ProductionArg:~args} ")"] [ Binding:binding]; 177 177 178 178 CustomTerminal 179 179 = new CustomTerminal(String name,Binding binding) 180 ::= "&" Identifier:name WS [Binding:binding];180 ::= "&" Identifier:name WS [ Binding:binding]; 181 181 182 182 Binding 183 183 = new Binding(bool isConcat,String name) 184 ::= ":" WS [ "~"]:isConcat WSIdentifier:name;184 ::= ":" WS [ "~"]:isConcat WS Identifier:name; 185 185 186 186 Identifier 187 187 = String value 188 ::= ( IdentifierStartChar {IdentifierChar}):value ;188 ::= ( IdentifierStartChar { IdentifierChar}):value ; 189 189 190 190 IdentifierStartChar 191 191 = String text 192 ::= ( letter |"_"):text ;192 ::= ( letter | "_"):text ; 193 193 194 194 IdentifierChar 195 195 = String text 196 ::= ( letter | digit | "_" |"."):text ;196 ::= ( letter | digit | "_" | "."):text ; 197 197 198 198 String 199 199 = String text 200 ::= "\"" { AnyChar}:text"\"";200 ::= "\"" { AnyChar}:text "\""; 201 201 202 202 HexExpr 203 203 = String text 204 ::= "#" ( hexdigit hexdigit [ hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit hexdigithexdigit]]]):text ;204 ::= "#" ( hexdigit hexdigit [ hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit]]]):text ; 205 205 206 206 AnyChar 207 207 = String value 208 ::= [ "\\":~value]any:~value;208 ::= [ "\\":~value] any:~value; 209 209 210 210 # … … 215 215 Comment 216 216 = new Comment(String text) 217 ::= PoundComment:text | SlashSlashComment:text |SlashStarComment:text;217 ::= PoundComment:text | SlashSlashComment:text | SlashStarComment:text; 218 218 219 219 PoundComment 220 220 = String text 221 ::= "#" { any}:texteol;221 ::= "#" { any}:text eol; 222 222 223 223 SlashSlashComment 224 224 = String text 225 ::= "\x2F\x2F" { any}:texteol;225 ::= "\x2F\x2F" { any}:text eol; 226 226 227 227 SlashStarComment 228 228 = String text 229 ::= "\x2F\x2A" { any}:text"\x2A\x2F";229 ::= "\x2F\x2A" { any}:text "\x2A\x2F"; 230 230 231 231 # … … 235 235 Directive 236 236 = Directive dir 237 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir | BoilerplateDirective:~dir | HeaderDirective:~dir |UTFDirective:~dir);237 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir | BoilerplateDirective:~dir | HeaderDirective:~dir | UTFDirective:~dir); 238 238 239 239 ImportDirective 240 240 = new ImportDirective(String imp) 241 ::= "import" WS "(" WS DirectiveArg:imp WS ")" WS";";241 ::= "import" WS "(" WS DirectiveArg:imp WS ")" WS ";"; 242 242 243 243 BaseClassDirective 244 244 = new BaseClassDirective(String name) 245 ::= "baseclass" WS "(" WS DirectiveArg:name WS ")" WS";";245 ::= "baseclass" WS "(" WS DirectiveArg:name WS ")" WS ";"; 246 246 247 247 ClassnameDirective 248 248 = new ClassnameDirective(String name) 249 ::= "classname" WS "(" WS DirectiveArg:name WS ")" WS";";249 ::= "classname" WS "(" WS DirectiveArg:name WS ")" WS ";"; 250 250 251 251 DefineDirective 252 252 = new DefineDirective(String returnType,String name,bool isTerminal,String description) 253 ::= "define" WS "(" WS DirectiveArg:returnType WS "," WS DirectiveArg:name WS "," WS DirectiveArg:isTerminal WS [ "," WS DirectiveArg:description WS] ")" WS";";253 ::= "define" WS "(" WS DirectiveArg:returnType WS "," WS DirectiveArg:name WS "," WS DirectiveArg:isTerminal WS [ "," WS DirectiveArg:description WS] ")" WS ";"; 254 254 255 255 IncludeDirective 256 256 = new IncludeDirective(String filename) 257 ::= "include" WS "(" WS String:filename WS ")" WS";";257 ::= "include" WS "(" WS String:filename WS ")" WS ";"; 258 258 259 259 AliasDirective 260 260 = new AliasDirective(String rule,String ruleAlias) 261 ::= "alias" WS "(" WS DirectiveArg:rule WS "," WS DirectiveArg:ruleAlias WS ")" WS";";261 ::= "alias" WS "(" WS DirectiveArg:rule WS "," WS DirectiveArg:ruleAlias WS ")" WS ";"; 262 262 263 263 ModuleDirective 264 264 = new ModuleDirective(String moduleName) 265 ::= "module" WS "(" WS DirectiveArg:moduleName WS ")" WS";";265 ::= "module" WS "(" WS DirectiveArg:moduleName WS ")" WS ";"; 266 266 267 267 CodeDirective 268 268 = new CodeDirective(String code) 269 ::= "code" WS "{{{" { any}:code"}}}";269 ::= "code" WS "{{{" { any}:code "}}}"; 270 270 271 271 TypelibDirective 272 272 = new TypelibDirective(String importName) 273 ::= "typelib" WS "(" WS DirectiveArg:importName WS ")" WS";";273 ::= "typelib" WS "(" WS DirectiveArg:importName WS ")" WS ";"; 274 274 275 275 ParseTypeDirective 276 276 = new ParseTypeDirective(String typeName) 277 ::= "parsetype" WS "(" WS DirectiveArg:typeName WS ")" WS";";277 ::= "parsetype" WS "(" WS DirectiveArg:typeName WS ")" WS ";"; 278 278 279 279 BoilerplateDirective 280 280 = new BoilerplateDirective(String code) 281 ::= "boilerplate" WS "{{{" { any}:code"}}}";281 ::= "boilerplate" WS "{{{" { any}:code "}}}"; 282 282 283 283 HeaderDirective 284 284 = new HeaderDirective(String code) 285 ::= "header" WS "{{{" { any}:code"}}}";285 ::= "header" WS "{{{" { any}:code "}}}"; 286 286 287 287 UTFDirective 288 288 = new UTFDirective(String value) 289 ::= "utf" WS "(" WS DirectiveArg:value WS ")" WS";";289 ::= "utf" WS "(" WS DirectiveArg:value WS ")" WS ";"; 290 290 291 291 DirectiveArg 292 292 = String arg 293 ::= Identifier:arg |String:arg;293 ::= Identifier:arg | String:arg;
