title: Indentation control while developing a small python like language
body: <p>I'm developing a small python like language using flex, byacc (for lexical and parsing) and C++, but i have a few questions regarding scope control.</p>
  
  <p>just as python it uses white spaces (or tabs) for indentation, not only that but i want to implement index breaking like for instance if you type "break 2" inside a while loop that's inside another while loop it would not only break from the last one but from the first loop as well (hence the number 2 after break) and so on.</p>
  
  <p>example:</p>
  
  <pre><code>while 1
      while 1
          break 2
          'hello world'!! #will never reach this. "!!" outputs with a newline
      end
      'hello world again'!! #also will never reach this. again "!!" used for cout
  end
  #after break 2 it would jump right here
  </code></pre>
  
  <p>but since I don't have an "anti" tab character to check when a scope ends (like C for example i would just use the '}' char) i was wondering if this method would the the best:</p>
  
  <p>I would define a global variable, like "int tabIndex" on my yacc file that i would access in my lex file using extern. then every time i find a tab character on my lex file i would increment that variable by 1. when parsing on my yacc file if i find a "break" keyword i would decrement by the amount typed after it from the tabIndex variable, and when i reach and EOF after compiling and i get a tabIndex != 0 i would output compilation error.</p>
  
  <p>now the problem is, whats the best way to see if the indentation got reduced, should i read \b (backspace) chars from lex and then reduce the tabIndex variable (when the user doesn't use break)?</p>
  
  <p>another method to achieve this?</p>
  
  <p>also just another small question, i want every executable to have its starting point on the function called start() should i hardcode this onto my yacc file?</p>
  
  <p>sorry for the long question any help is greatly appreciated. also if someone can provide an yacc file for python would be nice as a guideline (tried looking on Google and had no luck).</p>
  
  <p>thanks in advance.</p>