コード例 #1
0
ファイル: srcparser.py プロジェクト: beppec56/openoffice
 def expandMacro (self):
     macroExp = MacroExpander(self.tokens, self.defines)
     macroExp.expand()
     self.tokens = macroExp.getTokens()
     if self.onlyExpandMacros:
         srclexer.dumpTokens(self.tokens)
         sys.exit(0)
コード例 #2
0
 def expandMacro (self):
     macroExp = MacroExpander(self.tokens, self.defines)
     macroExp.expand()
     self.tokens = macroExp.getTokens()
     if self.onlyExpandMacros:
         srclexer.dumpTokens(self.tokens)
         sys.exit(0)
コード例 #3
0
ファイル: srcparser.py プロジェクト: beppec56/openoffice
    def parseValues (self):
        """Parse tokens to get macro function variable values.

Be aware that there is an implicit quotes around the text between the open
paren, the comma(s), and the close paren.  For instance, if a macro is defined
as FOO(a, b) and is used as FOO(one two three, and four), then the 'a' must be
replaced with 'one two three', and the 'b' replaced with 'and four'.  In other
words, whitespace does not end a token.

"""
        values = []
        i = 1
        scope = 0
        value = []
        while True:
            try:
                tk = self.tokens[self.pos+i]
            except IndexError:
                progress ("error parsing values (%d)\n"%i)
                for j in range(0, i):
                    print(self.tokens[self.pos+j], end=' ')
                print('')
                srclexer.dumpTokens(self.tokens)
                srclexer.dumpTokens(self.newtokens)
                print("tokens expanded so far:")
                for tk in self.expandedTokens:
                    print("-"*20)
                    print(tk)
                    srclexer.dumpTokens(self.defines[tk].tokens)
                sys.exit(1)
            if tk == '(':
                value = []
                scope += 1
            elif tk == ',':
                values.append(value)
                value = []
            elif tk == ')':
                scope -= 1
                values.append(value)
                value = []
                if scope == 0:
                    break
                else:
                    raise ParseError ('')
            else:
                value.append(tk)
            i += 1

        return values, i
コード例 #4
0
    def parseValues (self):
        """Parse tokens to get macro function variable values.

Be aware that there is an implicit quotes around the text between the open 
paren, the comma(s), and the close paren.  For instance, if a macro is defined 
as FOO(a, b) and is used as FOO(one two three, and four), then the 'a' must be 
replaced with 'one two three', and the 'b' replaced with 'and four'.  In other 
words, whitespace does not end a token.  

"""
        values = []
        i = 1
        scope = 0
        value = []
        while True:
            try:
                tk = self.tokens[self.pos+i]
            except IndexError:
                progress ("error parsing values (%d)\n"%i)
                for j in xrange(0, i):
                    print self.tokens[self.pos+j],
                print ''
                srclexer.dumpTokens(self.tokens)
                srclexer.dumpTokens(self.newtokens)
                print "tokens expanded so far:"
                for tk in self.expandedTokens:
                    print "-"*20
                    print tk
                    srclexer.dumpTokens(self.defines[tk].tokens)
                sys.exit(1)
            if tk == '(':
                value = []
                scope += 1
            elif tk == ',':
                values.append(value)
                value = []
            elif tk == ')':
                scope -= 1
                values.append(value)
                value = []
                if scope == 0:
                    break
                else:
                    raise ParseError ('')
            else:
                value.append(tk)
            i += 1

        return values, i