Logo Search packages:      
Sourcecode: yapps2 version File versions  Download package

def yapps::runtime::Scanner::__init__ (   self,
  patterns,
  ignore,
  input = "",
  file = None,
  filename = None,
  stacked = False 
)

Initialize the scanner.

Parameters:
  patterns : [(terminal, uncompiled regex), ...] or None
  ignore : {terminal:None, ...}
  input : string

If patterns is None, we assume that the subclass has
defined self.patterns : [(terminal, compiled regex), ...].
Note that the patterns parameter expects uncompiled regexes,
whereas the self.patterns field expects compiled regexes.

The 'ignore' value is either None or a callable, which is called
with the scanner and the to-be-ignored match object; this can
be used for include file or comment handling.

Definition at line 79 of file runtime.py.

                                                        :
            """Initialize the scanner.

            Parameters:
              patterns : [(terminal, uncompiled regex), ...] or None
              ignore : {terminal:None, ...}
              input : string

            If patterns is None, we assume that the subclass has
            defined self.patterns : [(terminal, compiled regex), ...].
            Note that the patterns parameter expects uncompiled regexes,
            whereas the self.patterns field expects compiled regexes.

            The 'ignore' value is either None or a callable, which is called
            with the scanner and the to-be-ignored match object; this can
            be used for include file or comment handling.
            """

            if not filename:
                  global in_name
                  filename="<f.%d>" % in_name
                  in_name += 1

            self.input = input
            self.ignore = ignore
            self.file = file
            self.filename = filename
            self.pos = 0
            self.del_pos = 0 # skipped
            self.line = 1
            self.del_line = 0 # skipped
            self.col = 0
            self.tokens = []
            self.stack = None
            self.stacked = stacked
            
            self.last_read_token = None
            self.last_token = None
            self.last_types = None

            if patterns is not None:
                  # Compile the regex strings into regex objects
                  self.patterns = []
                  for terminal, regex in patterns:
                        self.patterns.append( (terminal, re.compile(regex)) )

      def stack_input(self, input="", file=None, filename=None):


Generated by  Doxygen 1.6.0   Back to index