Fix build break
[chromium-blink-merge.git] / tools / idl_parser / idl_ppapi_lexer.py
blobf615c77fba4863931f2bf903bd1223164095910b
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """ Lexer for PPAPI IDL
7 The lexer uses the PLY library to build a tokenizer which understands both
8 WebIDL and Pepper tokens.
10 WebIDL, and WebIDL regular expressions can be found at:
11 http://www.w3.org/TR/2012/CR-WebIDL-20120419/
12 PLY can be found at:
13 http://www.dabeaz.com/ply/
14 """
16 from idl_lexer import IDLLexer
17 import optparse
18 import os.path
19 import sys
23 # IDL PPAPI Lexer
25 class IDLPPAPILexer(IDLLexer):
26 # Special multi-character operators
27 def t_LSHIFT(self, t):
28 r'<<'
29 return t;
31 def t_RSHIFT(self, t):
32 r'>>'
33 return t;
35 def t_INLINE(self, t):
36 r'\#inline (.|\n)*?\#endinl.*'
37 self.AddLines(t.value.count('\n'))
38 return t
40 # Return a "preprocessor" inline block
41 def __init__(self):
42 IDLLexer.__init__(self)
43 self._AddTokens(['LSHIFT', 'RSHIFT', 'INLINE'])
44 self._AddKeywords(['label', 'namespace', 'struct'])
47 # If run by itself, attempt to build the lexer
48 if __name__ == '__main__':
49 lexer = IDLPPAPILexer()