From f017dd2b3814e8fbff423786175622b75c6f5ed2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 5 Jul 2020 17:33:03 -0500 Subject: [PATCH] Update: improve IKI syntax rules. This is a relaxation on the specification where previously only whitespace was required to exist before a valid variable name. This allows punctuation to exist before the variable name. Content such as 'A:"b"' may now be specified where A is the variable name (notice the single-quote before A which would previously prevent A from being recognized as a variable name). --- level_0/f_iki/c/iki-common.h | 28 +++++++++++++++ level_0/f_iki/c/iki.c | 86 +++++--------------------------------------- specifications/fss-000D.txt | 9 ++--- 3 files changed, 42 insertions(+), 81 deletions(-) diff --git a/level_0/f_iki/c/iki-common.h b/level_0/f_iki/c/iki-common.h index 8f37731..a07a1cf 100644 --- a/level_0/f_iki/c/iki-common.h +++ b/level_0/f_iki/c/iki-common.h @@ -265,6 +265,7 @@ extern "C" { * status: The return status to use. * buffer: (A pointer) The buffer to seek through. * range: (A pointer) The range within that buffer to seek through. + * width_max: The width_max variable to use fo calculating width_max. * condition: Set to TRUE to seek until whitespace is found and FALSE to seek until non-whitespace. */ #ifndef _di_f_macro_iki_seek_whitespace_ @@ -283,6 +284,33 @@ extern "C" { } #endif // _di_f_macro_iki_seek_whitespace_ +/** + * Seek until a word, dash, or plus is found or not found. + * + * This will ignore the delimit placeholder. + * + * status: The return status to use. + * buffer: (A pointer) The buffer to seek through. + * range: (A pointer) The range within that buffer to seek through. + * width_max: The width_max variable to use fo calculating width_max. + * condition: Set to TRUE to seek until a word character, dash character, or plus character is found and FALSE to seek until the opposite is found. + */ +#ifndef _di_f_macro_iki_seek_word_dash_plus_ + #define f_macro_iki_seek_word_dash_plus(status, buffer, range, width_max, condition) \ + while (range->start <= range->stop && range->start < buffer->used) { \ + if (buffer->string[range->start] == f_iki_syntax_placeholder) { \ + range->start++; \ + continue; \ + } \ + f_macro_iki_determine_width_max(buffer, range, width_max); \ + status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max); \ + if (status == condition) break; \ + else if (F_status_is_error(status)) break; \ + status = f_utf_buffer_increment(*buffer, range, 1); \ + if (F_status_is_error(status)) break; \ + } +#endif // _di_f_macro_iki_seek_word_dash_plus_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index 6205aae..698e559 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -26,27 +26,12 @@ extern "C" { } // skip past all initial non-word, non-dash, and non-plus. - while (range->start <= range->stop && range->start < buffer->used) { - if (buffer->string[range->start] == f_iki_syntax_placeholder) { - range->start++; - continue; - } - - f_macro_iki_determine_width_max(buffer, range, width_max); - - status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max); - if (F_status_is_error(status)) return status; - - if (status == F_true) break; - - f_macro_iki_seek_whitespace(status, buffer, range, width_max, F_true); - if (F_status_is_error(status)) return status; - - f_macro_iki_seek_whitespace(status, buffer, range, width_max, F_false); - if (F_status_is_error(status)) return status; - } // while + f_macro_iki_seek_word_dash_plus(status, buffer, range, width_max, F_true); - if (range->start > range->stop) { + if (F_status_is_error(status)) { + return status; + } + else if (range->start > range->stop) { return F_data_not_stop; } else if (range->start >= buffer->used) { @@ -106,8 +91,8 @@ extern "C" { break; } - // this is not a valid vocabulary name so seek until a whitespace to prepare for the next main loop pass. - f_macro_iki_seek_whitespace(status, buffer, range, width_max, F_true); + // this is not a valid vocabulary name so seek until a non-word, non-dash, or non-plus character. + f_macro_iki_seek_word_dash_plus(status, buffer, range, width_max, F_false); if (F_status_is_error(status)) { f_macro_string_lengths_delete(status, delimits); return status; @@ -326,28 +311,7 @@ extern "C" { range->start++; // skip past all initial non-word, non-dash, and non-plus. - while (range->start <= range->stop && range->start < buffer->used) { - if (buffer->string[range->start] == f_iki_syntax_placeholder) { - range->start++; - continue; - } - - f_macro_iki_determine_width_max(buffer, range, width_max); - - status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - - if (status == F_true) break; - - status = f_utf_buffer_increment(*buffer, range, 1); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - } // while + f_macro_iki_seek_word_dash_plus(status, buffer, range, width_max, F_true); found_vocabulary.start = range->start; } @@ -429,39 +393,7 @@ extern "C" { } if (find_next) { - - while (range->start <= range->stop && range->start < buffer->used) { - - f_macro_iki_seek_whitespace(status, buffer, range, width_max, F_true); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - - f_macro_iki_seek_whitespace(status, buffer, range, width_max, F_false); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - - if (range->start > range->stop || range->start >= buffer->used) break; - - f_macro_iki_determine_width_max(buffer, range, width_max); - - status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - - if (status == F_true) break; - - status = f_utf_buffer_increment(*buffer, range, 1); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; - } - } // while + f_macro_iki_seek_word_dash_plus(status, buffer, range, width_max, F_true); found_vocabulary.start = range->start; find_next = F_false; diff --git a/specifications/fss-000D.txt b/specifications/fss-000D.txt index 1abcd43..1e09b65 100644 --- a/specifications/fss-000D.txt +++ b/specifications/fss-000D.txt @@ -16,22 +16,23 @@ Featureless Settings Specification: 000D - Iki Text: For compatibility with the FSS terminology, the Vocabulary Name is to be considered the Object and the Vocabulary value is to be considered the Content. - Whitespace (or start of file), must exist before any valid variable name. + Whitespace, non-word (and non "_", "-", "+") character punctuations, or the start of file must exist before any valid variable name. + Whitespace and non-word (and non "_", "-", "+") character punctuations may not exist as part of the variable name. The IKI format will use IKI-0000 to represent an IKI with no explicitly defined vocabulary. Whereas IKI-0001 and beyond represent a specific IKI vocabulary. Key\: - \s = whitespace. - \o = any printable word character, including "_", "-", "+". + \o = any printable word character, including "_", "-", "+" (and Unicode equivalents). \c = any character, including whitespace and non-printing, and any delimited quote (used as the opening quote) or a any quote (undelimited) not used as the opening quote. \q = either a single quote (') or a double quote ("). \x = any character. + \W = any non-word character, discluding "_", "-", "+" (and Unicode equivalents). * = 0 or more occurrences. ~ = one or more occurrences, or 0 if at start of file. Structure\: - \x*\s~\o:\q\c\q + \x*\W~\o:\q\c\q Example\: # fss-000d iki-0000 -- 1.8.3.1