Show
Ignore:
Timestamp:
08/13/06 16:33:29 (2 years ago)
Author:
pragma
Message:

Bugfixes for WS/Comment parsing and D Tokenizer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/enki/enki.bnf

    r237 r240  
    5151 
    5252WS 
    53     ::= ws [ ( SlashSlashComment | SlashStarComment) ws]; 
     53    ::= ws [ (  SlashSlashComment |  SlashStarComment)  WS]; 
    5454 
    5555 
    5656Syntax 
    5757    = void createSyntax(SyntaxLine[] lines) 
    58     ::= WS { ( Rule:~lines | Comment:~lines | Directive:~lines) WS}eoi; 
     58    ::= WS { (  Rule:~lines |  Comment:~lines |  Directive:~lines)  WS} eoi; 
    5959 
    6060#  
     
    6464Rule 
    6565    = 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 ";"; 
    6767 
    6868RuleDecl 
    6969    = new RuleDecl(Param[] params) 
    70     ::= ParamsExpr:params; 
     70    ::= ParamsExpr:params; 
    7171 
    7272RulePredicate 
    7373    = RulePredicate pred 
    74     ::= "=" WS ( ClassPredicate:pred | FunctionPredicate:pred | BindingPredicate:pred); 
     74    ::= "="  WS (  ClassPredicate:pred |  FunctionPredicate:pred | BindingPredicate:pred); 
    7575 
    7676ClassPredicate 
    7777    = new ClassPredicate(String name,Param[] params) 
    78     ::= "new" WS Identifier:name WS ParamsExpr:params; 
     78    ::= "new"  WS  Identifier:name  WS ParamsExpr:params; 
    7979 
    8080FunctionPredicate 
    8181    = new FunctionPredicate(Param decl,Param[] params) 
    82     ::= ExplicitParam:decl WS ParamsExpr:params; 
     82    ::= ExplicitParam:decl  WS ParamsExpr:params; 
    8383 
    8484BindingPredicate 
    8585    = new BindingPredicate(Param param) 
    86     ::= Param:param; 
     86    ::= Param:param; 
    8787 
    8888ParamsExpr 
    8989    = Param[] params 
    90     ::= "(" WS [ Param:~params WS { "," WS Param:~params WS}] ")"; 
     90    ::= "("  WS [  Param:~params  WS {  ","  WS  Param:~params  WS}] ")"; 
    9191 
    9292Param 
    9393    = Param param 
    94     ::= ExplicitParam:param | WeakParam:param; 
     94    ::= ExplicitParam:param | WeakParam:param; 
    9595 
    9696WeakParam 
    9797    = new Param(String name) 
    98     ::= Identifier:name; 
     98    ::= Identifier:name; 
    9999 
    100100ExplicitParam 
    101101    = 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; 
    103103 
    104104Brackets 
    105     ::= [ "[]" Brackets]; 
     105    ::= [ "[]" Brackets]; 
    106106#  
    107107#  Expressions 
     
    110110Expression 
    111111    = new Expression(Term[] terms) 
    112     ::= Term:~terms WS { "|" WS Term:~terms WS}; 
     112    ::= Term:~terms  WS {  "|"  WS  Term:~terms WS}; 
    113113 
    114114Term 
    115115    = SubExpression[] factors 
    116     ::= SubExpression:~factors WS { SubExpression:~factors WS}; 
     116    ::= SubExpression:~factors  WS {  SubExpression:~factors WS}; 
    117117 
    118118SubExpression 
    119119    = 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; 
    121121 
    122122Production 
    123123    = 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]; 
    125125 
    126126ProductionArg 
    127127    = ProductionArg arg 
    128     ::= StringProductionArg:arg | BindingProductionArg:arg; 
     128    ::= StringProductionArg:arg | BindingProductionArg:arg; 
    129129 
    130130StringProductionArg 
    131131    = new StringProductionArg(String value) 
    132     ::= String:value; 
     132    ::= String:value; 
    133133 
    134134BindingProductionArg 
    135135    = new BindingProductionArg(String value) 
    136     ::= Identifier:value; 
     136    ::= Identifier:value; 
    137137 
    138138Substitution 
    139139    = new Substitution(String name,Binding binding) 
    140     ::= "." Identifier:name WS [ Binding:binding]; 
     140    ::= "."  Identifier:name  WS [ Binding:binding]; 
    141141 
    142142GroupExpr 
    143143    = new GroupExpr(Expression expr,Binding binding) 
    144     ::= "(" WS Expression:expr WS ")" WS [ Binding:binding]; 
     144    ::= "("  WS  Expression:expr  WS  ")"  WS [ Binding:binding]; 
    145145 
    146146OptionalExpr 
    147147    = new OptionalExpr(Expression expr,Binding binding) 
    148     ::= "[" WS Expression:expr WS "]" WS [ Binding:binding]; 
     148    ::= "["  WS  Expression:expr  WS  "]"  WS [ Binding:binding]; 
    149149 
    150150ZeroOrMoreExpr 
    151151    = 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]; 
    153153 
    154154Terminal 
    155155    = new Terminal(String text,Binding binding) 
    156     ::= String:text WS [ Binding:binding]; 
     156    ::= String:text  WS [ Binding:binding]; 
    157157 
    158158Range 
    159159    = 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]; 
    161161 
    162162Regexp 
    163163    = new Regexp(String text,Binding binding) 
    164     ::= ( "r" String:text | "`" { any}:text"`") WS [ Binding:binding]; 
     164    ::= ( "r"  String:text |  "`" {  any}:text "`")  WS [ Binding:binding]; 
    165165 
    166166NegateExpr 
    167167    = new Negate(SubExpression expr) 
    168     ::= "!" WS SubExpression:expr; 
     168    ::= "!"  WS SubExpression:expr; 
    169169 
    170170TestExpr 
    171171    = new Test(SubExpression expr) 
    172     ::= "/" WS SubExpression:expr; 
     172    ::= "/"  WS SubExpression:expr; 
    173173 
    174174LiteralExpr 
    175175    = 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]; 
    177177 
    178178CustomTerminal 
    179179    = new CustomTerminal(String name,Binding binding) 
    180     ::= "&" Identifier:name WS [ Binding:binding]; 
     180    ::= "&"  Identifier:name  WS [ Binding:binding]; 
    181181 
    182182Binding 
    183183    = new Binding(bool isConcat,String name) 
    184     ::= ":" WS [ "~"]:isConcat  WS Identifier:name; 
     184    ::= ":"  WS [  "~"]:isConcat   WS Identifier:name; 
    185185 
    186186Identifier 
    187187    = String value 
    188     ::= ( IdentifierStartChar { IdentifierChar}):value ; 
     188    ::= ( IdentifierStartChar { IdentifierChar}):value ; 
    189189 
    190190IdentifierStartChar 
    191191    = String text 
    192     ::= ( letter | "_"):text ; 
     192    ::= ( letter | "_"):text ; 
    193193 
    194194IdentifierChar 
    195195    = String text 
    196     ::= ( letter | digit | "_" | "."):text ; 
     196    ::= ( letter |  digit |  "_" | "."):text ; 
    197197 
    198198String 
    199199    = String text 
    200     ::= "\"" { AnyChar}:text"\""; 
     200    ::= "\"" {  AnyChar}:text "\""; 
    201201 
    202202HexExpr 
    203203    = String text 
    204     ::= "#" ( hexdigit hexdigit [ hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit [ hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit]]]):text ; 
     204    ::= "#" (  hexdigit  hexdigit [  hexdigit  hexdigit [  hexdigit  hexdigit  hexdigit  hexdigit [  hexdigit  hexdigit  hexdigit  hexdigit  hexdigit  hexdigit  hexdigit hexdigit]]]):text ; 
    205205 
    206206AnyChar 
    207207    = String value 
    208     ::= [ "\\":~value] any:~value; 
     208    ::= [ "\\":~value] any:~value; 
    209209 
    210210#  
     
    215215Comment 
    216216    = new Comment(String text) 
    217     ::= PoundComment:text | SlashSlashComment:text | SlashStarComment:text; 
     217    ::= PoundComment:text |  SlashSlashComment:text | SlashStarComment:text; 
    218218 
    219219PoundComment 
    220220    = String text 
    221     ::= "#" { any}:texteol; 
     221    ::= "#" {  any}:text eol; 
    222222 
    223223SlashSlashComment 
    224224    = String text 
    225     ::= "\x2F\x2F" { any}:texteol; 
     225    ::= "\x2F\x2F" {  any}:text eol; 
    226226 
    227227SlashStarComment 
    228228    = String text 
    229     ::= "\x2F\x2A" { any}:text"\x2A\x2F"; 
     229    ::= "\x2F\x2A" {  any}:text "\x2A\x2F"; 
    230230 
    231231#  
     
    235235Directive 
    236236    = 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); 
    238238 
    239239ImportDirective 
    240240    = new ImportDirective(String imp) 
    241     ::= "import" WS "(" WS DirectiveArg:imp WS ")" WS ";"; 
     241    ::= "import"  WS  "("  WS  DirectiveArg:imp  WS  ")"  WS ";"; 
    242242 
    243243BaseClassDirective 
    244244    = new BaseClassDirective(String name) 
    245     ::= "baseclass" WS "(" WS DirectiveArg:name WS ")" WS ";"; 
     245    ::= "baseclass"  WS  "("  WS  DirectiveArg:name  WS  ")"  WS ";"; 
    246246 
    247247ClassnameDirective 
    248248    = new ClassnameDirective(String name) 
    249     ::= "classname" WS "(" WS DirectiveArg:name WS ")" WS ";"; 
     249    ::= "classname"  WS  "("  WS  DirectiveArg:name  WS  ")"  WS ";"; 
    250250 
    251251DefineDirective 
    252252    = 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 ";"; 
    254254 
    255255IncludeDirective 
    256256    = new IncludeDirective(String filename) 
    257     ::= "include" WS "(" WS String:filename WS ")" WS ";"; 
     257    ::= "include"  WS  "("  WS  String:filename  WS  ")"  WS ";"; 
    258258 
    259259AliasDirective 
    260260    = 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 ";"; 
    262262 
    263263ModuleDirective 
    264264    = new ModuleDirective(String moduleName) 
    265     ::= "module" WS "(" WS DirectiveArg:moduleName WS ")" WS ";"; 
     265    ::= "module"  WS  "("  WS  DirectiveArg:moduleName  WS  ")"  WS ";"; 
    266266 
    267267CodeDirective 
    268268    = new CodeDirective(String code) 
    269     ::= "code" WS "{{{" { any}:code"}}}"; 
     269    ::= "code"  WS  "{{{" {  any}:code "}}}"; 
    270270 
    271271TypelibDirective 
    272272    = new TypelibDirective(String importName) 
    273     ::= "typelib" WS "(" WS DirectiveArg:importName WS ")" WS ";"; 
     273    ::= "typelib"  WS  "("  WS  DirectiveArg:importName  WS  ")"  WS ";"; 
    274274 
    275275ParseTypeDirective 
    276276    = new ParseTypeDirective(String typeName) 
    277     ::= "parsetype" WS "(" WS DirectiveArg:typeName WS ")" WS ";"; 
     277    ::= "parsetype"  WS  "("  WS  DirectiveArg:typeName  WS  ")"  WS ";"; 
    278278 
    279279BoilerplateDirective 
    280280    = new BoilerplateDirective(String code) 
    281     ::= "boilerplate" WS "{{{" { any}:code"}}}"; 
     281    ::= "boilerplate"  WS  "{{{" {  any}:code "}}}"; 
    282282 
    283283HeaderDirective 
    284284    = new HeaderDirective(String code) 
    285     ::= "header" WS "{{{" { any}:code"}}}"; 
     285    ::= "header"  WS  "{{{" {  any}:code "}}}"; 
    286286 
    287287UTFDirective 
    288288    = new UTFDirective(String value) 
    289     ::= "utf" WS "(" WS DirectiveArg:value WS ")" WS ";"; 
     289    ::= "utf"  WS  "("  WS  DirectiveArg:value  WS  ")"  WS ";"; 
    290290 
    291291DirectiveArg 
    292292    = String arg 
    293     ::= Identifier:arg | String:arg; 
     293    ::= Identifier:arg | String:arg;