From 99c9410cc2bd84fb4dda2e536094c42db25174fd Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 26 Aug 2019 20:04:57 +0300 Subject: [PATCH] compiler: add all C reserved words to CReserved --- compiler/query.v | 2 +- compiler/table.v | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/compiler/query.v b/compiler/query.v index 380b3c51c6..98132cfed4 100644 --- a/compiler/query.v +++ b/compiler/query.v @@ -124,7 +124,7 @@ fn (p mut Parser) select_query(fn_ph int) string { for i, field in fields { mut cast := '' if field.typ == 'int' { - cast = 'string_int' + cast = 'v_string_int' } obj_gen.writeln('${qprefix}$tmp . $field.name = $cast( *(string*)array__get(${qprefix}row.vals, $i) );') } diff --git a/compiler/table.v b/compiler/table.v index 03b4d615e4..81c7bd7d89 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -102,10 +102,44 @@ const ( 'error', 'malloc', 'calloc', - 'char', 'free', 'panic', - 'register' + + // Full list of C reserved words, from: https://en.cppreference.com/w/c/keyword + 'auto', + 'break', + 'case', + 'char', + 'const', + 'continue', + 'default', + 'do', + 'double', + 'else', + 'enum', + 'extern', + 'float', + 'for', + 'goto', + 'if', + 'inline', + 'int', + 'long', + 'register', + 'restrict', + 'return', + 'short', + 'signed', + 'sizeof', + 'static', + 'struct', + 'switch', + 'typedef', + 'union', + 'unsigned', + 'void', + 'volatile', + 'while', ] )