chess_engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -0
- data/README.md +26 -0
- data/chess_engine.gemspec +14 -0
- data/lib/chess_engine/board.rb +95 -0
- data/lib/chess_engine/cli.rb +105 -0
- data/lib/chess_engine/game.rb +148 -0
- data/lib/chess_engine/input.rb +19 -0
- data/lib/chess_engine/move.rb +35 -0
- data/lib/chess_engine/piece.rb +97 -0
- data/lib/chess_engine/validator.rb +87 -0
- data/lib/chess_engine.rb +1 -0
- data/spec/board_spec.rb +70 -0
- data/spec/game_helper.rb +5 -0
- data/spec/game_spec.rb +79 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/validator_spec.rb +26 -0
- data/vendor/bundle/bin/coderay +27 -0
- data/vendor/bundle/bin/pry +27 -0
- data/vendor/bundle/cache/coderay-1.1.2.gem +0 -0
- data/vendor/bundle/cache/colorize-0.8.1.gem +0 -0
- data/vendor/bundle/cache/method_source-0.9.2.gem +0 -0
- data/vendor/bundle/cache/pry-0.12.2.gem +0 -0
- data/vendor/bundle/cache/rb-readline-0.5.5.gem +0 -0
- data/vendor/bundle/gems/coderay-1.1.2/MIT-LICENSE +22 -0
- data/vendor/bundle/gems/coderay-1.1.2/README_INDEX.rdoc +123 -0
- data/vendor/bundle/gems/coderay-1.1.2/bin/coderay +215 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/duo.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/_map.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/comment_filter.rb +25 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/count.rb +39 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug.rb +49 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug_lint.rb +63 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/div.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb +190 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/filter.rb +58 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/css.rb +65 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/numbering.rb +108 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/output.rb +166 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html.rb +333 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/json.rb +83 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lines_of_code.rb +45 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lint.rb +59 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/null.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/page.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/span.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/statistic.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/terminal.rb +195 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/text.rb +46 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/token_kind_filter.rb +111 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/xml.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/yaml.rb +50 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/for_redcloth.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/file_type.rb +151 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin_host.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/word_list.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/_map.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/c.rb +189 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/clojure.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/cpp.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/css.rb +196 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/debug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/delphi.rb +144 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/diff.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/erb.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/go.rb +208 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/groovy.rb +268 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/haml.rb +168 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/html.rb +275 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java/builtin_types.rb +421 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java.rb +174 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java_script.rb +237 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/json.rb +98 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/lua.rb +280 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/php.rb +527 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/python.rb +287 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/raydebug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/patterns.rb +178 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/string_state.rb +79 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby.rb +477 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sass.rb +232 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb +337 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sql.rb +169 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/taskpaper.rb +36 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/text.rb +26 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/xml.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/yaml.rb +140 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners.rb +27 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/_map.rb +7 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/alpha.rb +153 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/style.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles.rb +15 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/token_kinds.rb +85 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens.rb +161 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/version.rb +3 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay.rb +284 -0
- data/vendor/bundle/gems/colorize-0.8.1/CHANGELOG +65 -0
- data/vendor/bundle/gems/colorize-0.8.1/LICENSE +339 -0
- data/vendor/bundle/gems/colorize-0.8.1/README.md +105 -0
- data/vendor/bundle/gems/colorize-0.8.1/Rakefile +13 -0
- data/vendor/bundle/gems/colorize-0.8.1/colorize.gemspec +36 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/class_methods.rb +120 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/instance_methods.rb +132 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize.rb +12 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorized_string.rb +19 -0
- data/vendor/bundle/gems/colorize-0.8.1/test/test_colorize.rb +164 -0
- data/vendor/bundle/gems/method_source-0.9.2/Gemfile +2 -0
- data/vendor/bundle/gems/method_source-0.9.2/LICENSE +25 -0
- data/vendor/bundle/gems/method_source-0.9.2/README.markdown +91 -0
- data/vendor/bundle/gems/method_source-0.9.2/Rakefile +81 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/code_helpers.rb +154 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/source_location.rb +138 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/version.rb +3 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source.rb +141 -0
- data/vendor/bundle/gems/method_source-0.9.2/method_source.gemspec +35 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source/code_helpers_spec.rb +43 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source_spec.rb +143 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb +101 -0
- data/vendor/bundle/gems/pry-0.12.2/CHANGELOG.md +953 -0
- data/vendor/bundle/gems/pry-0.12.2/LICENSE +25 -0
- data/vendor/bundle/gems/pry-0.12.2/README.md +390 -0
- data/vendor/bundle/gems/pry-0.12.2/bin/pry +8 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/basic_object.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/cli.rb +218 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_file.rb +110 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_range.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/loc.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code.rb +353 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code_object.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/color_printer.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command.rb +723 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command_set.rb +415 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/amend_line.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang.rb +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang_pry.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/exception_formatter.rb +79 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/file_formatter.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat.rb +63 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cd.rb +41 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_prompt.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/clear_screen.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/code_collector.rb +167 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disable_pry.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disabled_commands.rb +2 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/easter_eggs.rb +112 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_all.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_program.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/find_method.rb +191 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/fix_indent.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_cd.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_install.rb +32 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_open.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_readme.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_search.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_stats.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gist.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/help.rb +164 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/hist.rb +181 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/import_set.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/jump_to.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/list_inspectors.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/constants.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/formatter.rb +51 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/globals.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/grep.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/instance_vars.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_names.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_vars.rb +37 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/ls_entity.rb +69 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/self_methods.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls.rb +113 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/nesting.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/play.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_backtrace.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_version.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reload_code.rb +62 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reset.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ri.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/save_file.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_command.rb +75 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_mode.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_doc.rb +81 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_info.rb +216 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_input.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_source.rb +53 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/stat.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/switch_to.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/toggle_color.rb +24 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression.rb +107 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/whereami.rb +197 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/wtf.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/behavior.rb +255 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/convenience.rb +28 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/default.rb +159 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/memoization.rb +48 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/core_extensions.rb +142 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/editor.rb +128 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/exceptions.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/forwardable.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/base_helpers.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/command_helpers.rb +157 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/documentation_helpers.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/options_helpers.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/platform.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/table.rb +114 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/text.rb +115 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/history.rb +161 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/hooks.rb +171 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/indent.rb +408 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_completer.rb +265 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_lock.rb +130 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/last_exception.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/disowned.rb +55 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/patcher.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb +198 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method.rb +552 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/object_path.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/output.rb +50 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pager.rb +250 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/platform.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/plugins.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/prompt.rb +145 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_class.rb +425 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_instance.rb +699 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl.rb +261 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl_file_loader.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/ring.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/rubygem.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/LICENSE +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/commands.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/option.rb +206 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop.rb +661 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/terminal.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/evalable.rb +15 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/mockable.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/pry_tester.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/utility.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/variables.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/version.rb +3 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module/candidate.rb +131 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module.rb +378 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry.rb +132 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/CHANGES +94 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/LICENSE +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/README.md +81 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/Rakefile +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/bench/_rl_adjust_point.rb +26 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline.rb +8 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline_with_completion.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/tinyirb.rb +11 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rb-readline.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline/version.rb +3 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline.rb +8920 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/readline.rb +539 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/rb-readline.gemspec +51 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/setup.rb +1585 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/support/filesystem_completion_helper.rb +53 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_completion.rb +100 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_filename_completion_proc.rb +88 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_history.rb +29 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_rbreadline.rb +23 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_readline.rb +221 -0
- data/vendor/bundle/specifications/coderay-1.1.2.gemspec +26 -0
- data/vendor/bundle/specifications/colorize-0.8.1.gemspec +38 -0
- data/vendor/bundle/specifications/method_source-0.9.2.gemspec +35 -0
- data/vendor/bundle/specifications/pry-0.12.2.gemspec +38 -0
- data/vendor/bundle/specifications/rb-readline-0.5.5.gemspec +39 -0
- metadata +363 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module CodeRay
|
3
|
+
module Scanners
|
4
|
+
|
5
|
+
# Clojure scanner by Licenser.
|
6
|
+
class Clojure < Scanner
|
7
|
+
|
8
|
+
register_for :clojure
|
9
|
+
file_extension 'clj'
|
10
|
+
|
11
|
+
SPECIAL_FORMS = %w[
|
12
|
+
def if do let quote var fn loop recur throw try catch monitor-enter monitor-exit .
|
13
|
+
new
|
14
|
+
] # :nodoc:
|
15
|
+
|
16
|
+
CORE_FORMS = %w[
|
17
|
+
+ - -> ->> .. / * <= < = == >= > accessor aclone add-classpath add-watch
|
18
|
+
agent agent-error agent-errors aget alength alias all-ns alter alter-meta!
|
19
|
+
alter-var-root amap ancestors and apply areduce array-map aset aset-boolean
|
20
|
+
aset-byte aset-char aset-double aset-float aset-int aset-long aset-short
|
21
|
+
assert assoc assoc! assoc-in associative? atom await await-for bases bean
|
22
|
+
bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or
|
23
|
+
bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array
|
24
|
+
booleans bound-fn bound-fn* bound? butlast byte byte-array bytes case cast char
|
25
|
+
char-array char-escape-string char-name-string char? chars class class?
|
26
|
+
clear-agent-errors clojure-version coll? comment commute comp comparator
|
27
|
+
compare compare-and-set! compile complement concat cond condp conj conj!
|
28
|
+
cons constantly construct-proxy contains? count counted? create-ns
|
29
|
+
create-struct cycle dec decimal? declare definline defmacro defmethod defmulti
|
30
|
+
defn defn- defonce defprotocol defrecord defstruct deftype delay delay?
|
31
|
+
deliver denominator deref derive descendants disj disj! dissoc dissoc!
|
32
|
+
distinct distinct? doall doc dorun doseq dosync dotimes doto double
|
33
|
+
double-array doubles drop drop-last drop-while empty empty? ensure
|
34
|
+
enumeration-seq error-handler error-mode eval even? every? extend
|
35
|
+
extend-protocol extend-type extenders extends? false? ffirst file-seq
|
36
|
+
filter find find-doc find-ns find-var first float float-array float?
|
37
|
+
floats flush fn fn? fnext for force format future future-call future-cancel
|
38
|
+
future-cancelled? future-done? future? gen-class gen-interface gensym get
|
39
|
+
get-in get-method get-proxy-class get-thread-bindings get-validator hash
|
40
|
+
hash-map hash-set identical? identity if-let if-not ifn? import in-ns
|
41
|
+
inc init-proxy instance? int int-array integer? interleave intern
|
42
|
+
interpose into into-array ints io! isa? iterate iterator-seq juxt key
|
43
|
+
keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list*
|
44
|
+
list? load load-file load-reader load-string loaded-libs locking long
|
45
|
+
long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy
|
46
|
+
map map? mapcat max max-key memfn memoize merge merge-with meta methods
|
47
|
+
min min-key mod name namespace neg? newline next nfirst nil? nnext not
|
48
|
+
not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns
|
49
|
+
ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth
|
50
|
+
nthnext num number? numerator object-array odd? or parents partial
|
51
|
+
partition pcalls peek persistent! pmap pop pop! pop-thread-bindings
|
52
|
+
pos? pr pr-str prefer-method prefers print print-namespace-doc
|
53
|
+
print-str printf println println-str prn prn-str promise proxy
|
54
|
+
proxy-mappings proxy-super push-thread-bindings pvalues quot rand
|
55
|
+
rand-int range ratio? rationalize re-find re-groups re-matcher
|
56
|
+
re-matches re-pattern re-seq read read-line read-string reduce ref
|
57
|
+
ref-history-count ref-max-history ref-min-history ref-set refer
|
58
|
+
refer-clojure reify release-pending-sends rem remove remove-all-methods
|
59
|
+
remove-method remove-ns remove-watch repeat repeatedly replace replicate
|
60
|
+
require reset! reset-meta! resolve rest restart-agent resultset-seq
|
61
|
+
reverse reversible? rseq rsubseq satisfies? second select-keys send
|
62
|
+
send-off seq seq? seque sequence sequential? set set-error-handler!
|
63
|
+
set-error-mode! set-validator! set? short short-array shorts
|
64
|
+
shutdown-agents slurp some sort sort-by sorted-map sorted-map-by
|
65
|
+
sorted-set sorted-set-by sorted? special-form-anchor special-symbol?
|
66
|
+
split-at split-with str string? struct struct-map subs subseq subvec
|
67
|
+
supers swap! symbol symbol? sync syntax-symbol-anchor take take-last
|
68
|
+
take-nth take-while test the-ns thread-bound? time to-array to-array-2d
|
69
|
+
trampoline transient tree-seq true? type unchecked-add unchecked-dec
|
70
|
+
unchecked-divide unchecked-inc unchecked-multiply unchecked-negate
|
71
|
+
unchecked-remainder unchecked-subtract underive update-in update-proxy
|
72
|
+
use val vals var-get var-set var? vary-meta vec vector vector-of vector?
|
73
|
+
when when-first when-let when-not while with-bindings with-bindings*
|
74
|
+
with-in-str with-local-vars with-meta with-open with-out-str
|
75
|
+
with-precision xml-seq zero? zipmap
|
76
|
+
] # :nodoc:
|
77
|
+
|
78
|
+
PREDEFINED_CONSTANTS = %w[
|
79
|
+
true false nil *1 *2 *3 *agent* *clojure-version* *command-line-args*
|
80
|
+
*compile-files* *compile-path* *e *err* *file* *flush-on-newline*
|
81
|
+
*in* *ns* *out* *print-dup* *print-length* *print-level* *print-meta*
|
82
|
+
*print-readably* *read-eval* *warn-on-reflection*
|
83
|
+
] # :nodoc:
|
84
|
+
|
85
|
+
IDENT_KIND = WordList.new(:ident).
|
86
|
+
add(SPECIAL_FORMS, :keyword).
|
87
|
+
add(CORE_FORMS, :keyword).
|
88
|
+
add(PREDEFINED_CONSTANTS, :predefined_constant)
|
89
|
+
|
90
|
+
KEYWORD_NEXT_TOKEN_KIND = WordList.new(nil).
|
91
|
+
add(%w[ def defn defn- definline defmacro defmulti defmethod defstruct defonce declare ], :function).
|
92
|
+
add(%w[ ns ], :namespace).
|
93
|
+
add(%w[ defprotocol defrecord ], :class)
|
94
|
+
|
95
|
+
BASIC_IDENTIFIER = /[a-zA-Z$%*\/_+!?&<>\-=]=?[a-zA-Z0-9$&*+!\/_?<>\-\#]*/
|
96
|
+
IDENTIFIER = /(?!-\d)(?:(?:#{BASIC_IDENTIFIER}\.)*#{BASIC_IDENTIFIER}(?:\/#{BASIC_IDENTIFIER})?\.?)|\.\.?/
|
97
|
+
SYMBOL = /::?#{IDENTIFIER}/o
|
98
|
+
DIGIT = /\d/
|
99
|
+
DIGIT10 = DIGIT
|
100
|
+
DIGIT16 = /[0-9a-f]/i
|
101
|
+
DIGIT8 = /[0-7]/
|
102
|
+
DIGIT2 = /[01]/
|
103
|
+
RADIX16 = /\#x/i
|
104
|
+
RADIX8 = /\#o/i
|
105
|
+
RADIX2 = /\#b/i
|
106
|
+
RADIX10 = /\#d/i
|
107
|
+
EXACTNESS = /#i|#e/i
|
108
|
+
SIGN = /[\+-]?/
|
109
|
+
EXP_MARK = /[esfdl]/i
|
110
|
+
EXP = /#{EXP_MARK}#{SIGN}#{DIGIT}+/
|
111
|
+
SUFFIX = /#{EXP}?/
|
112
|
+
PREFIX10 = /#{RADIX10}?#{EXACTNESS}?|#{EXACTNESS}?#{RADIX10}?/
|
113
|
+
PREFIX16 = /#{RADIX16}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX16}/
|
114
|
+
PREFIX8 = /#{RADIX8}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX8}/
|
115
|
+
PREFIX2 = /#{RADIX2}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX2}/
|
116
|
+
UINT10 = /#{DIGIT10}+#*/
|
117
|
+
UINT16 = /#{DIGIT16}+#*/
|
118
|
+
UINT8 = /#{DIGIT8}+#*/
|
119
|
+
UINT2 = /#{DIGIT2}+#*/
|
120
|
+
DECIMAL = /#{DIGIT10}+#+\.#*#{SUFFIX}|#{DIGIT10}+\.#{DIGIT10}*#*#{SUFFIX}|\.#{DIGIT10}+#*#{SUFFIX}|#{UINT10}#{EXP}/
|
121
|
+
UREAL10 = /#{UINT10}\/#{UINT10}|#{DECIMAL}|#{UINT10}/
|
122
|
+
UREAL16 = /#{UINT16}\/#{UINT16}|#{UINT16}/
|
123
|
+
UREAL8 = /#{UINT8}\/#{UINT8}|#{UINT8}/
|
124
|
+
UREAL2 = /#{UINT2}\/#{UINT2}|#{UINT2}/
|
125
|
+
REAL10 = /#{SIGN}#{UREAL10}/
|
126
|
+
REAL16 = /#{SIGN}#{UREAL16}/
|
127
|
+
REAL8 = /#{SIGN}#{UREAL8}/
|
128
|
+
REAL2 = /#{SIGN}#{UREAL2}/
|
129
|
+
IMAG10 = /i|#{UREAL10}i/
|
130
|
+
IMAG16 = /i|#{UREAL16}i/
|
131
|
+
IMAG8 = /i|#{UREAL8}i/
|
132
|
+
IMAG2 = /i|#{UREAL2}i/
|
133
|
+
COMPLEX10 = /#{REAL10}@#{REAL10}|#{REAL10}\+#{IMAG10}|#{REAL10}-#{IMAG10}|\+#{IMAG10}|-#{IMAG10}|#{REAL10}/
|
134
|
+
COMPLEX16 = /#{REAL16}@#{REAL16}|#{REAL16}\+#{IMAG16}|#{REAL16}-#{IMAG16}|\+#{IMAG16}|-#{IMAG16}|#{REAL16}/
|
135
|
+
COMPLEX8 = /#{REAL8}@#{REAL8}|#{REAL8}\+#{IMAG8}|#{REAL8}-#{IMAG8}|\+#{IMAG8}|-#{IMAG8}|#{REAL8}/
|
136
|
+
COMPLEX2 = /#{REAL2}@#{REAL2}|#{REAL2}\+#{IMAG2}|#{REAL2}-#{IMAG2}|\+#{IMAG2}|-#{IMAG2}|#{REAL2}/
|
137
|
+
NUM10 = /#{PREFIX10}?#{COMPLEX10}/
|
138
|
+
NUM16 = /#{PREFIX16}#{COMPLEX16}/
|
139
|
+
NUM8 = /#{PREFIX8}#{COMPLEX8}/
|
140
|
+
NUM2 = /#{PREFIX2}#{COMPLEX2}/
|
141
|
+
NUM = /#{NUM10}|#{NUM16}|#{NUM8}|#{NUM2}/
|
142
|
+
|
143
|
+
protected
|
144
|
+
|
145
|
+
def scan_tokens encoder, options
|
146
|
+
|
147
|
+
state = :initial
|
148
|
+
kind = nil
|
149
|
+
|
150
|
+
until eos?
|
151
|
+
|
152
|
+
case state
|
153
|
+
when :initial
|
154
|
+
if match = scan(/ \s+ | \\\n | , /x)
|
155
|
+
encoder.text_token match, :space
|
156
|
+
elsif match = scan(/['`\(\[\)\]\{\}]|\#[({]|~@?|[@\^]/)
|
157
|
+
encoder.text_token match, :operator
|
158
|
+
elsif match = scan(/;.*/)
|
159
|
+
encoder.text_token match, :comment # TODO: recognize (comment ...) too
|
160
|
+
elsif match = scan(/\#?\\(?:newline|space|.?)/)
|
161
|
+
encoder.text_token match, :char
|
162
|
+
elsif match = scan(/\#[ft]/)
|
163
|
+
encoder.text_token match, :predefined_constant
|
164
|
+
elsif match = scan(/#{IDENTIFIER}/o)
|
165
|
+
kind = IDENT_KIND[match]
|
166
|
+
encoder.text_token match, kind
|
167
|
+
if rest? && kind == :keyword
|
168
|
+
if kind = KEYWORD_NEXT_TOKEN_KIND[match]
|
169
|
+
encoder.text_token match, :space if match = scan(/\s+/o)
|
170
|
+
encoder.text_token match, kind if match = scan(/#{IDENTIFIER}/o)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
elsif match = scan(/#{SYMBOL}/o)
|
174
|
+
encoder.text_token match, :symbol
|
175
|
+
elsif match = scan(/\./)
|
176
|
+
encoder.text_token match, :operator
|
177
|
+
elsif match = scan(/ \# \^ #{IDENTIFIER} /ox)
|
178
|
+
encoder.text_token match, :type
|
179
|
+
elsif match = scan(/ (\#)? " /x)
|
180
|
+
state = self[1] ? :regexp : :string
|
181
|
+
encoder.begin_group state
|
182
|
+
encoder.text_token match, :delimiter
|
183
|
+
elsif match = scan(/#{NUM}/o) and not matched.empty?
|
184
|
+
encoder.text_token match, match[/[.e\/]/i] ? :float : :integer
|
185
|
+
else
|
186
|
+
encoder.text_token getch, :error
|
187
|
+
end
|
188
|
+
|
189
|
+
when :string, :regexp
|
190
|
+
if match = scan(/[^"\\]+|\\.?/)
|
191
|
+
encoder.text_token match, :content
|
192
|
+
elsif match = scan(/"/)
|
193
|
+
encoder.text_token match, :delimiter
|
194
|
+
encoder.end_group state
|
195
|
+
state = :initial
|
196
|
+
else
|
197
|
+
raise_inspect "else case \" reached; %p not handled." % peek(1),
|
198
|
+
encoder, state
|
199
|
+
end
|
200
|
+
|
201
|
+
else
|
202
|
+
raise 'else case reached'
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
if [:string, :regexp].include? state
|
209
|
+
encoder.end_group state
|
210
|
+
end
|
211
|
+
|
212
|
+
encoder
|
213
|
+
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Scanners
|
3
|
+
|
4
|
+
# Scanner for C++.
|
5
|
+
#
|
6
|
+
# Aliases: +cplusplus+, c++
|
7
|
+
class CPlusPlus < Scanner
|
8
|
+
|
9
|
+
register_for :cpp
|
10
|
+
file_extension 'cpp'
|
11
|
+
title 'C++'
|
12
|
+
|
13
|
+
#-- http://www.cppreference.com/wiki/keywords/start
|
14
|
+
KEYWORDS = [
|
15
|
+
'and', 'and_eq', 'asm', 'bitand', 'bitor', 'break',
|
16
|
+
'case', 'catch', 'class', 'compl', 'const_cast',
|
17
|
+
'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else',
|
18
|
+
'enum', 'export', 'for', 'goto', 'if', 'namespace', 'new',
|
19
|
+
'not', 'not_eq', 'or', 'or_eq', 'reinterpret_cast', 'return',
|
20
|
+
'sizeof', 'static_assert', 'static_cast', 'struct', 'switch',
|
21
|
+
'template', 'throw', 'try', 'typedef', 'typeid', 'typename', 'union',
|
22
|
+
'while', 'xor', 'xor_eq',
|
23
|
+
] # :nodoc:
|
24
|
+
|
25
|
+
PREDEFINED_TYPES = [
|
26
|
+
'bool', 'char', 'char16_t', 'char32_t', 'double', 'float',
|
27
|
+
'int', 'long', 'short', 'signed', 'unsigned',
|
28
|
+
'wchar_t', 'string',
|
29
|
+
] # :nodoc:
|
30
|
+
PREDEFINED_CONSTANTS = [
|
31
|
+
'false', 'true',
|
32
|
+
'EOF', 'NULL', 'nullptr'
|
33
|
+
] # :nodoc:
|
34
|
+
PREDEFINED_VARIABLES = [
|
35
|
+
'this',
|
36
|
+
] # :nodoc:
|
37
|
+
DIRECTIVES = [
|
38
|
+
'alignas', 'alignof', 'auto', 'const', 'constexpr', 'decltype', 'explicit',
|
39
|
+
'extern', 'final', 'friend', 'inline', 'mutable', 'noexcept', 'operator',
|
40
|
+
'override', 'private', 'protected', 'public', 'register', 'static',
|
41
|
+
'thread_local', 'using', 'virtual', 'void', 'volatile',
|
42
|
+
] # :nodoc:
|
43
|
+
|
44
|
+
IDENT_KIND = WordList.new(:ident).
|
45
|
+
add(KEYWORDS, :keyword).
|
46
|
+
add(PREDEFINED_TYPES, :predefined_type).
|
47
|
+
add(PREDEFINED_VARIABLES, :local_variable).
|
48
|
+
add(DIRECTIVES, :directive).
|
49
|
+
add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc:
|
50
|
+
|
51
|
+
ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc:
|
52
|
+
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
|
53
|
+
|
54
|
+
protected
|
55
|
+
|
56
|
+
def scan_tokens encoder, options
|
57
|
+
|
58
|
+
state = :initial
|
59
|
+
label_expected = true
|
60
|
+
case_expected = false
|
61
|
+
label_expected_before_preproc_line = nil
|
62
|
+
in_preproc_line = false
|
63
|
+
|
64
|
+
until eos?
|
65
|
+
|
66
|
+
case state
|
67
|
+
|
68
|
+
when :initial
|
69
|
+
|
70
|
+
if match = scan(/ \s+ | \\\n /x)
|
71
|
+
if in_preproc_line && match != "\\\n" && match.index(?\n)
|
72
|
+
in_preproc_line = false
|
73
|
+
label_expected = label_expected_before_preproc_line
|
74
|
+
end
|
75
|
+
encoder.text_token match, :space
|
76
|
+
|
77
|
+
elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
|
78
|
+
encoder.text_token match, :comment
|
79
|
+
|
80
|
+
elsif match = scan(/ \# \s* if \s* 0 /x)
|
81
|
+
match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
|
82
|
+
encoder.text_token match, :comment
|
83
|
+
|
84
|
+
elsif match = scan(/ [-+*=<>?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x)
|
85
|
+
label_expected = match =~ /[;\{\}]/
|
86
|
+
if case_expected
|
87
|
+
label_expected = true if match == ':'
|
88
|
+
case_expected = false
|
89
|
+
end
|
90
|
+
encoder.text_token match, :operator
|
91
|
+
|
92
|
+
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
|
93
|
+
kind = IDENT_KIND[match]
|
94
|
+
if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/)
|
95
|
+
kind = :label
|
96
|
+
match << matched
|
97
|
+
else
|
98
|
+
label_expected = false
|
99
|
+
if kind == :keyword
|
100
|
+
case match
|
101
|
+
when 'class'
|
102
|
+
state = :class_name_expected
|
103
|
+
when 'case', 'default'
|
104
|
+
case_expected = true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
encoder.text_token match, kind
|
109
|
+
|
110
|
+
elsif match = scan(/\$/)
|
111
|
+
encoder.text_token match, :ident
|
112
|
+
|
113
|
+
elsif match = scan(/L?"/)
|
114
|
+
encoder.begin_group :string
|
115
|
+
if match[0] == ?L
|
116
|
+
encoder.text_token match, 'L', :modifier
|
117
|
+
match = '"'
|
118
|
+
end
|
119
|
+
state = :string
|
120
|
+
encoder.text_token match, :delimiter
|
121
|
+
|
122
|
+
elsif match = scan(/#[ \t]*(\w*)/)
|
123
|
+
encoder.text_token match, :preprocessor
|
124
|
+
in_preproc_line = true
|
125
|
+
label_expected_before_preproc_line = label_expected
|
126
|
+
state = :include_expected if self[1] == 'include'
|
127
|
+
|
128
|
+
elsif match = scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
|
129
|
+
label_expected = false
|
130
|
+
encoder.text_token match, :char
|
131
|
+
|
132
|
+
elsif match = scan(/0[xX][0-9A-Fa-f]+/)
|
133
|
+
label_expected = false
|
134
|
+
encoder.text_token match, :hex
|
135
|
+
|
136
|
+
elsif match = scan(/(?:0[0-7]+)(?![89.eEfF])/)
|
137
|
+
label_expected = false
|
138
|
+
encoder.text_token match, :octal
|
139
|
+
|
140
|
+
elsif match = scan(/(?:\d+)(?![.eEfF])L?L?/)
|
141
|
+
label_expected = false
|
142
|
+
encoder.text_token match, :integer
|
143
|
+
|
144
|
+
elsif match = scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
|
145
|
+
label_expected = false
|
146
|
+
encoder.text_token match, :float
|
147
|
+
|
148
|
+
else
|
149
|
+
encoder.text_token getch, :error
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
when :string
|
154
|
+
if match = scan(/[^\\"]+/)
|
155
|
+
encoder.text_token match, :content
|
156
|
+
elsif match = scan(/"/)
|
157
|
+
encoder.text_token match, :delimiter
|
158
|
+
encoder.end_group :string
|
159
|
+
state = :initial
|
160
|
+
label_expected = false
|
161
|
+
elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
|
162
|
+
encoder.text_token match, :char
|
163
|
+
elsif match = scan(/ \\ | $ /x)
|
164
|
+
encoder.end_group :string
|
165
|
+
encoder.text_token match, :error unless match.empty?
|
166
|
+
state = :initial
|
167
|
+
label_expected = false
|
168
|
+
else
|
169
|
+
raise_inspect "else case \" reached; %p not handled." % peek(1), encoder
|
170
|
+
end
|
171
|
+
|
172
|
+
when :include_expected
|
173
|
+
if match = scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
|
174
|
+
encoder.text_token match, :include
|
175
|
+
state = :initial
|
176
|
+
|
177
|
+
elsif match = scan(/\s+/)
|
178
|
+
encoder.text_token match, :space
|
179
|
+
state = :initial if match.index ?\n
|
180
|
+
|
181
|
+
else
|
182
|
+
state = :initial
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
when :class_name_expected
|
187
|
+
if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
|
188
|
+
encoder.text_token match, :class
|
189
|
+
state = :initial
|
190
|
+
|
191
|
+
elsif match = scan(/\s+/)
|
192
|
+
encoder.text_token match, :space
|
193
|
+
|
194
|
+
else
|
195
|
+
encoder.text_token getch, :error
|
196
|
+
state = :initial
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
else
|
201
|
+
raise_inspect 'Unknown state', encoder
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
if state == :string
|
208
|
+
encoder.end_group :string
|
209
|
+
end
|
210
|
+
|
211
|
+
encoder
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Scanners
|
3
|
+
|
4
|
+
class CSS < Scanner
|
5
|
+
|
6
|
+
register_for :css
|
7
|
+
|
8
|
+
KINDS_NOT_LOC = [
|
9
|
+
:comment,
|
10
|
+
:class, :pseudo_class, :tag,
|
11
|
+
:id, :directive,
|
12
|
+
:key, :value, :operator, :color, :float, :string,
|
13
|
+
:error, :important, :type,
|
14
|
+
] # :nodoc:
|
15
|
+
|
16
|
+
module RE # :nodoc:
|
17
|
+
Hex = /[0-9a-fA-F]/
|
18
|
+
Unicode = /\\#{Hex}{1,6}\b/ # differs from standard because it allows uppercase hex too
|
19
|
+
Escape = /#{Unicode}|\\[^\n0-9a-fA-F]/
|
20
|
+
NMChar = /[-_a-zA-Z0-9]/
|
21
|
+
NMStart = /[_a-zA-Z]/
|
22
|
+
String1 = /"(?:[^\n\\"]+|\\\n|#{Escape})*"?/ # TODO: buggy regexp
|
23
|
+
String2 = /'(?:[^\n\\']+|\\\n|#{Escape})*'?/ # TODO: buggy regexp
|
24
|
+
String = /#{String1}|#{String2}/
|
25
|
+
|
26
|
+
HexColor = /#(?:#{Hex}{6}|#{Hex}{3})/
|
27
|
+
|
28
|
+
Num = /-?(?:[0-9]*\.[0-9]+|[0-9]+)n?/
|
29
|
+
Name = /#{NMChar}+/
|
30
|
+
Ident = /-?#{NMStart}#{NMChar}*/
|
31
|
+
AtKeyword = /@#{Ident}/
|
32
|
+
Percentage = /#{Num}%/
|
33
|
+
|
34
|
+
reldimensions = %w[em ex px]
|
35
|
+
absdimensions = %w[in cm mm pt pc]
|
36
|
+
Unit = Regexp.union(*(reldimensions + absdimensions + %w[s dpi dppx deg]))
|
37
|
+
|
38
|
+
Dimension = /#{Num}#{Unit}/
|
39
|
+
|
40
|
+
Function = /(?:url|alpha|attr|counters?)\((?:[^)\n]|\\\))*\)?/
|
41
|
+
|
42
|
+
Id = /(?!#{HexColor}\b(?!-))##{Name}/
|
43
|
+
Class = /\.#{Name}/
|
44
|
+
PseudoClass = /::?#{Ident}/
|
45
|
+
AttributeSelector = /\[[^\]]*\]?/
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@state = :initial
|
52
|
+
@value_expected = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def scan_tokens encoder, options
|
56
|
+
states = Array(options[:state] || @state).dup
|
57
|
+
value_expected = @value_expected
|
58
|
+
|
59
|
+
until eos?
|
60
|
+
|
61
|
+
if match = scan(/\s+/)
|
62
|
+
encoder.text_token match, :space
|
63
|
+
|
64
|
+
elsif case states.last
|
65
|
+
when :initial, :media
|
66
|
+
if match = scan(/(?>#{RE::Ident})(?!\()|\*/ox)
|
67
|
+
encoder.text_token match, :tag
|
68
|
+
next
|
69
|
+
elsif match = scan(RE::Class)
|
70
|
+
encoder.text_token match, :class
|
71
|
+
next
|
72
|
+
elsif match = scan(RE::Id)
|
73
|
+
encoder.text_token match, :id
|
74
|
+
next
|
75
|
+
elsif match = scan(RE::PseudoClass)
|
76
|
+
encoder.text_token match, :pseudo_class
|
77
|
+
next
|
78
|
+
elsif match = scan(RE::AttributeSelector)
|
79
|
+
# TODO: Improve highlighting inside of attribute selectors.
|
80
|
+
encoder.text_token match[0,1], :operator
|
81
|
+
encoder.text_token match[1..-2], :attribute_name if match.size > 2
|
82
|
+
encoder.text_token match[-1,1], :operator if match[-1] == ?]
|
83
|
+
next
|
84
|
+
elsif match = scan(/@media/)
|
85
|
+
encoder.text_token match, :directive
|
86
|
+
states.push :media_before_name
|
87
|
+
next
|
88
|
+
end
|
89
|
+
|
90
|
+
when :block
|
91
|
+
if match = scan(/(?>#{RE::Ident})(?!\()/ox)
|
92
|
+
if value_expected
|
93
|
+
encoder.text_token match, :value
|
94
|
+
else
|
95
|
+
encoder.text_token match, :key
|
96
|
+
end
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
100
|
+
when :media_before_name
|
101
|
+
if match = scan(RE::Ident)
|
102
|
+
encoder.text_token match, :type
|
103
|
+
states[-1] = :media_after_name
|
104
|
+
next
|
105
|
+
end
|
106
|
+
|
107
|
+
when :media_after_name
|
108
|
+
if match = scan(/\{/)
|
109
|
+
encoder.text_token match, :operator
|
110
|
+
states[-1] = :media
|
111
|
+
next
|
112
|
+
end
|
113
|
+
|
114
|
+
else
|
115
|
+
#:nocov:
|
116
|
+
raise_inspect 'Unknown state', encoder
|
117
|
+
#:nocov:
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
elsif match = scan(/\/\*(?:.*?\*\/|\z)/m)
|
122
|
+
encoder.text_token match, :comment
|
123
|
+
|
124
|
+
elsif match = scan(/\{/)
|
125
|
+
value_expected = false
|
126
|
+
encoder.text_token match, :operator
|
127
|
+
states.push :block
|
128
|
+
|
129
|
+
elsif match = scan(/\}/)
|
130
|
+
value_expected = false
|
131
|
+
encoder.text_token match, :operator
|
132
|
+
if states.last == :block || states.last == :media
|
133
|
+
states.pop
|
134
|
+
end
|
135
|
+
|
136
|
+
elsif match = scan(/#{RE::String}/o)
|
137
|
+
encoder.begin_group :string
|
138
|
+
encoder.text_token match[0, 1], :delimiter
|
139
|
+
encoder.text_token match[1..-2], :content if match.size > 2
|
140
|
+
encoder.text_token match[-1, 1], :delimiter if match.size >= 2
|
141
|
+
encoder.end_group :string
|
142
|
+
|
143
|
+
elsif match = scan(/#{RE::Function}/o)
|
144
|
+
encoder.begin_group :function
|
145
|
+
start = match[/^\w+\(/]
|
146
|
+
encoder.text_token start, :delimiter
|
147
|
+
if match[-1] == ?)
|
148
|
+
encoder.text_token match[start.size..-2], :content if match.size > start.size + 1
|
149
|
+
encoder.text_token ')', :delimiter
|
150
|
+
else
|
151
|
+
encoder.text_token match[start.size..-1], :content if match.size > start.size
|
152
|
+
end
|
153
|
+
encoder.end_group :function
|
154
|
+
|
155
|
+
elsif match = scan(/(?: #{RE::Dimension} | #{RE::Percentage} | #{RE::Num} )/ox)
|
156
|
+
encoder.text_token match, :float
|
157
|
+
|
158
|
+
elsif match = scan(/#{RE::HexColor}/o)
|
159
|
+
encoder.text_token match, :color
|
160
|
+
|
161
|
+
elsif match = scan(/! *important/)
|
162
|
+
encoder.text_token match, :important
|
163
|
+
|
164
|
+
elsif match = scan(/(?:rgb|hsl)a?\([^()\n]*\)?/)
|
165
|
+
encoder.text_token match, :color
|
166
|
+
|
167
|
+
elsif match = scan(RE::AtKeyword)
|
168
|
+
encoder.text_token match, :directive
|
169
|
+
|
170
|
+
elsif match = scan(/ [+>~:;,.=()\/] /x)
|
171
|
+
if match == ':'
|
172
|
+
value_expected = true
|
173
|
+
elsif match == ';'
|
174
|
+
value_expected = false
|
175
|
+
end
|
176
|
+
encoder.text_token match, :operator
|
177
|
+
|
178
|
+
else
|
179
|
+
encoder.text_token getch, :error
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
if options[:keep_state]
|
186
|
+
@state = states
|
187
|
+
@value_expected = value_expected
|
188
|
+
end
|
189
|
+
|
190
|
+
encoder
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|