~ubuntu-branches/ubuntu/quantal/aspectc++/quantal

« back to all changes in this revision

Viewing changes to Puma/src/parser/ccparser/CCSyntax.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    _skip_bodies |= SKIP_BODIES_TPL;
51
51
  else if (config.Option ("--skip-bodies-non-prj"))
52
52
    _skip_bodies |= SKIP_BODIES_NON_PRJ;
 
53
  else if (config.Option ("--skip-bodies-non-prim"))
 
54
    _skip_bodies |= SKIP_BODIES_NON_PRIM;
53
55
  
54
56
  // FIRST set initialization  
55
57
  init_namespace_def ();   
114
116
  skip (stop_tokens, false);
115
117
}
116
118
 
 
119
bool CCSyntax::is_fct_def () {
 
120
  State s = token_provider->get_state ();
 
121
  bool result = false, braces = false;
 
122
  Token *current;
 
123
  int token;
 
124
 
 
125
  while ((current = token_provider->current ())) {
 
126
    token = current->type ();
 
127
    
 
128
    // only declaration
 
129
    if (token == TOK_SEMI_COLON || 
 
130
        token == TOK_COMMA ||
 
131
        token == TOK_TYPEDEF ||
 
132
        // TODO: checking the AspectC++ tokens here is really bad style
 
133
        token == TOK_ADVICE ||
 
134
        token == TOK_POINTCUT ||
 
135
        token == TOK_SLICE ||
 
136
        // --
 
137
        (! braces && token == TOK_ASSIGN)) {
 
138
      break;
 
139
    // operator name
 
140
    } else if (token == TOK_OPERATOR) {
 
141
      skip (TOK_OPEN_ROUND, false);
 
142
    // function `try' block, function body..
 
143
    } else if (token == TOK_TRY || (braces && 
 
144
               (token == TOK_OPEN_CURLY || token == TOK_COLON))) {
 
145
      result = true;
 
146
      break;
 
147
    // class definition in function return type
 
148
    } else if (token == TOK_OPEN_CURLY && ! braces) {
 
149
      skip_curly_block ();
 
150
    // member initialization list
 
151
    } else if (token == TOK_COLON && braces) {
 
152
      skip (TOK_OPEN_CURLY, false);
 
153
    // array delimiter
 
154
    } else if (token == TOK_OPEN_SQUARE) {
 
155
      skip_block (TOK_OPEN_SQUARE, TOK_CLOSE_SQUARE);
 
156
    // template-id
 
157
    } else if (token == TOK_LESS) {
 
158
      skip_block (TOK_LESS, TOK_GREATER);
 
159
    // function parameter list
 
160
    } else if (token == TOK_OPEN_ROUND) {
 
161
      skip_round_block ();
 
162
      braces = true;
 
163
    // throw expression
 
164
    } else if (token == TOK_THROW) {
 
165
      skip ();
 
166
      skip_round_block (); 
 
167
    // asm declaration specifier
 
168
    } else if (token == TOK_ASM) {
 
169
      skip ();
 
170
      skip_round_block ();
 
171
    // names etc.
 
172
    } else {
 
173
      token_provider->next ();
 
174
      locate_token ();
 
175
    }
 
176
  }
 
177
 
 
178
  token_provider->set_state (s);
 
179
  return result;
 
180
}
 
181
 
117
182
bool CCSyntax::is_nested (State first) {
118
183
  int token, braces, curlies, squares;
119
184
  Token *current;
888
953
  static int any_ass_op[] = { TOK_ASSIGN, TOK_MUL_EQ, TOK_DIV_EQ, TOK_MOD_EQ, 
889
954
                              TOK_ADD_EQ, TOK_SUB_EQ, TOK_RSH_EQ, TOK_LSH_EQ,
890
955
                              TOK_AND_EQ, TOK_XOR_EQ, TOK_IOR_EQ, 0 };
891
 
  return (parse (&CCSyntax::log_or_expr) && parse (any_ass_op)) ? 
 
956
  return (is_ass_expr () && parse (&CCSyntax::log_or_expr) && parse (any_ass_op)) ? 
892
957
    builder ().ass_expr1 () : (CTree*)0;
893
958
}
894
959
 
1001
1066
                  explicit_instantiation () ||
1002
1067
                  namespace_def () ||
1003
1068
                  parse (&CCSyntax::linkage_spec) ||
1004
 
                  (is_fct_def () ? parse (&CCSyntax::fct_def) :
1005
 
                   (parse (&CCSyntax::block_decl)/* ||
1006
 
                    parse (&CCSyntax::fct_def)*/)))); 
 
1069
                  (is_fct_def () ? 
 
1070
                   (parse (&CCSyntax::fct_def) ||
 
1071
                    parse (&CCSyntax::block_decl)) :
 
1072
                   (parse (&CCSyntax::block_decl) ||
 
1073
                    parse (&CCSyntax::fct_def))))); 
1007
1074
  if (extern_decl)
1008
1075
    semantic ().leave_extern_decl ();
1009
1076
  return parsed ? 
1163
1230
    semantic ().enumerator_def () : (CTree*)0;
1164
1231
}
1165
1232
 
1166
 
CTree *CCSyntax::asm_def () {
1167
 
  // 1: ASM  (  str_literal  )  ;
1168
 
  return (parse (TOK_ASM) && 
1169
 
          parse (TOK_OPEN_ROUND) && str_literal () && 
1170
 
          parse (TOK_CLOSE_ROUND) && parse (TOK_SEMI_COLON)) ?
1171
 
    builder ().asm_def () : (CTree*)0;
1172
 
}
1173
 
 
1174
1233
CTree *CCSyntax::linkage_spec () {
1175
1234
  // 4: EXTERN  str_literal  {  }
1176
1235
  // 5: EXTERN  str_literal  {  decl_seq  }
1506
1565
  bool skip_fct_bodies = false;
1507
1566
  if ((_skip_bodies & SKIP_BODIES_ALL) ||
1508
1567
      ((_skip_bodies & SKIP_BODIES_TPL) && semantic ().skip_tpl_fct_bodies ()) ||
1509
 
      ((_skip_bodies & SKIP_BODIES_NON_PRJ) && semantic ().non_project_loc ()))
 
1568
      ((_skip_bodies & SKIP_BODIES_NON_PRJ) && semantic ().non_project_loc ()) ||
 
1569
      ((_skip_bodies & SKIP_BODIES_NON_PRIM) && semantic ().non_primary_loc ()))
1510
1570
    skip_fct_bodies = true;
1511
1571
 
1512
1572
  // parse fct_body and ctor_init later due to potential use of names 
1622
1682
  if (parsed && (look_ahead (TOK_OPEN_CURLY) || look_ahead (TOK_COLON))) {
1623
1683
    CTree *cs = semantic ().introduce_class ();
1624
1684
    if (cs) {
1625
 
      if (parse (&CCSyntax::base_clause))
1626
 
        semantic ().add_base_classes (cs);
 
1685
      parse (&CCSyntax::base_clause);
 
1686
      semantic ().add_base_classes (cs);
1627
1687
      return cs;
1628
1688
    }
1629
1689
  } 
1706
1766
  // definition
1707
1767
  if (semantic ().in_class_def () && ! bitfield) { 
1708
1768
    if (parse (&CCSyntax::declarator)) {
 
1769
      // optional extensions
 
1770
      parse (&CCSyntax::init_declarator_ext);
1709
1771
      // constant initializer
1710
1772
      if (! parse (&CCSyntax::pure_spec) && look_ahead (TOK_ASSIGN)) {
1711
1773
        md = (CT_InitDeclarator*)semantic ().introduce_member ();
1731
1793
        return semantic ().introduce_member ();
1732
1794
    } else {
1733
1795
      if (parse (&CCSyntax::declarator) &&
 
1796
          opt (parse (&CCSyntax::init_declarator_ext)) &&
1734
1797
          opt (parse (&CCSyntax::pure_spec) || 
1735
1798
               parse (&CCSyntax::const_init)))
1736
1799
        return semantic ().introduce_member ();
1791
1854
  // 4: access_spec  VIRTUAL  ::  class_name
1792
1855
  // 5: VIRTUAL  access_spec  ::  nested_name_spec  class_name
1793
1856
  // 5: access_spec  VIRTUAL  ::  nested_name_spec  class_name
1794
 
  bool ok = 
1795
 
    ((parse (TOK_VIRTUAL) ? opt (access_spec ()) :
1796
 
      (access_spec () ? opt (parse (TOK_VIRTUAL)) : true)) &&
1797
 
     (colon_colon (), nested_name_spec (), class_name ()));
 
1857
  bool ok = false;
 
1858
  if (parse (TOK_VIRTUAL) ? opt (access_spec ()) :
 
1859
      (access_spec () ? opt (parse (TOK_VIRTUAL)) : true)) {
 
1860
    colon_colon ();
 
1861
    nested_name_spec ();
 
1862
    semantic ().enter_base_spec ();
 
1863
    ok = class_name ();
 
1864
    semantic ().leave_base_spec ();
 
1865
  }
1798
1866
  semantic ().reset_search_scope ();
1799
1867
  return ok ? builder ().base_spec () : (CTree*)0;
1800
1868
}
2181
2249
  bool skip_fct_bodies = false;
2182
2250
  if ((_skip_bodies & SKIP_BODIES_ALL) ||
2183
2251
      ((_skip_bodies & SKIP_BODIES_TPL) && semantic ().skip_tpl_fct_bodies ()) ||
2184
 
      ((_skip_bodies & SKIP_BODIES_NON_PRJ) && semantic ().non_project_loc ()))
 
2252
      ((_skip_bodies & SKIP_BODIES_NON_PRJ) && semantic ().non_project_loc ()) ||
 
2253
      ((_skip_bodies & SKIP_BODIES_NON_PRIM) && semantic ().non_primary_loc ()))
2185
2254
    skip_fct_bodies = true;
2186
2255
  return (parse (TOK_TRY) && opt (parse (&CCSyntax::ctor_init)) && 
2187
2256
          parse (skip_fct_bodies ?