Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes sublimehq#1609 Fixes sublimehq#1724 According to sublimehq#481 this PR provides an Oniguruma free Erlang syntax definition written from scratch. Outline ======= The syntax definition is based on the http://erlang.org/doc and includes all sematic features of Erlang/OTP 21.2 which are required for highlighting. It follows https://www.sublimetext.com/docs/3/syntax.html and includes concepts from https://github.com/sublimehq/Packages. Nearly every aspect and detail of the syntax definition was designed from ground up making use of the latest features of ST's syntax engine and with the intent to apply the most recent best practice examples found in other recently updated syntax definitions. Changes ======= * Add support for Erlang ShellScript (escript) * Add support for Erlang Type Language (`-type`, `-spec` directive) * Add lots of detailed test cases * Add some invalid illegal matching where appropriate * Add builtin constants and macros highlighting * Improve the list of builtin functions ([BIFs](http://erlang.org/doc/man/erlang.html#exports)) * Improve indention settings * Improve shebang/editorconfig detection in `first_line_match` * Improve support for _Goto Definition_ and _Goto Reference_ * Improve parsing performance by round about 50% * Fix quoted atom highlighting (function names, module names, field names, ...) * Fix bitstring data type highlighting * Fix string escape highlighting * Fix string placeholders highlighting * Fix identifier break handling (`@` is no word-break) * Fix lots of context pop offs * ... Benchmarks ========== The whole design and development process included benchmarking of different solutions to find the best possible performance for the different sets of rules. The following examples provide an impression of the performance improvements achieved with the new design. **10k binary** Bin = << << (X*2) >> || <<X>> <= << 1,2,3 >> >>. **10k maps** Expr#{name=>"adam",{age,24}:=fct(),4.0=>{july,29}} **10k records** #record{field1="val1", Field2=3, field3, 'Field-4'={}, _=atom} **10k fun types** -type fun() :: fun(() -> int()). **10k spec** -spec is_foo(Pid) -> boolean() when Pid :: pid() | if(); (Pid) -> ok. **ErlangOTP files** https://github.com/erlang/otp/blob/master/lib/wx/include/gl.hrl https://github.com/erlang/otp/blob/master/lib/stdlib/test/re_testoutput1_split_test.erl https://github.com/erlang/otp/blob/master/lib/xmerl/test/xmerl_sax_std_SUITE.erl https://github.com/erlang/otp/blob/master/lib/crypto/test/crypto_SUITE.erl Results ======= Type | before | after | difference -------------------------------|------------|-------------|------------ 10k binaries | 303ms | 140ms | -53.8% 10k maps | 326ms | 156ms | -52.1% 10k records | 399ms | 130ms | -67.4% 10k fun type | n.a. | 79ms | 10k spec | n.a. | 176ms | gl.hrl | 47ms | 24ms | -48.9% re_testoutput1_split_test.erl | 448ms | 305ms | -31.9% xmerl_sax_std_SUITE.erl | 389ms | 127ms | -67.4% crypto_SUITE.erl | 79ms | 27ms | -65.8%
- Loading branch information