emit NEWLINE and deal with indentation
| 97 | |
| 98 | // emit NEWLINE and deal with indentation |
| 99 | static void process_newline(unsigned indent) |
| 100 | { |
| 101 | emit("NEWLINE", linenr-1, saved_col); |
| 102 | |
| 103 | unsigned last_indent = indents_top(); // maybe 0 |
| 104 | |
| 105 | if (indent > last_indent) { |
| 106 | indents_push(indent); |
| 107 | emit("INDENT", linenr, column-1); |
| 108 | // Here: !empty() && top() == indent |
| 109 | } |
| 110 | else |
| 111 | if (indent < last_indent) { |
| 112 | // Here: indent < last_indent => !empty() && indent < top() |
| 113 | do { |
| 114 | emit("DEDENT", linenr, column ? column-1 : 0); |
| 115 | indents_pop(); |
| 116 | } while (indent < indents_top()); |
| 117 | // Here: empty() || indent >= top() |
| 118 | if (indent > indents_top() && !nowarn) |
| 119 | fprintf(stderr, "(W): Incorrect indentation.\n"); |
| 120 | } |
| 121 | // else: indent == last_indent: no action |
| 122 | } |
| 123 | |
| 124 | // cc in [ \t\f] |
| 125 | static int process_ws(int cc) |
no test coverage detected