rustlr 0.3.93

Bottom-Up Parser Generator with Advanced Options
Documentation
332,333c332,333
< 	let mut AST = format!("#[derive(Debug)]\npub enum {} {{\n",&ntsym.rusttype);
<         if willextend {AST=String::new();}
---
> 	let mut AST = if willextend {String::new()}
>           else {format!("#[derive(Debug)]\npub enum {} {{\n",&ntsym.rusttype)};
356,359c356,370
< 	  if self.Rules[*ri].rhs.len()>0 { //for enums
< 	    enumvar.push('(');
< 	    ACTION.push('(');
< 	  }//enum
---
> 
>           // determine if tuple variant or struct/named variant
>           let mut tuplevariant = true;
>           for rs in &self.Rules[*ri].rhs {
>             if rs.label.len()>0 && !rs.label.starts_with("_item") 
>               { tuplevariant = false; break; }
>           } //determine if tuplevariant
> 
> 	  if self.Rules[*ri].rhs.len()>0 { // rhs exists
>             if tuplevariant {
> 	      enumvar.push('('); ACTION.push('(');
>             } else {
>               enumvar.push('{'); ACTION.push('{');
>             }  // struct variant
> 	  }//rhsexists
362a374
>           if tuplevariant {passthru = -2;} // forget about it
373a386
>             
376a390
>             
389,394c403,405
<                    //enumvar.push_str("pub ");
<                    enumvar.push_str(ftype); enumvar.push(',');
<                    ACTION.push_str(&newactionlab); ACTION.push(',');
<                    /*
<                    let islbxtype = ftype.starts_with("LBox<");
<                    if !islbxtype{
---
> 
>                    if tuplevariant {
>                      enumvar.push_str(ftype); enumvar.push(',');
396,399c407,411
<                    } else  {
<                      ACTION.push_str(&format!("parser.lbx({},{}),",newindex,&newactionlab));
<                    }
<                    */
---
>                    } else {
>                      enumvar.push_str(&format!("{}:{},",&newlab,ftype));
>                      ACTION.push_str(&format!("{}:{},",&newlab,&newactionlab));
>                    }//non-tuplevariant
>                    
417,418c429,437
<               enumvar.push_str(&format!("LBox<{}>,",rsymtype));
<               let semact = if alreadyislbx {format!("{}, ",&itemlabel)} else {format!("parser.lbx({},{}),",&rhsi, &itemlabel)};
---
> 
>               let semact;
>               if tuplevariant {
>                 enumvar.push_str(&format!("LBox<{}>,",rsymtype));
>                 semact = if alreadyislbx {format!("{},",&itemlabel)} else {format!("parser.lbx({},{}),",&rhsi, &itemlabel)};
>               } else {
>                 enumvar.push_str(&format!("{}:LBox<{}>,",itemlabel,rsymtype));
>                 semact = if alreadyislbx {format!("{0}:{0},",&itemlabel)} else {format!("{}:parser.lbx({},{}),",&itemlabel,&rhsi, &itemlabel)};                
>               } // non-tuple variant
419a439
>               
425,426c445,452
<               enumvar.push_str(&format!("{},",rsymtype));
<               ACTION.push_str(&format!("{},",&itemlabel));
---
>               if tuplevariant {
>                 enumvar.push_str(&format!("{},",rsymtype));
>                 ACTION.push_str(&format!("{},",&itemlabel));
>               } else {
>                 enumvar.push_str(&format!("{}:{},",&itemlabel,rsymtype));
>                 ACTION.push_str(&format!("{0}:{0},",&itemlabel));              
>               }// non-tuple variant
>               
443c469,470
< 	      enumvar.push(')');
---
> 	      if tuplevariant {enumvar.push(')');}
>               else {enumvar.push('}');}
445,446c472,474
< 	      ACTION.push(')');
< 	  } else if enumvar.ends_with('(') {
---
> 	      if tuplevariant {ACTION.push(')');}
>               else {ACTION.push('}');}
> 	  } else if enumvar.ends_with('(') || enumvar.ends_with('{') {