1
0
mirror of https://github.com/cmur2/joe-syntax.git synced 2024-10-09 09:02:18 +02:00

ini: enhance error handling, add support for colon comments, unicode escapes, new test file

This commit is contained in:
Todd Lewis 2017-09-09 09:55:48 -04:00 committed by cn
parent 5c8944fc51
commit 13cfbdc5cd
4 changed files with 102 additions and 31 deletions

View File

@ -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))

88
ini.jsf
View File

@ -1,4 +1,7 @@
# JOE syntax highlight file for INI files
# License: GPL v2 or any later version
# by Christian Nicolai (http://mycrobase.de)
# contributions by Todd Lewis (https://github.com/utoddl)
=Idle
=Comment green
@ -9,68 +12,93 @@
=Key
=Separator bold
=Section bold magenta
=SectionBracket bold 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

3
test/README.md Normal file
View File

@ -0,0 +1,3 @@
# 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.

39
test/ini-test.ini Normal file
View File

@ -0,0 +1,39 @@
; 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