From 7ba201799e063ff21cb11fe783efebd21f9d7123 Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Thu, 2 Feb 2017 21:03:40 -0500 Subject: [PATCH 1/7] Fix comment detection. --- yaml.jsf | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index ee5024d..1caa1c0 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -1,4 +1,5 @@ # JOE syntax highlight file for YAML +# by Christian Nicolai (http://mycrobase.de) =Idle =Comment green @@ -11,7 +12,7 @@ =Directive red =Reference yellow -=LocalType fg_310 # brown +=LocalType blue =BlockDelim bold blue =BadTab inverse red @@ -19,13 +20,26 @@ :line_start Idle * maybe_key noeat "\t" bad_tab recolor=-1 + "#" maybe_lscomment1 " " line_start +:maybe_lscomment1 Idle + * maybe_key noeat + " " line_comment recolor=-2 + +:maybe_idlecomment Comment + * idle noeat + "#" maybe_idlecomment2 + +:maybe_idlecomment2 Comment + * idle recolor=-2 + " " line_comment recolor=-2 + :idle Constant * idle "\n" line_start + " " maybe_idlecomment "%" directive recolor=-1 - "#" line_comment recolor=-1 "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -35,7 +49,8 @@ :maybe_key Idle * maybe_key1 recolor=-1 mark - "\n%#'\"{[]}*&!" idle noeat + "\n" line_start + "%#'\"{[]}*&!" idle noeat "-" maybe_block1 mark :maybe_key1 Constant From a832dbd5f43d47cedda9c68a583bc2fceee41e0c Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Fri, 3 Feb 2017 14:42:48 -0500 Subject: [PATCH 2/7] Fix spaces after '#' --- yaml.jsf | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 1caa1c0..350bd82 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -20,20 +20,12 @@ :line_start Idle * maybe_key noeat "\t" bad_tab recolor=-1 - "#" maybe_lscomment1 + "#" line_comment recolor=-1 " " line_start -:maybe_lscomment1 Idle - * maybe_key noeat - " " line_comment recolor=-2 - :maybe_idlecomment Comment * idle noeat - "#" maybe_idlecomment2 - -:maybe_idlecomment2 Comment - * idle recolor=-2 - " " line_comment recolor=-2 + "#" line_comment recolor=-1 :idle Constant * idle From d35bc8d3d55e347d4725de5e7b8cc33bcb4e65d3 Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Thu, 4 May 2017 20:13:50 -0400 Subject: [PATCH 3/7] yaml: handle plain strings w/ non-initial quotes --- yaml.jsf | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 810d9f5..0ebe7e0 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -23,11 +23,15 @@ "#" line_comment recolor=-1 " " line_start +:maybe_idlecomment Comment + * idle noeat + "#" line_comment recolor=-1 + :idle Constant - * idle + * plain_scalar noeat "\n" line_start + " " maybe_idlecomment "%" directive recolor=-1 - " " maybe_line_comment "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -35,9 +39,15 @@ "*&" maybe_reference "!" maybe_typecast +:plain_scalar Constant + * plain_scalar + "\t" bad_tab recolor=-1 + "\n" line_start noeat + :maybe_key Idle * maybe_key1 recolor=-1 mark - "\n%#'\"{[]}*&!" idle noeat + "\n" line_start + "%#'\"{[]}*&!" idle noeat "-" maybe_block1 mark :maybe_key1 Constant @@ -56,10 +66,6 @@ :bad_tab BadTab * line_start noeat -:maybe_line_comment Comment - * idle noeat - "#" line_comment - :line_comment Comment * line_comment "\n" line_start From 44616813ea32f7eba163b08d30c16b81ebebfd7c Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Sun, 7 May 2017 20:48:58 -0400 Subject: [PATCH 4/7] handle comment in plain scalars --- yaml.jsf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 0ebe7e0..9d88635 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -23,15 +23,11 @@ "#" line_comment recolor=-1 " " line_start -:maybe_idlecomment Comment - * idle noeat - "#" line_comment recolor=-1 - :idle Constant * plain_scalar noeat "\n" line_start - " " maybe_idlecomment "%" directive recolor=-1 + " " maybe_idle_comment "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -43,6 +39,7 @@ * plain_scalar "\t" bad_tab recolor=-1 "\n" line_start noeat + " " maybe_plain_scalar_comment :maybe_key Idle * maybe_key1 recolor=-1 mark @@ -66,6 +63,14 @@ :bad_tab BadTab * line_start noeat +:maybe_plain_scalar_comment Comment + * plain_scalar noeat + "#" line_comment + +:maybe_idle_comment Comment + * idle noeat + "#" line_comment + :line_comment Comment * line_comment "\n" line_start From 1d8db8f84e6b7603d0eeb9e1676a43c08085bcd1 Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Fri, 4 Aug 2017 14:23:50 -0400 Subject: [PATCH 5/7] repair comments again --- yaml.jsf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 51972e4..6974d05 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -12,7 +12,7 @@ =Directive red =Reference yellow -=LocalType blue +=LocalType fg_310 # brown =BlockDelim bold blue =BadTab inverse red @@ -23,14 +23,9 @@ "#" line_comment recolor=-1 " " line_start -:maybe_idlecomment Comment - * idle noeat - "#" line_comment recolor=-1 - :idle Constant * plain_scalar noeat "\n" line_start - " " maybe_idlecomment "%" directive recolor=-1 " " maybe_idle_comment "'" string_sq_1 recolor=-1 @@ -55,7 +50,8 @@ :maybe_key1 Constant * idle noeat ":" key - " a-zA-Z0-9_-" maybe_key1 + "a-zA-Z0-9_-" maybe_key1 + " " maybe_key1_comment noeat # necessary to include the : :key Idle @@ -72,6 +68,10 @@ * plain_scalar noeat "#" line_comment +:maybe_key1_comment Comment + * maybe_key1 noeat + "#" line_comment + :maybe_idle_comment Comment * idle noeat "#" line_comment From d5a3ad8cc42d7569b5a482f98213f8b23206a6b3 Mon Sep 17 00:00:00 2001 From: Christian Nicolai Date: Fri, 4 Aug 2017 19:23:24 +0000 Subject: [PATCH 6/7] The noeat leads to infinite loop --- yaml.jsf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yaml.jsf b/yaml.jsf index 6974d05..317bf51 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -51,7 +51,7 @@ * idle noeat ":" key "a-zA-Z0-9_-" maybe_key1 - " " maybe_key1_comment noeat + " " maybe_key1_comment # necessary to include the : :key Idle From ed2978c79b2f60c1d0570d5d35c7c0e0c2e4023b Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Sat, 9 Sep 2017 09:55:48 -0400 Subject: [PATCH 7/7] error handling enhancements; new test file --- README.md | 3 +- ini.jsf | 100 +++++++++++++++++++++++++++++----------------- test/README.md | 6 +++ test/ini-test.ini | 40 +++++++++++++++++++ 4 files changed, 112 insertions(+), 37 deletions(-) create mode 100644 test/README.md create mode 100644 test/ini-test.ini diff --git a/README.md b/README.md index d075921..fb424ae 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,14 @@ See [HowItWorks.md](https://github.com/cmur2/joe-syntax/blob/master/HowItWorks.m Every .jsf file from the original repository is under GPL as [JOE](http://sourceforge.net/projects/joe-editor/). There are efforts to move JOE to GPL v2 or any later version. -Every .jsf file created and modified exclusively by [me](https://github.com/cmur2) is under GPL v2 or any later version. +Every .jsf file created and modified exclusively by [me (Christian Nicolai)](https://github.com/cmur2) is under GPL v2 or any later version. Files with contributions (or unclear license info): * [elixir.jsf](https://github.com/cmur2/joe-syntax/blob/master/elixir.jsf) which is created by [Andrew Lisin](https://github.com/avli) under GPL v2 or any later version ([comment](https://github.com/cmur2/joe-syntax/pull/18#issuecomment-78036115)) * [erlang.jsf](https://github.com/cmur2/joe-syntax/blob/master/erlang.jsf) which is created by [Christian Nicolai](https://github.com/cmur2) and then modified by Jonas Rosling and enhanced with a small tweak from [raev](https://github.com/raev) * [go.jsf](https://github.com/cmur2/joe-syntax/blob/master/go.jsf) which is entirely contributed by [Daniel Vargas](https://github.com/danielvargas) +* [ini.jsf](https://github.com/cmur2/joe-syntax/blob/master/ini.jsf) which is created by [Christian Nicolai](https://github.com/cmur2) with contributions from [Todd Lewis](https://github.com/utoddl) * [js.jsf](https://github.com/cmur2/joe-syntax/blob/master/js.jsf) which is created by [Christian Nicolai](https://github.com/cmur2) and then modified by [Rebecca Turner](https://github.com/iarna) under GPL v2 or any later version and compatible ISC license ([comment](https://github.com/cmur2/joe-syntax/pull/13#issuecomment-78058267)) * [json.jsf](https://github.com/cmur2/joe-syntax/blob/master/json.jsf) which is entirely contributed by [Rebecca Turner](https://github.com/iarna) under GPL v2 or any later version and compatible ISC license ([comment](https://github.com/cmur2/joe-syntax/pull/14#issuecomment-78058037)) * [lsl.jsf](https://github.com/cmur2/joe-syntax/blob/master/lsl.jsf) which is from [Zai Lynch](https://wiki.secondlife.com/wiki/User:Zai_Lynch) under GPL v1 (delivered by [Rebecca Turner](https://github.com/iarna)) diff --git a/ini.jsf b/ini.jsf index bf4aa83..1927c36 100644 --- a/ini.jsf +++ b/ini.jsf @@ -1,76 +1,104 @@ # JOE syntax highlight file for INI files +# License: GPL +# by Christian Nicolai (http://mycrobase.de) +# contributions by Todd Lewis (https://github.com/utoddl) =Idle =Comment green -=Constant cyan -=Escape bold cyan -=Bad bold red - +=Constant cyan dim +=Escape cyan bold +=Bad red bold =Key -=Separator bold -=Section bold magenta +=Separator bold +=Section white bold bg_MAGENTA +=SectionBracket white bg_MAGENTA :line_start Idle - * key noeat + * key noeat mark "\n" line_start " \t\r" line_start # leading spaces ";#" line_comment recolor=-1 - "[" section recolor=-1 + "[" section_start noeat "=" missing_key recolor=-1 :line_comment Comment * line_comment "\n" line_start +:section_start SectionBracket + * section mark noeat + "[" section_start + :section Section * section - "]" section_end - "\n" section_unexp_end recolor=-2 + "]" section_end noeat + "\n" unexpected_end noeat recolormark -:section_end Bad - * section_end +:section_end SectionBracket + * unexpected_end noeat + "]" section_end mark "\n" line_start -:section_unexp_end Bad - * line_start noeat +:unexpected_end Bad + * unexpected_end + "\n" line_start :missing_key Bad * value_pre noeat :key Key * key - " \t\r" key_post noeat - "=" sep recolor=-1 - "\n" key_error recolor=-2 - -:key_post Idle - * value_pre noeat - " \t\r" key_post - "=" sep recolor=-1 - -:key_error Bad - * key noeat + "=:" sep noeat mark + "\n" unexpected_end noeat recolormark :sep Separator * value_pre noeat + "=:" value_pre :value_pre Idle - * value noeat + * value noeat mark " \t\r" value_pre + "\n" unexpected_end noeat recolormark :value Constant * value - "\\" value_esc + "\\" value_esc mark "\n" line_start - " \t\r" maybe_comment recolor=-1 + " " value_maybe_comment recolor=-1 -:value_esc Escape - * value - "\n" value_error recolor=-2 - -:value_error Bad - * value noeat - -:maybe_comment Idle +:value_maybe_comment Idle * value noeat ";#" line_comment recolor=-1 + +:value_esc Escape + * value_esc_bad noeat recolormark + "0abtrn;#=:\\" value_esc_end recolormark + "x" value_esc_unicode1 + "\n" value mark + +:value_esc_bad Bad + * value noeat mark + +:value_esc_end Escape + * value noeat mark + +:value_esc_unicode1 Escape + * value_esc_bad noeat recolormark + "0-9a-fA-F" value_esc_unicode2 + "\n" unexpected_end noeat recolormark + +:value_esc_unicode2 Escape + * value_esc_bad noeat recolormark + "0-9a-fA-F" value_esc_unicode3 + "\n" unexpected_end noeat recolormark + +:value_esc_unicode3 Escape + * value_esc_bad noeat recolormark + "0-9a-fA-F" value_esc_unicode4 + "\n" unexpected_end noeat recolormark + +:value_esc_unicode4 Escape + * value_esc_bad noeat recolormark + "0-9a-fA-F" value_esc_end recolormark + "\n" unexpected_end noeat recolormark + diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..214d367 --- /dev/null +++ b/test/README.md @@ -0,0 +1,6 @@ +# Test Files for JOE Syntax Highlighting + +This directory contains files for testing and validating .jsf files. +Select features and problematic cases should be added to these files +to ensure that new features and bug fixes don't break existing +functionality. diff --git a/test/ini-test.ini b/test/ini-test.ini new file mode 100644 index 0000000..60d95d2 --- /dev/null +++ b/test/ini-test.ini @@ -0,0 +1,40 @@ +; ini-test.ini -- file for testing ini.jsf +; License: GPL +; by Todd Lewis (https://github.com/utoddl) +; +; See https://en.wikipedia.org/wiki/INI_file for .ini specs +; Normal (;) line comment +# Alternative (#) line comment +[broken_section_head) +bsh1=normal_value_with_equals_sign_as_separator +bsh2:normal_value_with_colon_as_separator + +[escape_char_section] with evil trailing chars +; Valid esc chars: \ 0 a b t r n ; # : +; and unicode "Basic Multilingual Plane" (4 hex digits) after "\x" +alphas=\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +valid_esc=~\\~\0~\a~\b~\t~\r~\n~\;~\#~ +unicodes=~~\x~~\x1~~\x12~~\x123\a~~\x1234~~\x12345~~ +# another comment +ecs1_missing_value ; Not a trailing comment b/c no equal sign! +ecs2 = # value w/ leading whitespace! +ecs3=value with continuation \ + on the next line. + +[quotes_and_trailing_comments] +; The following quotes should be insignificant according +; to https://en.wikipedia.org/wiki/INI_file, but some +; implementations allow it. Likewise, trailing comments are +; not spec, but often honored. +qatc3="quoted value" # not technically a comment, but lovely green. +qatc4="quoted value \# w/o comment" +qatc5="quoted value # w/ comment?" ; No right answer! +qatc6_missing_value + +[second_borken_section +sbs1='val \x \'' ; These single quotes aren't spec either. + +differently_borken_section] +dbs1_no_val_but_with_equals= +dbs2 = good_value_with_whitespace_around_equals +