30 Commits

Author SHA1 Message Date
Waldemar Quevedo
62242a7215 Fix JSON compatibility in conf format
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-22 12:47:51 -07:00
Ivan Kozlovic
6ebbb4a41a Fixed lexer changes made in #3434
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-03 20:02:25 -06:00
Ivan Kozlovic
86d20aa5e6 [FIXED] Parsing of strings starting with numbers and K/G/etc.. suffix
If a configuration variable starts with numbers and has a character
that such as K/k/G/g/etc.. it would assume that it was a number
(expressed in Kb, Gb, etc..).

This PR checks that if the special characters are not the suffix,
that is, the variable does not end after those characters, then
the parsing will treat the whole thing as a string.

Resolves #3431

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-02 18:15:04 -06:00
Waldemar Quevedo
47055eddef Add support for unquoted config strings that start with number
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2019-02-06 08:57:09 -08:00
Waldemar Quevedo
c3a441f6ec Fix dangling bracket and parens eof bugs in config parser
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2019-01-28 17:26:22 -08:00
Waldemar Quevedo
e8928b7eed Fix conf parser hang on dangling quote
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2018-10-23 17:45:08 -07:00
Waldemar Quevedo
181b07ebc1 Config reporting with line and error position
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2018-10-02 11:38:15 -07:00
Derek Collison
3b953ce838 Allow localhost to not be defined, only need 127.0.0.1
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 16:10:19 -07:00
Waldemar Quevedo
c45d2f5b8b Improve compatibility with JSON in config parser
The configuration format from the server is almost already a superset
of JSON with exception of two cases:

1) trailing commas from values at the top level (although they are
   supported inside of maps)

2) initial and final brackets on the top level section.

This change relaxes the two cases above to just skip those tokens so
that the config syntax can also support valid JSON objects for
configuring the server which might be helpful when generating it
programmatically.
2018-03-21 01:03:41 -07:00
Eric Promislow
bcf8b7532b [477] - Bring up coverage. 2017-04-28 13:33:35 -07:00
Eric Promislow
122b697e41 Issue 477: Improve handling of escaped substrings
This involves evaluating and interpolating \-escaped sequences
in double-quoted and undelimited strings.

Added tests on various edge-conditions, as well as ruling out bare
strings like '\true' as a bool.
2017-04-27 18:04:47 -07:00
Derek Collison
e57c949658 Add support for 'include' to configuration files 2016-11-21 14:58:05 -08:00
Derek Collison
6f9e4d6512 Added support for integer suffixes, e.g. 1k, 8mb 2016-11-20 17:39:04 -08:00
Derek Collison
832bac98be First pass variable support.
This allows blocked scoped variables to be set and retrieved as values using the $ prefix.
e.g. foo = 22; bar = $foo

Also supports env variables being used as variables and will properly parse to the correct type.
2016-05-22 10:21:00 -07:00
Derek Collison
46a9e6f0bc First pass at multi-user support 2016-05-13 12:27:57 -07:00
Derek Collison
9b41ee00aa lex coverage 2016-05-04 12:52:52 -07:00
Derek Collison
433d62ec0a Parse IPs and raw strings in arrays properly 2016-04-07 08:36:57 -07:00
Derek Collison
99f1ea29bd Increased test coverage, remove dead code 2015-01-10 18:32:30 -08:00
Peter Ohler
e391e6f696 added support for blocks and removed feature that allowed mixed single and double quotes 2013-08-12 09:48:52 -07:00
Derek Collison
60c411638f quoted strings should allow internal spaces 2013-08-07 12:32:08 -07:00
Derek Collison
2833a1f05a Make sure special chars ok in key names 2013-08-07 11:21:39 -07:00
Derek Collison
d7876007d9 Support quoted map keys too 2013-08-07 09:17:32 -07:00
Derek Collison
b2187a7514 Allow key values to be quoted 2013-08-07 08:31:48 -07:00
Derek Collison
377ade5e42 go fmt 2013-08-02 16:52:08 -07:00
Derek Collison
ce8ff5d640 Allow whitespace to term non-quoted string 2013-04-21 23:43:43 -04:00
Derek Collison
dcdcb84295 Allow non-quoted string values 2013-04-21 23:39:09 -04:00
Derek Collison
d10c170409 Assure semi-colon chaining on same line works 2013-03-25 19:05:13 -07:00
Derek Collison
446f2b923b Merged KeyStart and keyText to just Key emits 2013-03-24 14:40:09 -07:00
Derek Collison
6ec668df27 Removed item debug print 2013-03-24 12:45:56 -07:00
Derek Collison
390e530649 First pass configuration lexer 2013-03-24 12:34:26 -07:00