Skip to content
Snippets Groups Projects
Select Git revision
  • dualcore
  • ch3/leds
  • wip-bootstrap default
  • ch3/time
  • master
5 results

vfs_reader.c

Blame
    • Damien George's avatar
      1831034b
      py: Allow lexer to raise exceptions during construction. · 1831034b
      Damien George authored
      This patch refactors the error handling in the lexer, to simplify it (ie
      reduce code size).
      
      A long time ago, when the lexer/parser/compiler were first written, the
      lexer and parser were designed so they didn't use exceptions (ie nlr) to
      report errors but rather returned an error code.  Over time that has
      gradually changed, the parser in particular has more and more ways of
      raising exceptions.  Also, the lexer never really handled all errors without
      raising, eg there were some memory errors which could raise an exception
      (and in these rare cases one would get a fatal nlr-not-handled fault).
      
      This patch accepts the fact that the lexer can raise exceptions in some
      cases and allows it to raise exceptions to handle all its errors, which are
      for the most part just out-of-memory errors during construction of the
      lexer.  This makes the lexer a bit simpler, and also the persistent code
      stuff is simplified.
      
      What this means for users of the lexer is that calls to it must be wrapped
      in a nlr handler.  But all uses of the lexer already have such an nlr
      handler for the parser (and compiler) so that doesn't put any extra burden
      on the callers.
      1831034b
      History
      py: Allow lexer to raise exceptions during construction.
      Damien George authored
      This patch refactors the error handling in the lexer, to simplify it (ie
      reduce code size).
      
      A long time ago, when the lexer/parser/compiler were first written, the
      lexer and parser were designed so they didn't use exceptions (ie nlr) to
      report errors but rather returned an error code.  Over time that has
      gradually changed, the parser in particular has more and more ways of
      raising exceptions.  Also, the lexer never really handled all errors without
      raising, eg there were some memory errors which could raise an exception
      (and in these rare cases one would get a fatal nlr-not-handled fault).
      
      This patch accepts the fact that the lexer can raise exceptions in some
      cases and allows it to raise exceptions to handle all its errors, which are
      for the most part just out-of-memory errors during construction of the
      lexer.  This makes the lexer a bit simpler, and also the persistent code
      stuff is simplified.
      
      What this means for users of the lexer is that calls to it must be wrapped
      in a nlr handler.  But all uses of the lexer already have such an nlr
      handler for the parser (and compiler) so that doesn't put any extra burden
      on the callers.