diff --git a/docs/_posts/2006-01-02-command.md b/docs/_posts/2006-01-02-command.md index 51d42f7d..e512fb8e 100644 --- a/docs/_posts/2006-01-02-command.md +++ b/docs/_posts/2006-01-02-command.md @@ -80,6 +80,9 @@ csvq > This option can be specified multiple formats using JSON array of strings. +--ansi-quotes, -k +: Use double quotation mark (U+0022 `"`) as identifier enclosure. + --wait-timeout value, -w value : Limit of the waiting time in seconds to wait for locked files to be released. The default is 10. @@ -516,7 +519,7 @@ In command parameters and statements, following strings represent special charac | \r | U+000D Carriage Return | | \t | U+0009 Horizontal Tab | | \v | U+000b Vertical Tab | -| \\" | U+0022 Double Quote (in strings only) | +| \\" | U+0022 Double Quote | | \\' | U+0027 Single Quote (in strings only) | | \\\` | U+0060 Grave Accent (in identifiers only) | | \\\\ | U+005c Backslash | diff --git a/docs/_posts/2006-01-02-flag.md b/docs/_posts/2006-01-02-flag.md index cb2bc4f0..1f72a6a6 100644 --- a/docs/_posts/2006-01-02-flag.md +++ b/docs/_posts/2006-01-02-flag.md @@ -15,6 +15,7 @@ A flag is a representation of a [command option]({{ '/reference/command.html#opt | @@REPOSITORY | string | Directory path where files are located | | @@TIMEZONE | string | Default TimeZone | | @@DATETIME_FORMAT | string | Datetime Format to parse strings | +| @@ANSI_QUOTES | boolean | Use double quotation mark as identifier enclosure | | @@WAIT_TIMEOUT | float | Limit of the waiting time in seconds to wait for locked files to be released | | @@IMPORT_FORMAT | string | Default format to load files | | @@DELIMITER | string | Field delimiter for CSV | diff --git a/docs/_posts/2006-01-02-statement.md b/docs/_posts/2006-01-02-statement.md index 32f904e0..d8fc26e1 100644 --- a/docs/_posts/2006-01-02-statement.md +++ b/docs/_posts/2006-01-02-statement.md @@ -88,18 +88,18 @@ csvq > EXIT; You can use following types in statements. Identifier -: A identifier is a word starting with any unicode letter or a Low Line(U+005F `_`) and followed by a character string that contains any unicode letters, any digits or Low Lines(U+005F `_`). - You cannot use [reserved words](#reserved_words) as a identifier. +: An identifier is a word starting with any unicode letter or a Low Line(U+005F `_`) and followed by a character string that contains any unicode letters, any digits or Low Lines(U+005F `_`). + You cannot use [reserved words](#reserved_words) as an identifier. - Notwithstanding above naming restriction, you can use most character strings as a identifier by enclosing in Grave Accents(U+0060 ` ). - Back quotes are escaped by back slashes. + Notwithstanding above naming restriction, you can use most character strings as an identifier by enclosing in Grave Accents(U+0060 \` ) or Quotation Marks(U+0022 `"`) if [--ansi-quotes]({{ '/reference/command.html#options' | relative_url }}) is specified. + Enclosure characters are escaped by back slashes or double enclosures. Identifiers represent tables, columns, functions or cursors. Character case is insensitive except file paths, and whether file paths are case insensitive or not depends on your file system. String -: A string is a character string enclosed in Apostrophes(U+0027 `'`) or Quotation Marks(U+0022 `"`). - In a string, single quotes or double quotes are escaped by back slashes. +: A string is a character string enclosed in Apostrophes(U+0027 `'`) or Quotation Marks(U+0022 `"`) if [--ansi-quotes]({{ '/reference/command.html#options' | relative_url }}) is not specified. + In a string, enclosure characters are escaped by back slashes or double enclosures. Integer : An integer is a word that contains only \[0-9\]. @@ -159,9 +159,10 @@ Runtime Information ```sql abcde -- identifier 識別子 -- identifier -`ab+c\`de` -- identifier +`abc\`de` -- identifier +`abc``de` -- identifier 'abcd\'e' -- string -"abcd\"e" -- string +'abcd''e' -- string 123 -- integer 123.456 -- float true -- ternary @@ -172,6 +173,14 @@ null -- null @%ENV_VAR -- environment variable @%`ENV_VAR` -- environment variable @#INFO -- runtime information + +/* if --ansi-quotes is specified */ +"abcd\"e" -- identifier +"abcd""e" -- identifier + +/* if --ansi-quotes is not specified */ +"abcd\"e" -- string +"abcd""e" -- string ``` ## Comments diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 282c8691..b493764f 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -18,11 +18,11 @@ https://mithrandie.github.io/csvq/reference/command.html - 2019-05-04T12:09:52+00:00 + 2019-05-19T09:32:34+00:00 https://mithrandie.github.io/csvq/reference/statement.html - 2018-11-24T06:47:39+00:00 + 2019-05-19T09:32:34+00:00 https://mithrandie.github.io/csvq/reference/value.html @@ -102,7 +102,7 @@ https://mithrandie.github.io/csvq/reference/flag.html - 2018-11-17T22:33:20+00:00 + 2019-05-19T09:32:34+00:00 https://mithrandie.github.io/csvq/reference/environment-variable.html diff --git a/lib/syntax/syntax.go b/lib/syntax/syntax.go index cb9f8b37..98cf2bc6 100644 --- a/lib/syntax/syntax.go +++ b/lib/syntax/syntax.go @@ -993,6 +993,8 @@ var CsvqSyntax = []Expression{ "%s \n" + " > Datetime Format to parse strings.\n" + "%s \n" + + " > Use double quotation mark(U+0022 \") as identifier enclosure.\n" + + "%s \n" + " > Limit of the waiting time in seconds to wait for locked files to be released.\n" + "%s \n" + " > Default format to load files.\n" + @@ -1045,6 +1047,7 @@ var CsvqSyntax = []Expression{ Flag("@@REPOSITORY"), String("string"), Flag("@@TIMEZONE"), String("string"), Link("Timezone"), Flag("@@DATETIME_FORMAT"), String("string"), + Flag("@@ANSI_QUOTES"), String("boolean"), Flag("@@WAIT_TIMEOUT"), Float("float"), Flag("@@IMPORT_FORMAT"), String("string"), Flag("@@DELIMITER"), String("string"), @@ -2675,14 +2678,16 @@ var CsvqSyntax = []Expression{ Description: Description{ Template: "" + "%s\n" + - " > A identifier is a word starting with any unicode letter or" + + " > An identifier is a word starting with any unicode letter or" + " a Low Line(U+005F _) and followed by a character string that" + - " contains any unicode letters, any digits or Low Lines(U+005F _)." + - " You cannot use %s as a identifier.\n" + + " contains any unicode letters, any digits or Low Lines(U+005F _)." + + " You cannot use %s as an identifier.\n" + "\n" + " > Notwithstanding above naming restriction, you can use most" + - " character strings as a identifier by enclosing in" + - " Grave Accents(U+0060 `). Back quotes are escaped by back slashes.\n" + + " character strings as an identifier by enclosing in" + + " Grave Accents(U+0060 `) or Quotation Marks(U+0022 \") if" + + " --ansi-quotes is specified. Enclosure characters are escaped by" + + " back slashes or double enclosures.\n" + "\n" + " > Identifiers represent tables, columns, functions or cursors." + " Character case is insensitive except file paths, and whether file" + @@ -2690,8 +2695,9 @@ var CsvqSyntax = []Expression{ "\n" + "%s\n" + " > A string is a character string enclosed in Apostrophes(U+0027 ') or" + - " Quotation Marks(U+0022 \"). In a string, single quotes or double" + - " quotes are escaped by back slashes.\n" + + " Quotation Marks(U+0022 \") if --ansi-quotes is not specified." + + " In a string, enclosure characters are escaped by back slashes or" + + " double enclosures.\n" + "\n" + "%s\n" + " > An integer is a word that contains only [0-9].\n" + @@ -2774,7 +2780,7 @@ var CsvqSyntax = []Expression{ " | \\r | U+000D Carriage Return |\n" + " | \\t | U+0009 Horizontal Tab |\n" + " | \\v | U+000b Vertical Tab |\n" + - " | \\\" | U+0022 Double Quote (in strings only) |\n" + + " | \\\" | U+0022 Double Quote |\n" + " | \\' | U+0027 Single Quote (in strings only) |\n" + " | \\` | U+0060 Grave Accent (in identifiers only) |\n" + " | \\\\ | U+005c Backslash |\n" +