Hi,

> How can i tell Bison that that it has to look for the indentations? Has
> anyone maybe an example that he/she can send me ? it would be very helpful,
> because i havent seen such an example.

Whitespace is usually handled by the lexer, in this case you need an
indication of the amount of leading whitespace for each line.

For example you could generate INDENT and DEDENT tokens (if I remember
right this is how it's done in python). An INDENT token would be
generated if the indentation level increases, a DEDENT if it decreases.

So the if would look roughly like:

if : IF INDENT stmt_list DEDENT


The lexer has to store the last seen indentation level and check the
indentation at each line:

if(current_indent < stored_indent) {
        stored_indent = current_indent;
        return DEDENT;
}
if(current_indent > stored_indent) {
        stored_indent = current_indent;
        return INDENT;
}

regards
Istvan


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to