From f16643a1a0bd7ccb2ed0a2f433708cbfd06bf29b Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 23 Dec 2015 18:28:15 +0100 Subject: [PATCH] Allow negative numbers in ddl2cpp --- scripts/ddl2cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 55df3645..78c15442 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -30,7 +30,7 @@ import sys import re import os -from pyparsing import CaselessLiteral, SkipTo, restOfLine, oneOf, ZeroOrMore, Optional, \ +from pyparsing import CaselessLiteral, Literal, SkipTo, restOfLine, oneOf, ZeroOrMore, Optional, Combine, \ WordStart, WordEnd, Word, alphas, alphanums, nums, QuotedString, nestedExpr, MatchFirst, OneOrMore, delimitedList, Or, Group INCLUDE = 'sqlpp11' @@ -59,7 +59,8 @@ def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) -ddlNum = Word(nums + ".") +negativeSign = Literal('-') +ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) ddlTerm = Word(alphas, alphanums + "_$") ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")" ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull")