Skip to content

Bash Scanner #119

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
update from pejuko/coderay_bash
  • Loading branch information
korny committed Jun 10, 2013
commit 55a95e67d8b1a703c8643d2b2df4178d0293b61d
22 changes: 11 additions & 11 deletions lib/coderay/scanners/bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def scan_tokens encoder, options
kind = match = nil

if match = scan(/\n/)
encoder.text_token(match, :plain)
encoder.text_token(match, :end_line)
next
end

Expand All @@ -85,9 +85,11 @@ def scan_tokens encoder, options
kind = :directive
elsif match = scan(/\s*#.*/)
kind = :comment
elsif match = scan(/.#/)
elsif match = scan(/[^"]#/)
kind = :ident
elsif match = scan(/(?:\. |source ).*/)
elsif match = scan(/\.\.+/)
kind = :plain
elsif match = scan(/(?:\.|source)\s+/)
kind = :reserved
elsif match = scan(/(?:\\.|,)/)
kind = :plain
Expand Down Expand Up @@ -146,13 +148,11 @@ def scan_tokens encoder, options
encoder.begin_group :shell
encoder.text_token(match, :delimiter)
next
elsif match = scan(/ \) /ox)
if @brace_shell > 0
encoder.text_token(match, :delimiter)
encoder.end_group :shell
@brace_shell -= 1
next
end
elsif @brace_shell > 0 && match = scan(/ \) /ox)
encoder.text_token(match, :delimiter)
encoder.end_group :shell
@brace_shell -= 1
next
elsif match = scan(PRE_CONSTANTS)
kind = :predefined_constant
elsif match = scan(/[^\s'"]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
Expand Down Expand Up @@ -266,7 +266,7 @@ def scan_tokens encoder, options


def match_array(match, encoder)
match =~ /([A-Za-z_]+)\[(.*?)\]/
match =~ /(.+)\[(.*?)\]/
var = $1
key = $2
kind = IDENT_KIND[var]
Expand Down