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

def runtime::Scanner::__init__ (   self,
  patterns,
  ignore,
  input 
)

Initialize the scanner.

Parameters:
  patterns : [(terminal, uncompiled regex), ...] or None
  ignore : [terminal,...]
  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.

Definition at line 50 of file runtime.py.

00050                                                :
        """Initialize the scanner.

        Parameters:
          patterns : [(terminal, uncompiled regex), ...] or None
          ignore : [terminal,...]
          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.
        """
        self.tokens = [] # [(begin char pos, end char pos, token name, matched text), ...]
        self.restrictions = []
        self.input = input
        self.pos = 0
        self.ignore = ignore
        self.first_line_number = 1
        
        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 get_token_pos(self):


Generated by  Doxygen 1.6.0   Back to index