Fix generation of Vim syntax file

This commit is contained in:
David Neto 2018-02-08 12:05:40 -05:00
parent 4e4a254bc8
commit 886859159e
2 changed files with 16 additions and 1 deletions

View File

@ -66,7 +66,7 @@ macro(spvtools_vimsyntax VERSION CLVERSION)
add_custom_command(OUTPUT ${VIMSYNTAX_FILE}
COMMAND ${PYTHON_EXECUTABLE} ${VIMSYNTAX_PROCESSING_SCRIPT}
--spirv-core-grammar=${GRAMMAR_JSON_FILE}
--exinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
--extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE}
--extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE}
>${VIMSYNTAX_FILE}

View File

@ -150,6 +150,10 @@ def main():
type=str, required=False, default=None,
help='input JSON grammar file for OpenGL extended '
'instruction set')
parser.add_argument('--extinst-debuginfo-grammar', metavar='<path>',
type=str, required=False, default=None,
help='input JSON grammar file for DebugInfo extended '
'instruction set')
args = parser.parse_args()
# Generate the syntax rules.
@ -179,6 +183,17 @@ def main():
for inst in opencl["instructions"]:
EmitAsEnumerant(inst['opname'])
if args.extinst_debuginfo_grammar is not None:
print('\n" DebugInfo extended instructions')
debuginfo = json.loads(open(args.extinst_debuginfo_grammar).read())
for inst in debuginfo["instructions"]:
EmitAsEnumerant(inst['opname'])
print('\n" DebugInfo operand enums')
for operand_kind in debuginfo["operand_kinds"]:
if 'enumerants' in operand_kind:
for e in operand_kind['enumerants']:
EmitAsEnumerant(e['enumerant'])
print('\n" OpSpecConstantOp opcodes')
for word in SPEC_CONSTANT_OP_OPCODES.split(' '):
stripped = word.strip('\n,')