Implemented restrict and inline keywords for C99
inline: added field in Decl for it
diff --git a/TODO.txt b/TODO.txt
index c485264..3a8df61 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -8,7 +8,7 @@
 - new keywords restrict, inline

 - mix declarations and statements inside a block

 - VLAs (non-constants in arr[n]), including [*] for parameter lists

-- declarations in the first expression of "for" loops

+V- declarations in the first expression of "for" loops

 - named initializers for structs and arrays

 

 

diff --git a/pycparser/_ast_gen.py b/pycparser/_ast_gen.py
index 47ba148..68904d1 100644
--- a/pycparser/_ast_gen.py
+++ b/pycparser/_ast_gen.py
@@ -7,7 +7,7 @@
 # The design of this module was inspired by astgen.py from the

 # Python 2.5 code-base.

 #

-# Copyright (C) 2008-2009, Eli Bendersky

+# Copyright (C) 2008-2010, Eli Bendersky

 # License: LGPL

 #-----------------------------------------------------------------

 

diff --git a/pycparser/_c_ast.yaml b/pycparser/_c_ast.yaml
index 8ac0b8d..97fbca6 100644
--- a/pycparser/_c_ast.yaml
+++ b/pycparser/_c_ast.yaml
@@ -42,12 +42,13 @@
 

 # name: the variable being declared

 # quals: list of qualifiers (const, volatile)

+# funcspec: list function specifiers (i.e. inline in C99)

 # storage: list of storage specifiers (extern, register, etc.)

 # type: declaration type (probably nested with all the modifiers)

 # init: initialization value, or None

 # bitsize: bit field size, or None

 #

-Decl: [name, quals, storage, type*, init*, bitsize*]

+Decl: [name, quals, storage, funcspec, type*, init*, bitsize*]

 

 DeclList: [decls**]

 

diff --git a/pycparser/c_ast.py b/pycparser/c_ast.py
index b2f0ddc..1dfe354 100644
--- a/pycparser/c_ast.py
+++ b/pycparser/c_ast.py
@@ -984,10 +984,11 @@
 

 

 class Decl(Node):

-    def __init__(self, name, quals, storage, type, init, bitsize, coord=None):

+    def __init__(self, name, quals, storage, funcspec, type, init, bitsize, coord=None):

         self.name = name

         self.quals = quals

         self.storage = storage

+        self.funcspec = funcspec

         self.type = type

         self.init = init

         self.bitsize = bitsize

@@ -1005,9 +1006,9 @@
         buf.write(lead + 'Decl: ')

 

         if attrnames:

-            attrstr = ', '.join('%s=%s' % nv for nv in [("name", repr(self.name)), ("quals", repr(self.quals)), ("storage", repr(self.storage))])

+            attrstr = ', '.join('%s=%s' % nv for nv in [("name", repr(self.name)), ("quals", repr(self.quals)), ("storage", repr(self.storage)), ("funcspec", repr(self.funcspec))])

         else:

-            attrstr = ', '.join('%s' % v for v in [self.name, self.quals, self.storage])

+            attrstr = ', '.join('%s' % v for v in [self.name, self.quals, self.storage, self.funcspec])

         buf.write(attrstr)

 

         if showcoord:

diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py
index 58efea8..b9fa7a8 100644
--- a/pycparser/c_parser.py
+++ b/pycparser/c_parser.py
@@ -264,17 +264,18 @@
     

     def _add_declaration_specifier(self, declspec, newspec, kind):

         """ Declaration specifiers are represented by a dictionary

-            with 3 entries:

+            with the entries:

             * qual: a list of type qualifiers

             * storage: a list of storage type qualifiers

             * type: a list of type specifiers

+            * function: a list of function specifiers

             

             This method is given a declaration specifier, and a 

             new specifier of a given kind.

             Returns the declaration specifier, with the new 

             specifier incorporated.

         """

-        spec = declspec or dict(qual=[], storage=[], type=[])

+        spec = declspec or dict(qual=[], storage=[], type=[], function=[])

         spec[kind].append(newspec)

         return spec

     

@@ -285,6 +286,7 @@
             name=None,

             quals=spec['qual'],

             storage=spec['storage'],

+            funcspec=spec['function'],

             type=decl, 

             init=None, 

             bitsize=None, 

@@ -438,6 +440,7 @@
                 name=None,

                 quals=spec['qual'],

                 storage=spec['storage'],

+                funcspec=spec['function'],

                 type=type[0],

                 init=None,

                 bitsize=None,

@@ -457,6 +460,7 @@
                         name=None,

                         quals=spec['qual'],

                         storage=spec['storage'],

+                        funcspec=spec['function'],

                         type=decl, 

                         init=init, 

                         bitsize=None, 

@@ -521,6 +525,11 @@
         """

         p[0] = self._add_declaration_specifier(p[2], p[1], 'storage')

         

+    def p_declaration_specifiers_4(self, p):

+        """ declaration_specifiers  : function_specifier declaration_specifiers_opt

+        """

+        p[0] = self._add_declaration_specifier(p[2], p[1], 'function')

+    

     def p_storage_class_specifier(self, p):

         """ storage_class_specifier : AUTO

                                     | REGISTER

@@ -529,7 +538,12 @@
                                     | TYPEDEF

         """

         p[0] = p[1]

-        

+    

+    def p_function_specifier(self, p):
+        """ function_specifier  : INLINE
+        """

+        p[0] = p[1]

+    

     def p_type_specifier_1(self, p):

         """ type_specifier  : VOID

                             | CHAR

@@ -548,6 +562,7 @@
     

     def p_type_qualifier(self, p):

         """ type_qualifier  : CONST

+                            | RESTRICT

                             | VOLATILE

         """

         p[0] = p[1]

@@ -638,6 +653,7 @@
             decl = c_ast.Decl(

                 name=None,

                 quals=spec['qual'],

+                funcspec=spec['function'],

                 storage=spec['storage'],

                 type=struct_decl['decl'],

                 init=None,

@@ -806,6 +822,7 @@
             name=None,

             quals=spec['qual'],

             storage=spec['storage'],

+            funcspec=spec['function'],

             type=decl, 

             init=None, 

             bitsize=None, 

diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index aa75f00..ccedb01 100644
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -307,6 +307,15 @@
                             ['TypeDecl', ['IdentifierType', ['int']]]]], 
                         ['TypeDecl', ['IdentifierType', ['int']]]]]])
         
+        # restrict qualifier
+        self.assertEqual(self.get_decl('int (*k)(restrict int* q);'),
+            ['Decl', 'k', 
+                ['PtrDecl', 
+                    ['FuncDecl', 
+                        [['Decl', ['restrict'], 'q', 
+                            ['PtrDecl',
+                                ['TypeDecl', ['IdentifierType', ['int']]]]]], 
+                        ['TypeDecl', ['IdentifierType', ['int']]]]]])
         
     def test_qualifiers_storage_specifiers(self):
         def assert_qs(txt, index, quals, storage):
@@ -866,6 +875,10 @@
         d5 = self.get_decl_init(r'char* s = "foo\"" "bar";')
         self.assertEqual(d5, ['Constant', 'string', r'"foo\"bar"'])
 
+    def test_inline_specifier(self):                
+        ps2 = self.parse('static inline void inlinefoo(void);')
+        self.assertEqual(ps2.ext[0].funcspec, ['inline'])
+
 
 class TestCParser_whole_code(unittest.TestCase):
     """ Testing of parsing whole chunks of code.
@@ -1080,7 +1093,6 @@
         }
         '''
         ps3 = self.parse(s3)
-        ps3.show()
         self.assert_num_klass_nodes(ps3, For, 1)
         # here there are 2 refs to 'i' since the declaration doesn't count as 
         # a ref in the visitor