8000 Lua scanner, tweaked (finally!) by korny · Pull Request #141 · rubychan/coderay · GitHub
[go: up one dir, main page]

Skip to content
8000

Lua scanner, tweaked (finally!) #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 22, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix for Ruby 1.8, escape { and } in regexps
  • Loading branch information
korny committed Jun 19, 2012
commit 2b16d115f7d6caf21864934df763556e126d6357
12 changes: 6 additions & 6 deletions lib/coderay/scanners/lua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class CodeRay::Scanners::Lua < CodeRay::Scanners::Scanner
]

# Automatic token kind selection for normal words.
IDENT_KIND = CodeRay::WordList.new(:ident)
.add(KEYWORDS, :keyword)
.add(PREDEFINED_CONSTANTS, :predefined_constant)
.add(PREDEFINED_EXPRESSIONS, :predefined)
IDENT_KIND = CodeRay::WordList.new(:ident).
add(KEYWORDS, :keyword).
add(PREDEFINED_CONSTANTS, :predefined_constant).
add(PREDEFINED_EXPRESSIONS, :predefined)

protected

Expand Down Expand Up @@ -99,13 +99,13 @@ def handle_state_initial

@encoder.text_token(match, kind)

elsif match = scan(/{/) # Opening table brace {
elsif match = scan(/\{/) # Opening table brace {
@encoder.begin_group(:table)
@encoder.text_token(match, @brace_depth >= 1 ? :inline_delimiter : :delimiter)
@brace_depth += 1
@state = :table

elsif match = scan(/}/) # Closing table brace }
elsif match = scan(/\}/) # Closing table brace }
if @brace_depth == 1
@brace_depth = 0
@encoder.text_token(match, :delimiter)
Expand Down
0