-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ ruby27.y: Added numbered parameters support. (#565)
This commit tracks upstream commits - ruby/ruby@12acc75 - ruby/ruby@d0e25ed - ruby/ruby@964bbc1 - ruby/ruby@ae07b66 - ruby/ruby@6ca9e7c - ruby/ruby@b8f3be2 - ruby/ruby@bb4ac7a
- Loading branch information
1 parent
0e613aa
commit 5d31c61
Showing
12 changed files
with
488 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
module Parser | ||
|
||
class Lexer::MaxNumparamStack | ||
def initialize | ||
@stack = [] | ||
end | ||
|
||
def cant_have_numparams! | ||
set(-1) | ||
end | ||
|
||
def can_have_numparams? | ||
top >= 0 | ||
end | ||
|
||
def register(numparam) | ||
set( [top, numparam].max ) | ||
end | ||
|
||
def top | ||
@stack.last | ||
end | ||
|
||
def push | ||
@stack.push(0) | ||
end | ||
|
||
def pop | ||
@stack.pop | ||
end | ||
|
||
private | ||
|
||
def set(value) | ||
@stack.pop | ||
@stack.push(value) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.