MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / process_newline

Function process_newline

tools/tokenizer/pytokenize.c:99–122  ·  view source on GitHub ↗

emit NEWLINE and deal with indentation

Source from the content-addressed store, hash-verified

97
98// emit NEWLINE and deal with indentation
99static 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]
125static int process_ws(int cc)

Callers 2

process_wsFunction · 0.85
tokenizeFunction · 0.85

Calls 1

emitFunction · 0.85

Tested by

no test coverage detected