parameters: (self, grammar)
return_statement: return '\n'.join(parts)
docstring: Returns a string that is the language-specific header for the given grammar
docstring_summary: Returns a string that is the language-specific header for the given grammar
docstring_tokens: Returns a string that is the language - specific header for the given grammar
function: def generate(self, grammar):
          """Returns a string that is the language-specific header for the given grammar"""
  
          parts = []
          if grammar.copyright:
              parts.extend(["{}{}".format(self.comment_prefix(), f) for f in grammar.copyright])
          parts.append('')
  
          guard = 'SPIRV_UNIFIED1_{}_H_'.format(grammar.name)
          if self.uses_guards:
              parts.append('#ifndef {}'.format(guard))
              parts.append('#define {}'.format(guard))
          parts.append('')
  
          parts.append(self.cpp_guard_preamble())
  
          if grammar.version:
              parts.append(self.const_definition(grammar.name, 'Version', grammar.version))
  
          if grammar.revision is not None:
              parts.append(self.const_definition(grammar.name, 'Revision', grammar.revision))
  
          parts.append('')
  
          if grammar.instructions:
              parts.append(self.enum_prefix(grammar.name, 'Instructions'))
              for inst in grammar.instructions:
                  parts.append(self.enum_value(grammar.name, inst['opname'], inst['opcode']))
              parts.append(self.enum_end(grammar.name, 'Instructions'))
              parts.append('')
  
          if grammar.operand_kinds:
              for kind in grammar.operand_kinds:
                  parts.append(self.enum_prefix(grammar.name, kind['kind']))
                  for e in kind['enumerants']:
                      parts.append(self.enum_value(grammar.name, e['enumerant'], e['value']))
                  parts.append(self.enum_end(grammar.name, kind['kind']))
              parts.append('')
  
          parts.append(self.cpp_guard_postamble())
  
          if self.uses_guards:
              parts.append('#endif // {}'.format(guard))
  
          # Ensre the file ends in an end of line
          parts.append('')
  
          return '\n'.join(parts)
function_tokens: def generate ( self , grammar ) : parts = [ ] if grammar . copyright : parts . extend ( [ "{}{}" . format ( self . comment_prefix ( ) , f ) for f in grammar . copyright ] ) parts . append ( '' ) guard = 'SPIRV_UNIFIED1_{}_H_' . format ( grammar . name ) if self . uses_guards : parts . append ( '#ifndef {}' . format ( guard ) ) parts . append ( '#define {}' . format ( guard ) ) parts . append ( '' ) parts . append ( self . cpp_guard_preamble ( ) ) if grammar . version : parts . append ( self . const_definition ( grammar . name , 'Version' , grammar . version ) ) if grammar . revision is not None : parts . append ( self . const_definition ( grammar . name , 'Revision' , grammar . revision ) ) parts . append ( '' ) if grammar . instructions : parts . append ( self . enum_prefix ( grammar . name , 'Instructions' ) ) for inst in grammar . instructions : parts . append ( self . enum_value ( grammar . name , inst [ 'opname' ] , inst [ 'opcode' ] ) ) parts . append ( self . enum_end ( grammar . name , 'Instructions' ) ) parts . append ( '' ) if grammar . operand_kinds : for kind in grammar . operand_kinds : parts . append ( self . enum_prefix ( grammar . name , kind [ 'kind' ] ) ) for e in kind [ 'enumerants' ] : parts . append ( self . enum_value ( grammar . name , e [ 'enumerant' ] , e [ 'value' ] ) ) parts . append ( self . enum_end ( grammar . name , kind [ 'kind' ] ) ) parts . append ( '' ) parts . append ( self . cpp_guard_postamble ( ) ) if self . uses_guards : parts . append ( '#endif // {}' . format ( guard ) ) # Ensre the file ends in an end of line parts . append ( '' ) return '\n' . join ( parts )