diff --git a/vhdlparser/vhdlparser.jj b/vhdlparser/vhdlparser.jj
index d21afe15..cb149bec 100644
--- a/vhdlparser/vhdlparser.jj
+++ b/vhdlparser/vhdlparser.jj
@@ -18,8 +18,8 @@ options {
   TOKEN_MANAGER_INCLUDES="VhdlParser.h";
 
  //OUTPUT_DIRECTORY = ".";
- //DEBUG_PARSER=true;
- //DEBUG_LOOKAHEAD=true;
+  DEBUG_PARSER=true;
+ // DEBUG_LOOKAHEAD=true;
 
   }
 
@@ -295,7 +295,7 @@ TOKEN:
  | <EXTENDED_CHARACTER: ( ["\\"](<GRAPHIC_CHARACTER>)*["\\"] ) >
  | <CHARACTER_LITERAL: (["'"](<GRAPHIC_CHARACTER>|<QUOTE>)["'"]) >
  | <DECIMAL_LITERAL: (<INTEGER> (["."]<INTEGER>)? (<EXPONENT>)? ) >
- | <BASED_INTEGER: <LETTER_OR_DIGIT>( <LETTER_OR_DIGIT>)* >
+ | <BASED_INTEGER: <LETTER_OR_DIGIT>( (["_"])?<LETTER_OR_DIGIT>)* >
  | <BASED_LITERAL: <INTEGER>["#"]<BASED_INTEGER>(["."] <BASED_INTEGER>)? ["#"] (<EXPONENT>)? >
  | <#EXPONENT: (["e","E"] (["+","-"])? (<INTEGER>)+) >
  | < #BASIC_GRAPHIC_CHARACTER:    (<UPPER_CASE_LETTER>|<DIGIT>|<SPECIAL_CHARACTER>|<SPACE_CHARACTER>) >
@@ -305,7 +305,7 @@ TOKEN:
  | < #LETTER: (<UPPER_CASE_LETTER>|<LOWER_CASE_LETTER>) >
  | < #UPPER_CASE_LETTER: ["A"-"Z"]  >
  | <BIT_STRING_LITERAL : (<DIGIT>)*<BASE_SPECIFIER>["\""](<LETTER_OR_DIGIT_OR_STD>((["_"])*<LETTER_OR_DIGIT_OR_STD>)*)["\""] >
- | <#BASE_SPECIFIER:["B","O","X","b","o","x","d","D"]>
+ | <#BASE_SPECIFIER: (<DIGIT>)*(["S","U"])*["B","O","X","b","o","x","d","D"] >
  | <#STD_LOGIC:["0","1","L","H","X","Z","W","-","l","h","x","z","w"]>
  | < #DIGIT: ["0"-"9"] >
  | < #SPECIAL_CHARACTER: ["#","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","_","|"] >
@@ -625,7 +625,7 @@ void block_statement_part() :  {}
 void  case_statement() : {QCString s;}
 {
 [ identifier() <COLON_T> ]
-  <CASE_T> s=expression()
+  <CASE_T> [<Q_T>] s=expression()
     {
      QCString ca="case "+s;
      FlowChart::addFlowChart(FlowChart::CASE_NO,0,ca);
@@ -633,7 +633,7 @@ void  case_statement() : {QCString s;}
   <IS_T>
         case_statement_alternative()
         ( case_statement_alternative ())*
-        <END_T> <CASE_T> [ identifier() ] <SEMI_T>
+        <END_T> <CASE_T> [<Q_T>] [ identifier() ] <SEMI_T>
         {
          FlowChart::moveToPrevLevel();
          FlowChart::addFlowChart(FlowChart::END_CASE,"end case",0);
@@ -658,12 +658,13 @@ QCString character_literal() :  {Token *tok=0;}
 
 QCString choice() : {QCString s;}
 {
-  LOOKAHEAD(discrete_range())
-  s=discrete_range(){ return s; }
-  |
-   LOOKAHEAD(simple_expression())
+     LOOKAHEAD(simple_expression())
    s=simple_expression(){ return s; }
   |
+ 
+   LOOKAHEAD(discrete_range())
+  s=discrete_range(){ return s; }
+  |
   LOOKAHEAD(identifier())
   s=identifier(){ return s; }
   | <OTHER_T> { return " others "; }
@@ -755,9 +756,11 @@ block_statement()
 LOOKAHEAD([identifier() ":"] [<POSTPONED_T>] <PROCESS_T>)
 process_statement()
 |
-LOOKAHEAD(generate_statement())
+// LOOKAHEAD(generate_statement())
+LOOKAHEAD(identifier() ":" (<IF_T>|<FOR_T>))
 generate_statement()
 |
+LOOKAHEAD(case_scheme())
 case_scheme()
 |
 LOOKAHEAD([identifier() ":"] [<POSTPONED_T>] <ASSERT_T>)
@@ -1156,26 +1159,29 @@ QCString factor():  {QCString s,s1;}
 s=primary() [LOOKAHEAD(1) <DOUBLEMULT_T> s1=primary(){ s+="**";s+=s1;} ] { return s;}
 | <ABS_T> s=primary(){ s1 = "abs "; return s1+s; }
 | <NOT_T>  s=primary(){s1="not ";return s1+s;}
+| <QQ_T>  s=primary(){s1="?? ";return s1+s;}
 }
 
 QCString file_declaration() :  {QCString s,s1,s2,s3;}
 {
- <FILE_T> s=identifier_list() <COLON_T> s2=subtype_indication() [ s3=file_open_information() ] <SEMI_T>
+ <FILE_T> s=identifier_list() <COLON_T> s2=subtype_indication() [s3=file_open_information()]  <SEMI_T>
    {
    QCString t1=s2+" "+s3;
    addVhdlType(s.data(),getLine(),Entry::VARIABLE_SEC,VhdlDocGen::VFILE,0,t1.data(),Public);
    return " file "+s+":"+s2+" "+s3+";";
    }
+ 
  }
 
+ 
 QCString  file_logical_name():  {QCString s;}
 {
  s=expression() { return s; }
 }
 
-QCString file_open_information() :  {QCString s,s1,s2;}
+QCString file_open_information() :  {QCString s,s1,s2,s3;}
 {
- [ <OPEN_T> s=expression() ] <IS_T> s1=file_logical_name() {s2="open "+s+" is "+s1;  return s2; }
+ [ <OPEN_T> s=expression() ] <IS_T> [s3=mode()] s1=file_logical_name() {s2="open "+s+" is "+" "+s3+" "+s1;  return s2; }
 }
 
 QCString file_type_definition() :  {QCString s,s1;}
@@ -1247,21 +1253,19 @@ s=name()  <LPAREN_T> s1=actual_parameter_part()  <RPAREN_T> { return s+"("+s1+")
 void generate_statement() :  {QCString s;}
 {
 s=identifier() <COLON_T>
-          try{
-        generate_scheme() <GENERATE_T>
+         generate_scheme() <GENERATE_T>
         { pushLabel(genLabels,s); }
           generate_statement_body1()
         <END_T>
-                 }catch(...){error_skipto(GENERATE_T);}
         <GENERATE_T> [ identifier() ] <SEMI_T> {genLabels=popLabel(genLabels); }
 }
 
 void generate_scheme() : {}
 {
 <FOR_T> parameter_specification()
-| <IF_T> condition()
+|  <IF_T> [LOOKAHEAD(2) identifier() <COLON_T> ] condition()
 }
-
+//LOOKAHEAD(identifier() ":" (<IF_T>|<FOR_T>))
 void generic_clause() : {QCString s;}
 {
  <GENERIC_T>  <LPAREN_T> { parse_sec=GEN_SEC; } s=generic_list() <RPAREN_T> <SEMI_T> { parse_sec=0; }
@@ -1404,8 +1408,9 @@ QCString interface_declaration() :  {QCString s,s1;}
 
 LOOKAHEAD(5)
  s=interface_subprogram_declaration() { return s;}
-
-|interface_package_declaration() { return s;}
+|
+  LOOKAHEAD(5)
+  interface_package_declaration() { return s;}
 |
  LOOKAHEAD(5)
  s=interface_variable_declaration() { return s;}
@@ -1772,11 +1777,14 @@ LOOKAHEAD(attribute_declaration())
 |
 LOOKAHEAD(3)
  group_template_declaration()
-| group_declaration()
+| 
+group_declaration()
 |
  LOOKAHEAD(5)
  package_instantiation_declaration()
-|package_declaration()
+|
+LOOKAHEAD(5)
+ package_declaration()
 
 }
 
@@ -1842,8 +1850,10 @@ s=literal() { s.prepend(" ");return s;}
 LOOKAHEAD(name())
 s=name() { return s;}
 |
+LOOKAHEAD(allocator())
 allocator() { return "";}
 |
+LOOKAHEAD(aggregate())
 s=aggregate() { return s; }
 }
 
@@ -1851,14 +1861,17 @@ s=aggregate() { return s; }
 void primary_unit() : {}
 {
 entity_declaration()
-| configuration_declaration()
+| 
+configuration_declaration()
 |
 LOOKAHEAD(package_instantiation_declaration())
 package_instantiation_declaration()
 |
-LOOKAHEAD(4)
+LOOKAHEAD(interface_package_declaration())
  interface_package_declaration()
-| package_declaration()
+| 
+LOOKAHEAD(5)
+package_declaration()
 
 }
 
@@ -1951,12 +1964,14 @@ void process_statement_part() :  {}
 
 QCString qualified_expression() :  {QCString s,s1;}
 {
-  s1=identifier() <APOSTROPHE_T> {s=s1+"'";}
-  (
+ 
+  s1=identifier()  <APOSTROPHE_T> {s=s1+"'";}
+   (
     LOOKAHEAD(aggregate())
     s1=aggregate(){s+=s1;}
-    | <LPAREN_T> s1=expression() <RPAREN_T>{s+="(";s+=s1;s+=")";}
- )
+    |
+    <LPAREN_T> s1=expression() <RPAREN_T>{s+="(";s+=s1;s+=")";}
+    )
  {return s;}
 }
 
@@ -1997,7 +2012,13 @@ QCString relation_operator() :  {}
  |<GREATERTHAN_T> {return ">=";}
  |<LESSTHAN_T> {return "<=";}
  |<NOTEQU_T> {return "/=";}
-
+ |<QGT_T> { return "?>=";}
+ |<QLT_T> { return "?<=";}
+ |<QG_T> { return "?>";}
+ |<QL_T> { return "?<";}
+ |<QEQU_T> { return "?=";}
+ |<QNEQU_T> {return  "?/="; }
+ 
 }
 
 QCString report_statement() :  {Token *t=0;Token *t1=0;QCString s,s1,s2;}
@@ -2632,8 +2653,8 @@ void gen_interface_list() : {}
 
 void case_scheme (): {}
 {
- <CASE_T> expression() <GENERATE_T> when_stats() [LOOKAHEAD(3) ttend()]  <END_T>
- <GENERATE_T> generate_statement_body() <SEMI_T>
+[identifier() <COLON_T> ] <CASE_T> expression() <GENERATE_T> when_stats() [LOOKAHEAD(3) ttend()]  <END_T>
+ <GENERATE_T> generate_statement_body1() <SEMI_T>
 }
 
 void when_stats() : {}
@@ -2651,17 +2672,30 @@ void ttend(): {}
 
 void generate_statement_body() : {}
 {
-   <BEGIN_T> generate_statement_body()
+    [(LOOKAHEAD(block_declarative_item())block_declarative_item() )*  <BEGIN_T>] (concurrent_statement())*
 }
 
 void generate_statement_body1() : {}
 {
-  //   [LOOKAHEAD(block_declarative_item()<BEGIN_T> )(block_declarative_item() )*  <BEGIN_T>] (concurrent_statement())*
+   generate_statement_body()   generate_scheme_1()  [generate_scheme_2()]
+}
+
+void generate_scheme_1() : {}
+{
+ (LOOKAHEAD(generate_scheme_3()) generate_scheme_3())*
+}
+
+void generate_scheme_2() : {}
+{
+<ELSE_T> [LOOKAHEAD(2) identifier() <COLON_T> ] <GENERATE_T> generate_statement_body()
+}
 
-   [(LOOKAHEAD(block_declarative_item())block_declarative_item() )*  <BEGIN_T>] (concurrent_statement())*
-  // | (concurrent_statement())*
+void generate_scheme_3() : {}
+{
+ <ELSIF_T>[LOOKAHEAD(2) identifier() <COLON_T> ] expression() <GENERATE_T> generate_statement_body()
 }
 
+               
 QCString external_name(): {QCString s,s1,s2;}
 {
  <SLSL_T> s=sig_stat() s1=external_pathname() <COLON_T>  s2=subtype_indication()  <RSRS_T>
