~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to AspectC++/MatchExpr.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:
18
18
 
19
19
#include "MatchExpr.h"
20
20
 
 
21
#include <string.h>
 
22
 
21
23
// parse a match expression string
22
24
// complain about errors => result false
23
 
bool MatchExpr::parse (ErrorStream &err, Location loc, const char *str) {
 
25
bool MatchSignature::parse (ErrorStream &err, Location loc, const char *str) {
24
26
  if (parse_match_expr (str)) {
25
27
    // perform argument conversions, warn if any conversion are applied
26
28
    bool f = false, a = false, q = false, v = false;
103
105
        msg = "syntax error";
104
106
    }
105
107
    err << sev_error << loc
106
 
        << "invalid match expression, " << msg << endMessage;
 
108
        << "invalid match expression \"" << str << "\", " << msg 
 
109
        << endMessage;
 
110
    cout << 10/str[0];
107
111
    return false;
108
112
  }
109
113
  _state = NORMAL;
112
116
 
113
117
  
114
118
// internal parser functions that analyse a match expr string
115
 
bool MatchExpr::parse_match_expr (const char *&str) {
 
119
bool MatchSignature::parse_match_expr (const char *&str) {
116
120
  MatchTypeRef type;
117
121
  if (!parse_declaration (str, false, type)) {
118
122
    if (!error ())
133
137
  return true;
134
138
}
135
139
 
136
 
bool MatchExpr::parse_declaration (const char *&str, bool abstract,
 
140
bool MatchSignature::parse_declaration (const char *&str, bool abstract,
137
141
                                   MatchTypeRef &type) {
138
142
  // decl_spec_seq_opt declarator_opt
139
143
  FctSpec fct_spec;
163
167
  return true;
164
168
}
165
169
 
166
 
bool MatchExpr::parse_decl_spec_seq (const char *&str, MatchTypeRef &type,
 
170
bool MatchSignature::parse_decl_spec_seq (const char *&str, MatchTypeRef &type,
167
171
  FctSpec &fs) {
168
172
 
169
173
  DeclSpecs ds; // semantic knowledge about the decl spec seq
273
277
  return true;
274
278
}
275
279
 
276
 
bool MatchExpr::parse_decl_spec (const char *&str, DeclSpecs &ds) {
 
280
bool MatchSignature::parse_decl_spec (const char *&str, DeclSpecs &ds) {
277
281
  // remember the current value of this flag as it might be changed
278
282
  bool name_allowed = ds._allow_name;
279
283
  
402
406
  return false;
403
407
}
404
408
 
405
 
bool MatchExpr::parse_nested_name (const char *&str, MatchName &match_name) {
 
409
bool MatchSignature::parse_nested_name (const char *&str, MatchName &match_name) {
406
410
  bool have_nested_name = false;
407
411
  while (parse_nested_name_elem (str, match_name))
408
412
    have_nested_name = true;
409
413
  return have_nested_name;
410
414
}
411
415
 
412
 
bool MatchExpr::parse_nested_name_elem (const char *&str, MatchName &match_name) {
 
416
bool MatchSignature::parse_nested_name_elem (const char *&str, MatchName &match_name) {
413
417
  skip_blanks (str);
414
418
  // check for ellipses first
415
419
  if (str[0] == '.') {
452
456
  return true;
453
457
}
454
458
 
455
 
bool MatchExpr::parse_opt_template_argument_list (const char *&str,
 
459
bool MatchSignature::parse_opt_template_argument_list (const char *&str,
456
460
                                                   MatchTemplateArgList *&mtal) {
457
461
  skip_blanks (str);
458
462
  mtal = 0;
476
480
  return true;
477
481
}
478
482
 
479
 
bool MatchExpr::parse_template_argument_list (const char *&str,
 
483
bool MatchSignature::parse_template_argument_list (const char *&str,
480
484
                                               MatchTemplateArgList &mtal) {
481
485
  MatchTemplateArg *mta;
482
486
  if (!parse_template_argument (str, mta))
496
500
  return true;
497
501
}
498
502
 
499
 
bool MatchExpr::parse_template_argument (const char *&str,
 
503
bool MatchSignature::parse_template_argument (const char *&str,
500
504
                                          MatchTemplateArg *&mta) {
501
505
  mta = 0;
502
506
  skip_blanks (str);
543
547
  return true;
544
548
}
545
549
 
546
 
bool MatchExpr::parse_dec_literal (const char *&str, long long &val) {
 
550
bool MatchSignature::parse_dec_literal (const char *&str, long long &val) {
547
551
  skip_blanks (str);
548
552
  long long sign = 1;
549
553
  
565
569
  return true;
566
570
}
567
571
 
568
 
bool MatchExpr::parse_declarator (const char *&str, bool abstract,
 
572
bool MatchSignature::parse_declarator (const char *&str, bool abstract,
569
573
                                  MatchTypeRef &type) {
570
574
  // first parse an optional sequence of pointer operators like '*'
571
575
  // the type from the decl specs is simply extended.
620
624
  return true;
621
625
}
622
626
 
623
 
bool MatchExpr::skip_nested_declarator (const char *&str) {
 
627
bool MatchSignature::skip_nested_declarator (const char *&str) {
624
628
  int brackets = 1;
625
629
  str++;
626
630
  while (*str) {
635
639
  return false; 
636
640
}
637
641
 
638
 
bool MatchExpr::parse_declarator_post (const char *&str, MatchTypeRef &type) {
 
642
bool MatchSignature::parse_declarator_post (const char *&str, MatchTypeRef &type) {
639
643
  skip_blanks (str);
640
644
  if (*str == '(') { // analyse a function declarator
641
645
    str++;
724
728
  return false;
725
729
}
726
730
 
727
 
bool MatchExpr::parse_ptr_operator (const char *&str, MatchTypeRef &type) {
 
731
bool MatchSignature::parse_ptr_operator (const char *&str, MatchTypeRef &type) {
728
732
  skip_blanks (str);
729
733
  const char *curr = str;
730
734
  MatchName memb_ptr_scope;
758
762
  return false;
759
763
}
760
764
 
761
 
bool MatchExpr::parse_declarator_id (const char *&str, MatchName &match_name) {
 
765
bool MatchSignature::parse_declarator_id (const char *&str, MatchName &match_name) {
762
766
  skip_blanks (str);
763
767
  // first check if this is a qualified name 
764
768
  const char *curr = str;
810
814
  return true;
811
815
}
812
816
 
813
 
bool MatchExpr::parse_conv_id (const char *&str, MatchTypeRef &type) {
 
817
bool MatchSignature::parse_conv_id (const char *&str, MatchTypeRef &type) {
814
818
  // decl_spec_seq_opt declarator_opt
815
819
  const char *curr = str;
816
820
  FctSpec fct_spec;
834
838
  return true;
835
839
}
836
840
 
837
 
bool MatchExpr::parse_operator_id (const char *&str, MatchName::Operator &op) {
 
841
bool MatchSignature::parse_operator_id (const char *&str, MatchName::Operator &op) {
838
842
    
839
843
  // first check for new and delete
840
844
  bool op_new = false, op_delete = false;
1029
1033
  return false;
1030
1034
}
1031
1035
 
1032
 
bool MatchExpr::parse_fct_args (const char *&str, vector<MatchTypeRef> &args,
 
1036
bool MatchSignature::parse_fct_args (const char *&str, vector<MatchTypeRef> &args,
1033
1037
                                bool &var_args) {
1034
1038
  int arg = 0;
1035
1039
  bool have_ellipses = false;
1079
1083
  return true;
1080
1084
}
1081
1085
 
1082
 
bool MatchExpr::parse_ellipses (const char *&str) {
 
1086
bool MatchSignature::parse_ellipses (const char *&str) {
1083
1087
  const char *curr = str;
1084
1088
  if (*curr++ != '.')
1085
1089
    return false;
1098
1102
  return true;
1099
1103
}
1100
1104
 
1101
 
inline void MatchExpr::skip_blanks (const char *&str) const {
 
1105
inline void MatchSignature::skip_blanks (const char *&str) const {
1102
1106
  while (*str == ' ') str++;
1103
1107
}
1104
1108
 
1105
 
inline bool MatchExpr::next_word (const char *word, const char *&str) const {
 
1109
inline bool MatchSignature::next_word (const char *word, const char *&str) const {
1106
1110
  const char *curr = str;
1107
1111
  while (*word != '\0' && *curr == *word) {
1108
1112
    curr++;
1116
1120
    return false;
1117
1121
}
1118
1122
 
1119
 
inline bool MatchExpr::is_id (char c) const {
 
1123
inline bool MatchSignature::is_id (char c) const {
1120
1124
  return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
1121
1125
          c == '_' || c == '%' || (c >= '0' && c <= '9'));
1122
1126
}