aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/ruby-lex.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/irb] Ensure to restore $VERBOSENobuyoshi Nakada2021-01-051-1/+2
| | | | https://github.com/ruby/irb/commit/cef474a76a
* [ruby/irb] Use error tokens if there are no correct tokens in the same placeaycabta2021-01-051-6/+23
| | | | | | For example, the broken code "%www" will result in only one error token. https://github.com/ruby/irb/commit/9fa39a7cf3
* [ruby/irb] Use Ripper::Lexer#scan to take broken tokensaycabta2021-01-051-1/+11
| | | | | | ref. https://github.com/ruby/reline/pull/242 https://github.com/ruby/irb/commit/54f90cb6c9
* [ruby/irb] Heredoc may contain multiple newlines in a single tokenaycabta2021-01-051-2/+21
| | | | | | | | | Use the start token as the indentation criteria so that it works properly in heredoc. ref. https://github.com/ruby/reline/pull/242 https://github.com/ruby/irb/commit/9704808dfd
* [ruby/irb] Handle indentations related to keyword "do" correctlyaycabta2021-01-051-17/+47
| | | | | | This fixes ruby/irb#158. https://github.com/ruby/irb/commit/964643400b
* [ruby/irb] Newline in oneliner def doesn't reset indentaycabta2021-01-051-6/+8
| | | | | | This closes ruby/irb#132. https://github.com/ruby/irb/commit/43456dcf5e
* [ruby/irb] Suppress "shadowing outer" warningaycabta2020-12-231-1/+1
| | | | https://github.com/ruby/irb/commit/8b83fbef69
* [ruby/reline] [ruby/irb] Handle multiple newlines in a token correctlyaycabta2020-12-231-4/+9
| | | | | | | | | Co-authored-by: manga_osyo <manga.osyo@gmail.com> Co-authored-by: ima1zumi <mariimaizumi5@gmail.com> https://github.com/ruby/irb/commit/c59a9be82f https://github.com/ruby/reline/commit/a7922da16b
* [ruby/irb] Change variables handling for compatibilityaycabta2020-12-221-8/+8
| | | | https://github.com/ruby/irb/commit/26fd1a75cf
* [ruby/irb] Handle rest of tokens correctly if no newline at lastaycabta2020-12-201-0/+7
| | | | https://github.com/ruby/irb/commit/f3c8edad2a
* [ruby/reline] [ruby/irb] Call ripper only once when generating dynamic promptaycabta2020-12-191-41/+46
| | | | | | https://github.com/ruby/irb/commit/babb122a48 https://github.com/ruby/reline/commit/e6dbcb3b42
* [ruby/irb] Fixed a typo in a comment [ci skip]Nobuyoshi Nakada2020-12-171-1/+1
| | | | https://github.com/ruby/irb/commit/ce373417f3
* [ruby/irb] workaround for lack of tokens from `Ripper.lex`Nobuhiro IMAI2020-12-171-2/+5
| | | | | | * Fixes #38 https://github.com/ruby/irb/commit/905fb8e52e
* [ruby/irb] Add a fallback for check_code_block that does not depend on ↵Benoit Daloze2020-11-221-2/+7
| | | | | | | | implementation-private APIs * Fixes https://github.com/ruby/irb/issues/133 https://github.com/ruby/irb/commit/5eb3ef3293
* [ruby/irb] support more body argument for oneliner method definitionNobuhiro IMAI2020-11-221-9/+3
| | | | https://github.com/ruby/irb/commit/2ff1295533
* [ruby/irb] Support shortening lambda notetion for nesting level of promptaycabta2020-08-181-1/+1
| | | | https://github.com/ruby/irb/commit/f1a775af47
* [ruby/irb] Support shortening lambda notationaycabta2020-08-181-2/+2
| | | | https://github.com/ruby/irb/commit/8e3f81d428
* [ruby/irb] Support oneline method definitionaycabta2020-08-181-0/+77
| | | | https://github.com/ruby/irb/commit/826ae909c9
* Suppress "assigned but unused variable" warningsYusuke Endoh2020-07-231-1/+1
|
* [ruby/irb] handle rescue modifier properlyNobuhiro IMAI2020-07-221-5/+9
| | | | https://github.com/ruby/irb/commit/6de1341f5e
* [ruby/irb] Simplify RubyLex.compile_with_errors_suppressedaycabta2020-07-221-10/+9
| | | | | | | | | | | | | | | | nobu-san reviewed, https://github.com/ruby/irb/pull/106#pullrequestreview-423400033 > How about lexer = Ripper::Lexer.new(";\n#{code}", nil, 0)? > Encoding pragma is effective only at the beginning. > And the semicolon and newline will be skipped because the position is before > the initial pos. I employ the way. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> https://github.com/ruby/irb/commit/e593cc65b7
* [ruby/irb] Suppress incomplete encoding magic comment erroraycabta2020-07-221-2/+3
| | | | https://github.com/ruby/irb/commit/443e90af80
* [ruby/irb] Suppress incomplete coding magic comment erroraycabta2020-07-221-2/+19
| | | | https://github.com/ruby/irb/commit/6a457edbd1
* [ruby/irb] Require jruby lib to get JRuby.compile_irCharles Oliver Nutter2020-03-291-0/+1
| | | | https://github.com/ruby/irb/commit/dc59afe4f6
* [ruby/irb] Suppress crashing when EncodingError has occurred without linenoaycabta2020-03-261-0/+2
| | | | https://github.com/ruby/irb/commit/13572d8cdc
* [ruby/irb] Fix auto indent with closed braceaycabta2020-02-121-0/+1
| | | | | | | | | | | | A closed brace in auto-indent shouldn't affect the next brace in the same line, but it behaves like below: p() { } It's a bug. https://github.com/ruby/irb/commit/fbe59e344f
* [ruby/irb] Fix crashing when multiple open braces per lineBen2020-01-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/ruby/irb/issues/55 If we had put multiple open braces on a line the with no closing brace spaces_of_nest array keeps getting '0' added to it. This means that when we pop off of this array we are saying that we should be in position zero for the next line. This is an issue because we don't always want to be in position 0 after a closing brace. Example: ``` [[[ ] ] ] ``` In the above example the 'spaces_of_nest' array looks like this after the first line is entered: [0,0,0]. We really want to be indented 4 spaces for the 1st closing brace 2 for the 2nd and 0 for the 3rd. i.e. we want it to be: [0,2,4]. We also saw this issue with a heredoc inside of an array. ``` [<<FOO] hello FOO ``` https://github.com/ruby/irb/commit/80c69c8272
* [ruby/irb] Fix newline depth with multiple bracesBen2020-01-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes the check_newline_depth_difference method to multiple open braces on one line into account. Before this change we were subtracting from the depth in check_newline_depth_difference on every open brace. This is the right thing to do if the opening and closing brace are on the same line. For example in a method definition we have an opening and closing parentheses we want to add 1 to our depth, and then remove it. ``` def foo() end ``` However this isn't the correct behavior when the brace spans multiple lines. If a brace spans multiple lines we don't want to subtract from check_newline_depth_difference and we want to treat the braces the same way as we do `end` and allow check_corresponding_token_depth to pop the correct depth. Example of bad behavior: ``` def foo() [ ] puts 'bar' end ``` Example of desired behavior: ``` def foo() [ ] puts 'bar' end ``` https://github.com/ruby/irb/commit/7dc8af01e0
* [ruby/irb] Make nesting level up for `1.times do`Yusuke Endoh2019-12-221-1/+1
| | | | | | Follow up of the previous commit https://github.com/ruby/irb/commit/ab207353d3
* [ruby/irb] Fix auto-indent for `1.times do`Yusuke Endoh2019-12-221-1/+1
| | | | | | Fixes #47 https://github.com/ruby/irb/commit/6b8eca4635
* Fix auto-indent behavior correctlyaycabta2019-12-031-1/+1
|
* Revert "Treat :@1, :@@1, @1, and @@1 correctly to check termination"aycabta2019-11-291-15/+0
| | | | | | This reverts commit 5e275dd2af4d9d24cdb1cfc0f232f348dae9c2cd. ...The @1 type numberd parameter is reverted from Ruby syntax.
* Remove e2mmap dependencyaycabta2019-11-251-3/+5
|
* Replace typo "bock" with "block"aycabta2019-11-201-2/+2
|
* A preceding token of "do" of block has EXPR_CMDARG or EXPR_ENDFNaycabta2019-11-201-2/+2
| | | | | | | | meth do # the preceding token of "do" has EXPR_CMDARG end meth() do # the preceding token of "do" has EXPR_ENDFN end
* Number sign comment (# bla bla) is a kind of newline characteraycabta2019-11-201-2/+2
|
* Suppress warnings except for when last evaluationaycabta2019-11-131-4/+11
| | | | Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* Treat two types "do" correctlyaycabta2019-08-201-2/+20
| | | | | A "do" what has followed a token what has EXPR_CMDARG is for a block, and in other cases "do" is for "while", "until" or "for".
* Use JRuby equivalent of RubyVM.compile.Charles Oliver Nutter2019-07-271-1/+6
| | | | | RubyVM is specific to CRuby and not supported on JRuby. This is the equivalent operation.
* Check code_block_open for whether code continuesaycabta2019-07-031-2/+2
|
* Keyword token that follows EXPR_FNAME must be a method nameaycabta2019-07-021-3/+6
|
* Remove auto indent of continuation lineaycabta2019-06-281-3/+0
|
* Removed unused variableNobuyoshi Nakada2019-06-281-1/+1
|
* EXPR_LABEL also indicates non-continuation lineaycabta2019-06-271-1/+1
| | | | | | | | | Example: [ 1, # this is not continuation line 2 ]
* EXPR_CMDARG also indicates the end of an expressionaycabta2019-06-271-1/+1
|
* Increase indent of continuation lineaycabta2019-06-271-0/+3
| | | | | v = 3 # auto indent
* Decrease nesting level when closing token comes at a non-first token of lineaycabta2019-06-261-0/+2
|
* `ensure` is not a continuos lineNobuyoshi Nakada2019-06-261-1/+1
|
* Decrease indent at "elsif" tooNobuyoshi Nakada2019-06-261-2/+2
|
* Remove other debug printsNobuyoshi Nakada2019-06-261-3/+0
|