Commit Graph

88 Commits

Author SHA1 Message Date
Jean-Sébastien Pédron
98e134cb5c yamerl_constr: Ensure the node module is loaded
... before checking exported functions.
2014-07-15 12:27:11 +02:00
Jean-Sébastien Pédron
f3f7b5e218 Pass 'unicode' to re:run/3
Otherwise the application crash if the input string contains multibyte
characters. Here's the backtrace:
  2> yamerl_constr:string("いろは").
  ** exception error: bad argument
       in function  re:run/3
          called as re:run([12356,12429,12399],
                           "^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$",
                           [{capture,none}])
       in call from yamerl_node_float:string_to_float2/1 (src/yamerl_node_float.erl, line 145)
       in call from yamerl_node_float:construct_token/3 (src/yamerl_node_float.erl, line 64)
       in call from yamerl_node_float:try_construct_token/3 (src/yamerl_node_float.erl, line 54)
       in call from yamerl_constr:try_construct/3 (src/yamerl_constr.erl, line 371)
       in call from yamerl_constr:construct/2 (src/yamerl_constr.erl, line 315)
       in call from yamerl_constr:string/2 (src/yamerl_constr.erl, line 203)

PR:		#5
Reported by:	Eric Sagnes (ericsagnes on GitHub)
2014-06-24 16:56:22 +02:00
Jean-Sébastien Pédron
3955c235c3 yamerl_app.erl: Remove ?APPLICATION macro and hard-code "yamerl" 2014-04-17 15:46:21 +02:00
Jean-Sébastien Pédron
af554c3147 Update copyright year to 2014 2014-04-17 15:05:53 +02:00
Jean-Sébastien Pédron
327980b003 yamerl_parser: Fix two comments 2014-03-25 16:48:13 +01:00
Jean-Sébastien Pédron
b682790982 Move ebin/yamerl.app.in.in to src/yamerl.app.src
This is required by rebar(1). ebin/Makefile.am is updated to modify the
"{vsn, ...}" tuple while creating ebin/yamerl.app.

Submitted by:	Gleb Peregud (earlier version)
PR:		#2
2012-12-21 15:28:26 +01:00
Jean-Sébastien Pédron
981f944bf9 Define ?APPLICATION in yamerl_app.erl
No need to define it from the compiler: the application won't change
name often after all.
2012-12-21 15:26:56 +01:00
Jean-Sébastien Pédron
f7615484fc Add a yamerl wrapper to common functions
Currently, it has wrapper for:
    o  yamerl_constr:string/{1,2}
    o  yamerl_constr:file/{1,2}

Discussed with:	Gleb Peregud
PR:		#3
2012-12-20 14:51:08 +01:00
Jean-Sébastien Pédron
608d7f7559 Add license: 2-clause BSD license
PR:	#840
2012-12-12 11:35:10 +01:00
Jean-Sébastien Pédron
7abb388eef yamerl_constr: Rename main argument from Parser to Constr
This is to "undocument" the fact that the state is a yamerl_parser
state.
2012-12-11 16:16:26 +01:00
Jean-Sébastien Pédron
510aa11954 Improve specs and fix a bug in yamerl_constr:next_chunk/3
PR:	#849
2012-12-11 14:19:59 +01:00
Jean-Sébastien Pédron
372bab960e Rename option "simple_structs" to "detailed_constr"
CAUTION: the meaning is reversed! Though, the default behavior
({detailed_constr, false}) remains the same.
2012-12-10 15:28:28 +01:00
Jean-Sébastien Pédron
345ef4a63e Add -spec for next_fun/2 in yamerl_parser and yamerl_constr
PR:	#849
2012-12-10 11:29:23 +01:00
Jean-Sébastien Pédron
7b770b7b7c yamerl_constr: Support anchors and aliases
A new test is included, "examples", filled with the YAML snippets from
the YAML 1.2 specification, §2.5 Full Length Example.

PR:	#865
2012-12-07 16:40:05 +01:00
Jean-Sébastien Pédron
00dc3c11f6 Add -spec to yamler compatibility module
PR:	#849
2012-12-05 18:02:08 +01:00
Jean-Sébastien Pédron
40489699c4 Export yamerl_doc() and yamerl_simple_doc() types
PR:	#849
2012-12-05 18:01:41 +01:00
Jean-Sébastien Pédron
1d6d695c07 Add "yamler" compatibility module, called yamerl_yamler_compat
PR:	#844
2012-12-05 17:15:09 +01:00
Jean-Sébastien Pédron
6f50916322 Add a "yaml11" schema: use "_ext" node modules by default 2012-12-05 17:10:07 +01:00
Jean-Sébastien Pédron
737f1e42ce JSON string: a plain scalar is invalid
PR:	#864
2012-12-05 17:05:44 +01:00
Jean-Sébastien Pédron
18a66f2d91 yamerl_node_str: New "str_node_as_binary" option
If this option is enabled, an "str" node will be returned as a binary()
(encoded as UTF-8) instead of a string().

One may specify the encoding, using the following tuple:
  {str_node_as_binary, Encoding}
where Encoding is a unicode:encoding().
2012-12-05 12:09:21 +01:00
Jean-Sébastien Pédron
0a969e652b yamerl_constr: Add -spec for public functions
PR:	#849
2012-12-05 11:16:27 +01:00
Jean-Sébastien Pédron
89f33eab9b Add -spec to public functions
While here, fix some -type specifications.
2012-12-04 17:24:27 +01:00
Jean-Sébastien Pédron
c47ce9f789 Call proplists:unfold/1 before parsing options 2012-11-30 16:51:57 +01:00
Jean-Sébastien Pédron
c8474a9f40 Remove dependency between yamerl_errors and yamerl_parser
At the same time, remove unused ad badly designed functions from
yamerl_errors.
2012-11-23 14:53:21 +01:00
Jean-Sébastien Pédron
3351e77036 Fix how Erlang string to converted to Unicode binary
We use unicode:characters_to_binary/1 instead of list_to_binary/1.

PR:	#858
2012-11-23 12:29:46 +01:00
Jean-Sébastien Pédron
0ab68d2949 Change "erlang.org,2011" tag to "yamerl,2012"
PR:	#848
2012-11-19 14:23:42 +01:00
Jean-Sébastien Pédron
015a1425cb Support Erlang atom autodetection and "only if exist"
Note that the implementation differs from the yamler's one:
single-quoted flow scalars are not automatically converted to Erlang
atoms by yamerl because it's against the YAML 1.2 specification. The
specification states that only "?" non-specific should be "tasted" (ie.
plain flow scalars). Single-quoted and double quoted flow scalars as
well as block scalars have an implicit "!" non-specific tag and should
be interpreted as string.

See "§3.3.2 Resolved Tags" in the YAML 1.2 specification.

PR:	#846
PR:	#847
2012-11-19 14:13:51 +01:00
Jean-Sébastien Pédron
c8bed4a143 Support "external" options (eg. targetted to node type modules) 2012-11-19 14:11:27 +01:00
Jean-Sébastien Pédron
180a0644f4 Use "yamerl" as the extensions namespace instead of "yakaz.com"
PR:	#842
2012-11-16 14:55:03 +01:00
Jean-Sébastien Pédron
2cd8688712 Add yamerl_node_float_ext testsuite and fix bugs accordingly
PR:	#838
2012-11-16 14:24:28 +01:00
Jean-Sébastien Pédron
5da1810828 Fix regexes: "\." becomes "\\." 2012-11-16 14:24:00 +01:00
Jean-Sébastien Pédron
7930aa8759 Float parsing: Prepare string before calling erlang:list_to_float/1
Changes made are:
    o  If the string starts with ".", prepend a "0".
    o  If the string doesn't have digits following ".", add a "0".
2012-11-16 14:20:07 +01:00
Jean-Sébastien Pédron
ef9c56f193 Rename application from "yaml" to "yamerl"
PR:	#836
2012-11-15 16:20:29 +01:00
Jean-Sébastien Pédron
d6f161f66e Always enable native code for yaml_parser
Using HiPE brings about 50% gain with the new benchmark test. With this,
this YAML parser is generally faster than the SAX parser from xmerl.
However, this is far from enough to compete with any JSON parser.
2011-10-19 16:15:33 +02:00
Jean-Sébastien Pédron
b04c7d4729 Accept 'acc' and 'drop' as token functions
'acc': accumulate tokens in the parser's state. This was previously
available by not specifying a token function.

'drop': just drop tokens when they're ready.
2011-10-18 16:17:24 +02:00
Jean-Sébastien Pédron
3557b62f44 Replace set_default_tag/1 by specific macros
This optimization isn't that great though: merely 1%.
2011-10-17 12:30:34 +02:00
Jean-Sébastien Pédron
3e9126ed06 Remove warn_if_non_ascii_line_break/4 dead code 2011-10-05 15:57:58 +02:00
Jean-Sébastien Pédron
2a041048ff Convert warn_if_non_ascii_line_break/4 to a macro
This removes many functions calls. The performance gain is around 2%
with the source used during bench.
2011-10-05 15:46:49 +02:00
Jean-Sébastien Pédron
e9fe712c90 Avoid using '++' when possible
The performance gain is around 2% with the source used during bench.
2011-10-05 15:32:56 +02:00
Jean-Sébastien Pédron
1f26fa25ac Replace next_col/3 and next_line/4 by macros
The performance gain is around 5% with the source used during bench.
2011-10-05 14:45:58 +02:00
Jean-Sébastien Pédron
d316b7573a Split handling of escaped characters in flow scalar
Now, "normal" characters are treated in do_parse_flow_scalar/6 and
escaped characters are treated in do_parse_flow_scalar_escaped/6. The
"next_escaped" record member is gone. The performance gain is around
12% with the source used during the bench.
2011-10-05 12:01:03 +02:00
Jean-Sébastien Pédron
41991dd665 Remove a trailing space 2011-10-05 11:40:12 +02:00
Jean-Sébastien Pédron
0983bea3dd Remove next_state/6
Instead, the next state is called directly. The current state is saved
in #yaml_parser only when we need to suspend the parsing. The
performance gain is around 5%

While here, we convert some functions to macros, to take advantage of
the optimization described in §3.5 of the Efficiency Guide.
2011-10-05 11:06:10 +02:00
Jean-Sébastien Pédron
0eb4193ebd Maintain the input buffer outside of the #yaml_parser state
This removes frequent updates of the buffer and line/column numbers in
this state. It's only synchronized before return. The performance gain
is about 16% with the source used during bench.
2011-10-05 10:26:38 +02:00
Jean-Sébastien Pédron
46f645487e Use byte_size/1 instead of size/1 for binaries
This is recommended by Efficiency Guide, §3.6.
2011-09-30 11:30:11 +02:00
Jean-Sébastien Pédron
1299ee23f8 Fix float handling: we must use #yaml_float, not #yaml_int 2011-09-30 11:26:50 +02:00
Jean-Sébastien Pédron
3d328825dd Fix .nan case
It's not .Nan but .NaN (trailing capital N).
2011-09-29 14:27:13 +02:00
Jean-Sébastien Pédron
958ada0d22 Rename yaml_node_(json|ext)_$type to yaml_node_$type_(json|ext) 2011-09-29 14:04:09 +02:00
Jean-Sébastien Pédron
8d0f5d3a31 Fix multiple regex by specifying /^...$/
Otherwise, they could match a part of the input string and be happy with
that.
2011-09-29 11:33:11 +02:00
Jean-Sébastien Pédron
624a037f99 Accept "-0" 2011-09-29 11:32:57 +02:00