Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix spacing, remove trailing whitespace.

  • Loading branch information...
commit 2b834a8ec18903968dbf43dd9d2f8f643327f752 1 parent f16dcc4
Christopher Bertels authored
Showing with 25 additions and 30 deletions.
  1. +9 −9 bin/ifancy
  2. +16 −21 ruby_lib/interactive/hilight.rb
18 bin/ifancy
View
@@ -32,7 +32,7 @@ HISTORY = []
PROMPT = "ifancy[%d]> "
class Prompt {
-
+
def initialize: @str {
@line = 0
}
@@ -48,7 +48,7 @@ class Feature {
def initialize: @name will: @desc by: @block {
@@hooks at: @name put: self
}
-
+
def run: string { @block call: string }
def about { @name ++ ": " ++ @desc }
@@ -152,15 +152,15 @@ prompt = Prompt new: PROMPT
Feature new: "exit" will: "Exit the shell" by: |x| { System exit }
Feature new: "quit" will: "Exit the shell" by: |x| { System exit }
-Feature new: "?" will: "Give information on a command" by: |x| {
+Feature new: "?" will: "Give information on a command" by: |x| {
f = Feature get: $ x words [1]
if: f then: {
- if: (f is_a?: Feature) then: {
- f about . println
+ if: (f is_a?: Feature) then: {
+ f about . println
} else: {
"Sorry, #{x words [1]} is not a feature that is loaded}" println
}
- } else: {
+ } else: {
"Please supply the name of a feature as an argument" println
}
}
@@ -177,11 +177,11 @@ Feature new: "#{" will: "Create multiline capabilities" by: |x| {
prompt aug_line: (( line_s split: "\n") size)
} catch Exception => e {
e message() println
- }
+ }
}
loop: {
- line = read_line: prompt
+ line = read_line: prompt
{ next } if: (Feature match: (line words [0]) str: line)
HISTORY << line
@@ -190,7 +190,7 @@ loop: {
HISTORY pop()
}
try {
- if: (Fancy Interactive at: 'coderay) then: {
+ if: (Fancy Interactive at: 'coderay) then: {
"=> #{CodeRay.scan((Fancy eval: line binding: bnd . inspect), 'fancy).term()}" println
} else: {
"=> #{Fancy eval: line binding: bnd . inspect}" println
37 ruby_lib/interactive/hilight.rb
View
@@ -1,35 +1,35 @@
# encoding: utf-8
module CodeRay
module Scanners
-
+
# Fancy scanner by swarley.
class Fancy < Scanner
-
+
register_for :fancy
file_extension 'fy'
-
+
SPECIAL_FORMS = %w[
def throw try catch class
] # :nodoc:
-
+
CORE_FORMS = %w[
+ - > < == != >= <= % ** * = && || =~
] # :nodoc:
-
+
PREDEFINED_CONSTANTS = %w[
true false nil
] # :nodoc:
-
+
IDENT_KIND = WordList.new(:ident).
add(SPECIAL_FORMS, :keyword).
add(CORE_FORMS, :keyword).
add(PREDEFINED_CONSTANTS, :predefined_constant)
-
+
KEYWORD_NEXT_TOKEN_KIND = WordList.new(nil).
add(%w[ def defn defn- definline defmacro defmulti defmethod defstruct defonce declare ], :function).
add(%w[ ns ], :namespace).
add(%w[ defprotocol defrecord ], :class)
-
+
BASIC_IDENTIFIER = /[a-zA-Z$%*\/_+!?&<>\-=]=?[a-zA-Z0-9$&*+!\/_?<>\-\#]*/
CLASS_IDENTIFIER = /[A-Z]+[A-Za-z0-9]*|[A-Z]+[A-Za-z0-9]\:\:|\:\:[A-Z]+[A-Za-z0-9]*/
IDENTIFIER = /(?!-\d)(?:(?:#{BASIC_IDENTIFIER}\.)*#{BASIC_IDENTIFIER}(?:\/#{BASIC_IDENTIFIER})?\.?)|\.\.?/
@@ -43,15 +43,14 @@ def throw try catch class
NUM = /(?:\-)*(?:#{DIGIT}|#{DIGIT16}|#{DIGIT8}|#{DIGIT2}|#{DECIMAL})/
MESSAGE = /[A-Za-z0-9\&\_]+?(?:\:|\?\:)/
CAPTURE = /\|.+?\|/
- protected
-
- def scan_tokens encoder, options
-
+
+ protected
+
+ def scan_tokens(encoder, options)
state = :initial
kind = nil
-
+
until eos?
-
case state
when :initial
if match = scan(/ \s+ | \n | , /x)
@@ -98,7 +97,7 @@ def scan_tokens encoder, options
else
encoder.text_token getch, :error
end
-
+
when :string, :regexp
if match = scan(/[^"\\]+|\\.?/)
encoder.text_token match, :content
@@ -110,20 +109,16 @@ def scan_tokens encoder, options
raise_inspect "else case \" reached; %p not handled." % peek(1),
encoder, state
end
-
else
raise 'else case reached'
-
end
-
end
-
+
if [:string, :regexp].include? state
encoder.end_group state
end
-
+
encoder
-
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.