Commit Graph
44 Commits
Author SHA1 Message Date
Michael Go ffce6de8bb avoid using StringScanner eos 2024-10-30 13:45:10 -03:00
Michael Go f6a3e25e2e fix parsing quirky incomplete expressions 2024-10-30 13:44:35 -03:00
Michael Go 1375a9e4dc fix lexer parsing ID 'contains' as comparison 2024-10-30 13:39:55 -03:00
Michael Go 8a9f33a060 raise syntax error from lexer parser with utf8 character 2024-10-29 22:04:37 -03:00
Michael Go d94293a464 fix lexer parsing comparison without whitespaces 2024-10-28 19:30:12 -03:00
Ian Ker-SeymerandGitHub b3553787c8 Speed up the lexer for Ruby 3.4+ (#1832)
* Speed up lexing

* Bump msrv to 3.0 (from 2.7)

* Normalize test for ruby-head compat

* Fix bug when parsing negative numbers
2024-10-23 14:15:33 -04:00
Watson 7611463f02 Increase performance in Liquid::Lexer#tokenize
To obtain String Literal, the regular expression might be executed at two times.
It would be slightly faster to run them all at once using `Regexp.union`.

−               | before   | after   | result
--               | --       | --      | --
parse            | 63.418   | 65.183  | 1.028x
render           | 195.389  | 195.648 | -
parse & render   | 46.091   | 46.917  | 1.018x

### Environment
- MacBook Pro (14 inch, 2021)
- macOS 13.0 Beta
- Apple M1 Max
- Ruby 3.1.2

### Before
```
Running benchmark for 10 seconds (with 5 seconds warmup).

Warming up --------------------------------------
              parse:     6.000  i/100ms
             render:    19.000  i/100ms
     parse & render:     4.000  i/100ms
Calculating -------------------------------------
              parse:     63.418  (± 0.0%) i/s -    636.000  in  10.028939s
             render:    195.389  (± 0.5%) i/s -      1.957k in  10.016466s
     parse & render:     46.091  (± 0.0%) i/s -    464.000  in  10.067445s
```

### After
```
Running benchmark for 10 seconds (with 5 seconds warmup).

Warming up --------------------------------------
              parse:     6.000  i/100ms
             render:    19.000  i/100ms
     parse & render:     4.000  i/100ms
Calculating -------------------------------------
              parse:     65.183  (± 0.0%) i/s -    654.000  in  10.033549s
             render:    195.648  (± 1.0%) i/s -      1.957k in  10.003511s
     parse & render:     46.917  (± 0.0%) i/s -    472.000  in  10.060782s
```
2022-08-24 04:23:05 +09:00
Alessandro Diogo BrückheimerandMike Angell e83b1e4159 Add ForceEqualSignAlignment to .rubocop.yml (#1190)
* Add ForceEqualSignAlignment to .rubocop.yml

* Revert ForceEqualSignAlignment cop

* Update method alignment

* Undo addition of whitespace to improve readability

* Fix missing alignment
2019-10-21 21:18:48 +10:00
Mike AngellandGitHub b667bcb48b Shopify stye guide fixes (#1160) 2019-09-20 02:08:11 +10:00
0d26f05bb8 Enabled frozen string literals (#1154)
* Enabled frozen string literals

* Update rubocop config

* Prefer string interpolation in simple cases

Co-Authored-By: Dylan Thacker-Smith <[email protected]>
2019-09-18 13:19:45 +10:00
Mike Angell 799da202df Apply simple rubocop fixes 2019-08-31 21:58:33 +10:00
Ashwin MaroliandJustin Li f59f6dea83 Fix simple RuboCop offenses and update TODO file (#1062)
* Fix Layout/EmptyLineAfterMagicComment offense

* Fix Layout/ExtraSpacing offense

* Fix Layout/ClosingParenthesisIndentation offenses

* Fix Style/MutableConstant offense

* Fix Style/UnneededInterpolation offenses

* Fix Style/RedundantParentheses offenses

* Update TODO config for RuboCop

* Add executable bit to test/test_helper.rb

ref: https://travis-ci.org/Shopify/liquid/jobs/488169512#L578
2019-02-22 12:32:56 -05:00
Ashwin Maroli e4da4d49d2 assign regex to a constant 2018-03-13 23:36:56 +05:30
Michael Angell 6ed6e7e12f Allow :id to start with the word contains 2016-08-20 20:32:46 +10:00
Florian Weingarten 3372ca8136 Rubocop 2015-05-14 14:37:18 +00:00
Justin Li 81770f094d Remove unnecessary + 2014-10-29 13:39:43 -04:00
Justin Li dd5ee81089 Disallow number and dash identifier prefixes 2014-10-29 12:08:00 -04:00
Justin Li a07e382617 Use a single token for identifiers 2014-10-29 11:28:41 -04:00
Justin Li b4ea483c4e Separate ? and - into special tokens 2014-10-17 13:30:54 -04:00
Florian Weingarten 43ac8d560b Freeze all the things 2014-01-07 12:35:16 -05:00
Tristan Hume 7c5b3e0c3b Fix bad range parsing. 2013-09-04 18:13:31 -04:00
Tristan Hume 7b52dfcb95 Clean up lexer logic 2013-08-27 16:36:22 -04:00
Tristan Hume 1fa029ab67 Simplify lexer logic. 2013-08-27 11:35:03 -04:00
Tristan Hume 324d26d405 Consistent lack of periods in syntax errors. 2013-08-19 15:20:39 -04:00
Tristan Hume 48f50eea3b Remove unused lex_specials method 2013-08-02 15:12:11 -04:00
Tristan Hume 8ca00982b6 Fixed ranges and added for loop parser 2013-07-29 14:11:47 -04:00
Tristan Hume bc76c0daaf Collapse float and int into 'number' 2013-07-29 11:04:46 -04:00
Tristan Hume be4a04ed85 Merged array_tokens into recursive-parsing 2013-07-29 10:38:52 -04:00
Tristan Hume 8dcf44e99d Faster token creation, hopefully. 2013-07-29 10:23:04 -04:00
Tristan Hume a892e69a88 Hopefully fix CI build 2013-07-26 15:55:10 -04:00
Harry Brundage bf53e517f5 Inline Parser#next_token to avoid method dispatch 2013-07-26 15:38:52 -04:00
Harry Brundage bacacf2fd0 Remove the Token class from the lexer in favour of less smart but faster arrays 2013-07-26 15:14:01 -04:00
Tristan Hume 83e71ace99 Add lexer tests and fixes 2013-07-26 12:50:27 -04:00
Tristan Hume 8b1dff9d98 Allow ! in identifiers like Ruby 2013-07-26 10:33:30 -04:00
Tristan Hume 8896b55fa5 Parsing for if statements 2013-07-26 10:31:26 -04:00
Tristan Hume c0b9d53548 Revert "Test a different lexer architechture"
This reverts commit 24ddaf1a9c.
2013-07-26 09:52:04 -04:00
Tristan Hume 24ddaf1a9c Test a different lexer architechture 2013-07-26 09:51:58 -04:00
Tristan Hume 4da7b36139 New variable parser! 2013-07-25 11:38:57 -04:00
Tristan Hume f43e973e67 Basic expression parsing 2013-07-24 16:36:14 -04:00
Tristan Hume 84be895db2 Fancy StringScanner based lexer 2013-07-24 15:39:48 -04:00
Tristan Hume b20a594f25 Better lexer 2013-07-24 15:19:14 -04:00
Tristan Hume 76272a1afa Bring back the lexer 2013-07-24 14:40:29 -04:00
Tristan Hume ee14775f83 Replace hand-coded lexer with faster hacky lexer. 2013-07-24 11:41:47 -04:00
Tristan Hume 2332d86156 Slow lexer and parser scaffold. 2013-07-24 11:35:00 -04:00