void MutableVars::PrintValues(std::ostream & out, std::string const& pre, std::string const& sep) const { table_type::const_iterator item(table->begin()); for(; item != table->end(); item++) { // out << pre << (*item).first << sep; (*item).second.print(out, pre + (*item).first + sep); if( (*item).second.description() != "") out << " " << comment_start() << " " << (*item).second.description() << " " << comment_end(); out << "\n"; } }
static int phase2_getc () { int c; bool last_was_star; c = phase1_getc (); if (c != '/') return c; c = phase1_getc (); switch (c) { default: phase1_ungetc (c); return '/'; case '*': /* C comment. */ comment_start (); last_was_star = false; for (;;) { c = phase1_getc (); if (c == EOF) break; /* We skip all leading white space, but not EOLs. */ if (!(buflen == 0 && (c == ' ' || c == '\t'))) comment_add (c); switch (c) { case '\n': comment_line_end (1); comment_start (); last_was_star = false; continue; case '*': last_was_star = true; continue; case '/': if (last_was_star) { comment_line_end (2); break; } /* FALLTHROUGH */ default: last_was_star = false; continue; } break; } last_comment_line = line_number; return ' '; case '/': /* C++ or ISO C 99 comment. */ comment_start (); for (;;) { c = phase1_getc (); if (c == '\n' || c == EOF) break; /* We skip all leading white space, but not EOLs. */ if (!(buflen == 0 && (c == ' ' || c == '\t'))) comment_add (c); } comment_line_end (0); last_comment_line = line_number; return '\n'; } }
static void phase2_get (token_ty *tp) { static char *buffer; static int bufmax; int bufpos; int c; if (phase2_pushback_length) { *tp = phase2_pushback[--phase2_pushback_length]; return; } tp->string = NULL; for (;;) { tp->line_number = line_number; c = phase1_getc (); switch (c) { case EOF: tp->type = token_type_eof; return; case '"': { /* Comment. */ int lineno; comment_start (); lineno = line_number; for (;;) { c = phase1_getc (); if (c == '"' || c == EOF) break; if (c == '\n') { comment_line_end (); comment_start (); } else { /* We skip all leading white space, but not EOLs. */ if (!(buflen == 0 && (c == ' ' || c == '\t'))) comment_add (c); } } comment_line_end (); last_comment_line = lineno; continue; } case '\n': if (last_non_comment_line > last_comment_line) savable_comment_reset (); /* FALLTHROUGH */ case ' ': case '\t': case '\r': /* Ignore whitespace. */ continue; } last_non_comment_line = tp->line_number; switch (c) { case '\'': /* String literal. */ bufpos = 0; for (;;) { c = phase1_getc (); if (c == EOF) break; if (c == '\'') { c = phase1_getc (); if (c != '\'') { phase1_ungetc (c); break; } } if (bufpos >= bufmax) { bufmax = 2 * bufmax + 10; buffer = xrealloc (buffer, bufmax); } buffer[bufpos++] = c; } if (bufpos >= bufmax) { bufmax = 2 * bufmax + 10; buffer = xrealloc (buffer, bufmax); } buffer[bufpos] = 0; tp->type = token_type_string_literal; tp->string = xstrdup (buffer); return; case '+': case '-': case '*': case '/': case '~': case '|': case ',': case '<': case '>': case '=': case '&': case '@': case '?': case '%': case '\\': { char *name; int c2 = phase1_getc (); switch (c2) { case '+': case '-': case '*': case '/': case '~': case '|': case ',': case '<': case '>': case '=': case '&': case '@': case '?': case '%': name = xmalloc (3); name[0] = c; name[1] = c2; name[2] = '\0'; tp->type = token_type_symbol; tp->string = name; return; default: phase1_ungetc (c2); break; } name = xmalloc (2); name[0] = c; name[1] = '\0'; tp->type = token_type_symbol; tp->string = name; return; } case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* Recognize id or id":"[id":"]* or id":"[id":"]*id. */ bufpos = 0; for (;;) { if (bufpos >= bufmax) { bufmax = 2 * bufmax + 10; buffer = xrealloc (buffer, bufmax); } buffer[bufpos++] = c; c = phase1_getc (); switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': continue; case ':': if (bufpos >= bufmax) { bufmax = 2 * bufmax + 10; buffer = xrealloc (buffer, bufmax); } buffer[bufpos++] = c; c = phase1_getc (); switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': continue; default: phase1_ungetc (c); break; } break; default: phase1_ungetc (c); break; } break; } if (bufpos >= bufmax) { bufmax = 2 * bufmax + 10; buffer = xrealloc (buffer, bufmax); } buffer[bufpos] = '\0'; tp->string = xstrdup (buffer); tp->type = token_type_symbol; return; case '#': /* Uniquification operator. */ tp->type = token_type_uniq; return; case '$': c = phase1_getc (); tp->type = token_type_other; return; default: tp->type = token_type_other; return; } } }
static int phase3_getc () { int lineno; int c; if (phase3_pushback_length) return phase3_pushback[--phase3_pushback_length]; c = phase1_getc (); if (c == '#') { /* sh comment. */ bool last_was_qmark = false; comment_start (); lineno = line_number; for (;;) { c = phase1_getc (); if (c == '\n' || c == EOF) { comment_line_end (0); break; } if (last_was_qmark && c == '>') { comment_line_end (1); skip_html (); break; } /* We skip all leading white space, but not EOLs. */ if (!(buflen == 0 && (c == ' ' || c == '\t'))) comment_add (c); last_was_qmark = (c == '?' || c == '%'); } last_comment_line = lineno; return '\n'; } else if (c == '/') { c = phase1_getc (); switch (c) { default: phase1_ungetc (c); return '/'; case '*': { /* C comment. */ bool last_was_star; comment_start (); lineno = line_number; last_was_star = false; for (;;) { c = phase1_getc (); if (c == EOF) break; /* We skip all leading white space, but not EOLs. */ if (buflen == 0 && (c == ' ' || c == '\t')) continue; comment_add (c); switch (c) { case '\n': comment_line_end (1); comment_start (); lineno = line_number; last_was_star = false; continue; case '*': last_was_star = true; continue; case '/': if (last_was_star) { comment_line_end (2); break; } /* FALLTHROUGH */ default: last_was_star = false; continue; } break; } last_comment_line = lineno; return ' '; } case '/': { /* C++ comment. */ bool last_was_qmark = false; comment_start (); lineno = line_number; for (;;) { c = phase1_getc (); if (c == '\n' || c == EOF) { comment_line_end (0); break; } if (last_was_qmark && c == '>') { comment_line_end (1); skip_html (); break; } /* We skip all leading white space, but not EOLs. */ if (!(buflen == 0 && (c == ' ' || c == '\t'))) comment_add (c); last_was_qmark = (c == '?' || c == '%'); } last_comment_line = lineno; return '\n'; } } } else return c; }
static int phase2_getc () { int c; int lineno; c = phase1_getc (); if (c == '-') { c = phase1_getc (); if (c == '-') { /* It starts with '--', so it must be either a short or a long comment. */ c = phase1_getc (); if (c == '[') { c = phase1_getc (); int esigns = 0; while (c == '=') { esigns++; c = phase1_getc (); } if (c == '[') { /* Long comment. */ bool right_bracket = false; bool end = false; int esigns2 = 0; lineno = line_number; comment_start (); while (!end) { c = phase1_getc (); if (c == EOF) break; /* Ignore leading spaces and tabs. */ if (buflen == 0 && (c == ' ' || c == '\t')) continue; comment_add (c); switch (c) { case ']': if (!right_bracket) { right_bracket = true; esigns2 = 0; } else { if (esigns2 == esigns) { comment_line_end (2 + esigns); end = true; } } break; case '=': if (right_bracket) esigns2++; break; case '\n': comment_line_end (1); comment_start (); lineno = line_number; /* Intentionally not breaking. */ default: right_bracket = false; } } last_comment_line = lineno; return ' '; } else { /* One line (short) comment, starting with '--[=...='. */ lineno = last_comment_line; comment_start (); comment_add ('['); while (esigns--) comment_add ('='); phase1_ungetc (c); eat_comment_line (); last_comment_line = lineno; return '\n'; } } else { /* One line (short) comment. */ lineno = line_number; comment_start (); phase1_ungetc (c); eat_comment_line (); last_comment_line = lineno; return '\n'; } } else { /* Minus sign. */ phase1_ungetc (c); return '-'; } } else return c; }