llm-shell 0.10.0 → 0.11.0
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 +4 -4
- data/LICENSE +21 -0
- data/README.md +24 -160
- data/exe/llm-shell +7 -0
- data/llm-shell.gemspec +26 -32
- metadata +36 -372
- data/bin/llm-shell +0 -21
- data/lib/llm/shell/command.rb +0 -88
- data/lib/llm/shell/commands/clear_screen.rb +0 -18
- data/lib/llm/shell/commands/debug_mode.rb +0 -12
- data/lib/llm/shell/commands/dir_import.rb +0 -33
- data/lib/llm/shell/commands/disable_tool.rb +0 -33
- data/lib/llm/shell/commands/enable_tool.rb +0 -33
- data/lib/llm/shell/commands/file_import.rb +0 -25
- data/lib/llm/shell/commands/help.rb +0 -53
- data/lib/llm/shell/commands/show_chat.rb +0 -31
- data/lib/llm/shell/commands/show_version.rb +0 -17
- data/lib/llm/shell/commands/system_prompt.rb +0 -21
- data/lib/llm/shell/completion.rb +0 -40
- data/lib/llm/shell/config.rb +0 -34
- data/lib/llm/shell/default.rb +0 -23
- data/lib/llm/shell/formatter.rb +0 -41
- data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +0 -25
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +0 -39
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +0 -49
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +0 -63
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +0 -190
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +0 -58
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +0 -65
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +0 -108
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +0 -333
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +0 -83
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +0 -45
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +0 -59
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +0 -195
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +0 -46
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +0 -111
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +0 -50
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +0 -151
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +0 -189
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +0 -196
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +0 -144
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +0 -208
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +0 -268
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +0 -168
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +0 -275
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +0 -421
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +0 -174
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +0 -236
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +0 -98
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +0 -280
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +0 -527
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +0 -287
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +0 -178
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +0 -79
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +0 -477
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +0 -232
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +0 -337
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +0 -169
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +0 -36
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +0 -26
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +0 -140
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +0 -27
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +0 -7
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +0 -153
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +0 -15
- data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +0 -85
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +0 -3
- data/lib/llm/shell/internal/coderay/lib/coderay.rb +0 -284
- data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +0 -19
- data/lib/llm/shell/internal/io-line/lib/io/line.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +0 -37
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +0 -150
- data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +0 -162
- data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +0 -177
- data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +0 -178
- data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +0 -140
- data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +0 -101
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +0 -38
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +0 -53
- data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +0 -89
- data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +0 -352
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +0 -155
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +0 -66
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +0 -138
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +0 -68
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +0 -27
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +0 -73
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +0 -47
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +0 -146
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +0 -133
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +0 -60
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +0 -22
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +0 -173
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +0 -77
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +0 -56
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +0 -116
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +0 -46
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +0 -134
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +0 -90
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +0 -109
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +0 -55
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +0 -65
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +0 -40
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +0 -16
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +0 -48
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +0 -76
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +0 -99
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +0 -228
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +0 -206
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +0 -58
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +0 -67
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +0 -26
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +0 -41
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +0 -81
- data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +0 -32
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +0 -19
- data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +0 -5
- data/lib/llm/shell/internal/llm.rb/lib/llm.rb +0 -121
- data/lib/llm/shell/internal/optparse/lib/optionparser.rb +0 -2
- data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +0 -70
- data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +0 -18
- data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +0 -27
- data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +0 -11
- data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +0 -80
- data/lib/llm/shell/internal/optparse/lib/optparse.rb +0 -2469
- data/lib/llm/shell/internal/paint/lib/paint/constants.rb +0 -104
- data/lib/llm/shell/internal/paint/lib/paint/pa.rb +0 -13
- data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +0 -14
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +0 -100
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint/util.rb +0 -16
- data/lib/llm/shell/internal/paint/lib/paint/version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint.rb +0 -261
- data/lib/llm/shell/internal/reline/lib/reline/config.rb +0 -378
- data/lib/llm/shell/internal/reline/lib/reline/face.rb +0 -199
- data/lib/llm/shell/internal/reline/lib/reline/history.rb +0 -76
- data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +0 -322
- data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +0 -120
- data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +0 -530
- data/lib/llm/shell/internal/reline/lib/reline/io.rb +0 -55
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +0 -37
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +0 -17
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +0 -518
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +0 -8
- data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +0 -119
- data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +0 -125
- data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +0 -2356
- data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +0 -1292
- data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +0 -421
- data/lib/llm/shell/internal/reline/lib/reline/version.rb +0 -3
- data/lib/llm/shell/internal/reline/lib/reline.rb +0 -527
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +0 -712
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +0 -268
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +0 -35
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +0 -42
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +0 -21
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +0 -92
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +0 -5
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +0 -49
- data/lib/llm/shell/markdown.rb +0 -83
- data/lib/llm/shell/options.rb +0 -39
- data/lib/llm/shell/renderer.rb +0 -51
- data/lib/llm/shell/repl.rb +0 -111
- data/lib/llm/shell/tool.rb +0 -42
- data/lib/llm/shell/tools/read_file.rb +0 -15
- data/lib/llm/shell/tools/system.rb +0 -17
- data/lib/llm/shell/tools/write_file.rb +0 -16
- data/lib/llm/shell/version.rb +0 -8
- data/lib/llm/shell.rb +0 -132
- data/lib/llm-shell.rb +0 -3
- data/libexec/llm-shell/shell +0 -43
- data/share/llm-shell/prompts/default.txt +0 -21
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
require 'set'
|
|
2
|
-
|
|
3
|
-
module CodeRay
|
|
4
|
-
module Scanners
|
|
5
|
-
|
|
6
|
-
# = Debug Scanner
|
|
7
|
-
#
|
|
8
|
-
# Interprets the output of the Encoders::Debug encoder (basically the inverse function).
|
|
9
|
-
class Debug < Scanner
|
|
10
|
-
|
|
11
|
-
register_for :debug
|
|
12
|
-
title 'CodeRay Token Dump Import'
|
|
13
|
-
|
|
14
|
-
protected
|
|
15
|
-
|
|
16
|
-
def setup
|
|
17
|
-
super
|
|
18
|
-
@known_token_kinds = TokenKinds.keys.map(&:to_s).to_set
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def scan_tokens encoder, options
|
|
22
|
-
|
|
23
|
-
opened_tokens = []
|
|
24
|
-
|
|
25
|
-
until eos?
|
|
26
|
-
|
|
27
|
-
if match = scan(/\s+/)
|
|
28
|
-
encoder.text_token match, :space
|
|
29
|
-
|
|
30
|
-
elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /x)
|
|
31
|
-
if @known_token_kinds.include? self[1]
|
|
32
|
-
encoder.text_token self[2].gsub(/\\(.)/m, '\1'), self[1].to_sym
|
|
33
|
-
else
|
|
34
|
-
encoder.text_token matched, :unknown
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
elsif match = scan(/ (\w+) ([<\[]) /x)
|
|
38
|
-
if @known_token_kinds.include? self[1]
|
|
39
|
-
kind = self[1].to_sym
|
|
40
|
-
else
|
|
41
|
-
kind = :unknown
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
opened_tokens << kind
|
|
45
|
-
case self[2]
|
|
46
|
-
when '<'
|
|
47
|
-
encoder.begin_group kind
|
|
48
|
-
when '['
|
|
49
|
-
encoder.begin_line kind
|
|
50
|
-
else
|
|
51
|
-
raise 'CodeRay bug: This case should not be reached.'
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
elsif !opened_tokens.empty? && match = scan(/ > /x)
|
|
55
|
-
encoder.end_group opened_tokens.pop
|
|
56
|
-
|
|
57
|
-
elsif !opened_tokens.empty? && match = scan(/ \] /x)
|
|
58
|
-
encoder.end_line opened_tokens.pop
|
|
59
|
-
|
|
60
|
-
else
|
|
61
|
-
encoder.text_token getch, :space
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
encoder.end_group opened_tokens.pop until opened_tokens.empty?
|
|
68
|
-
|
|
69
|
-
encoder
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
end
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Scanners
|
|
3
|
-
|
|
4
|
-
# Scanner for the Delphi language (Object Pascal).
|
|
5
|
-
#
|
|
6
|
-
# Alias: +pascal+
|
|
7
|
-
class Delphi < Scanner
|
|
8
|
-
|
|
9
|
-
register_for :delphi
|
|
10
|
-
file_extension 'pas'
|
|
11
|
-
|
|
12
|
-
KEYWORDS = [
|
|
13
|
-
'and', 'array', 'as', 'at', 'asm', 'at', 'begin', 'case', 'class',
|
|
14
|
-
'const', 'constructor', 'destructor', 'dispinterface', 'div', 'do',
|
|
15
|
-
'downto', 'else', 'end', 'except', 'exports', 'file', 'finalization',
|
|
16
|
-
'finally', 'for', 'function', 'goto', 'if', 'implementation', 'in',
|
|
17
|
-
'inherited', 'initialization', 'inline', 'interface', 'is', 'label',
|
|
18
|
-
'library', 'mod', 'nil', 'not', 'object', 'of', 'or', 'out', 'packed',
|
|
19
|
-
'procedure', 'program', 'property', 'raise', 'record', 'repeat',
|
|
20
|
-
'resourcestring', 'set', 'shl', 'shr', 'string', 'then', 'threadvar',
|
|
21
|
-
'to', 'try', 'type', 'unit', 'until', 'uses', 'var', 'while', 'with',
|
|
22
|
-
'xor', 'on',
|
|
23
|
-
] # :nodoc:
|
|
24
|
-
|
|
25
|
-
DIRECTIVES = [
|
|
26
|
-
'absolute', 'abstract', 'assembler', 'at', 'automated', 'cdecl',
|
|
27
|
-
'contains', 'deprecated', 'dispid', 'dynamic', 'export',
|
|
28
|
-
'external', 'far', 'forward', 'implements', 'local',
|
|
29
|
-
'near', 'nodefault', 'on', 'overload', 'override',
|
|
30
|
-
'package', 'pascal', 'platform', 'private', 'protected', 'public',
|
|
31
|
-
'published', 'read', 'readonly', 'register', 'reintroduce',
|
|
32
|
-
'requires', 'resident', 'safecall', 'stdcall', 'stored', 'varargs',
|
|
33
|
-
'virtual', 'write', 'writeonly',
|
|
34
|
-
] # :nodoc:
|
|
35
|
-
|
|
36
|
-
IDENT_KIND = WordList::CaseIgnoring.new(:ident).
|
|
37
|
-
add(KEYWORDS, :keyword).
|
|
38
|
-
add(DIRECTIVES, :directive) # :nodoc:
|
|
39
|
-
|
|
40
|
-
NAME_FOLLOWS = WordList::CaseIgnoring.new(false).
|
|
41
|
-
add(%w(procedure function .)) # :nodoc:
|
|
42
|
-
|
|
43
|
-
protected
|
|
44
|
-
|
|
45
|
-
def scan_tokens encoder, options
|
|
46
|
-
|
|
47
|
-
state = :initial
|
|
48
|
-
last_token = ''
|
|
49
|
-
|
|
50
|
-
until eos?
|
|
51
|
-
|
|
52
|
-
if state == :initial
|
|
53
|
-
|
|
54
|
-
if match = scan(/ \s+ /x)
|
|
55
|
-
encoder.text_token match, :space
|
|
56
|
-
next
|
|
57
|
-
|
|
58
|
-
elsif match = scan(%r! \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !mx)
|
|
59
|
-
encoder.text_token match, :preprocessor
|
|
60
|
-
next
|
|
61
|
-
|
|
62
|
-
elsif match = scan(%r! // [^\n]* | \{ [^}]* \}? | \(\* (?: .*? \*\) | .* ) !mx)
|
|
63
|
-
encoder.text_token match, :comment
|
|
64
|
-
next
|
|
65
|
-
|
|
66
|
-
elsif match = scan(/ <[>=]? | >=? | :=? | [-+=*\/;,@\^|\(\)\[\]] | \.\. /x)
|
|
67
|
-
encoder.text_token match, :operator
|
|
68
|
-
|
|
69
|
-
elsif match = scan(/\./)
|
|
70
|
-
encoder.text_token match, :operator
|
|
71
|
-
next if last_token == 'end'
|
|
72
|
-
|
|
73
|
-
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
|
|
74
|
-
encoder.text_token match, NAME_FOLLOWS[last_token] ? :ident : IDENT_KIND[match]
|
|
75
|
-
|
|
76
|
-
elsif match = skip(/ ' ( [^\n']|'' ) (?:'|$) /x)
|
|
77
|
-
encoder.begin_group :char
|
|
78
|
-
encoder.text_token "'", :delimiter
|
|
79
|
-
encoder.text_token self[1], :content
|
|
80
|
-
encoder.text_token "'", :delimiter
|
|
81
|
-
encoder.end_group :char
|
|
82
|
-
next
|
|
83
|
-
|
|
84
|
-
elsif match = scan(/ ' /x)
|
|
85
|
-
encoder.begin_group :string
|
|
86
|
-
encoder.text_token match, :delimiter
|
|
87
|
-
state = :string
|
|
88
|
-
|
|
89
|
-
elsif match = scan(/ \# (?: \d+ | \$[0-9A-Fa-f]+ ) /x)
|
|
90
|
-
encoder.text_token match, :char
|
|
91
|
-
|
|
92
|
-
elsif match = scan(/ \$ [0-9A-Fa-f]+ /x)
|
|
93
|
-
encoder.text_token match, :hex
|
|
94
|
-
|
|
95
|
-
elsif match = scan(/ (?: \d+ ) (?![eE]|\.[^.]) /x)
|
|
96
|
-
encoder.text_token match, :integer
|
|
97
|
-
|
|
98
|
-
elsif match = scan(/ \d+ (?: \.\d+ (?: [eE][+-]? \d+ )? | [eE][+-]? \d+ ) /x)
|
|
99
|
-
encoder.text_token match, :float
|
|
100
|
-
|
|
101
|
-
else
|
|
102
|
-
encoder.text_token getch, :error
|
|
103
|
-
next
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
elsif state == :string
|
|
108
|
-
if match = scan(/[^\n']+/)
|
|
109
|
-
encoder.text_token match, :content
|
|
110
|
-
elsif match = scan(/''/)
|
|
111
|
-
encoder.text_token match, :char
|
|
112
|
-
elsif match = scan(/'/)
|
|
113
|
-
encoder.text_token match, :delimiter
|
|
114
|
-
encoder.end_group :string
|
|
115
|
-
state = :initial
|
|
116
|
-
next
|
|
117
|
-
elsif match = scan(/\n/)
|
|
118
|
-
encoder.end_group :string
|
|
119
|
-
encoder.text_token match, :space
|
|
120
|
-
state = :initial
|
|
121
|
-
else
|
|
122
|
-
raise "else case \' reached; %p not handled." % peek(1), encoder
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
else
|
|
126
|
-
raise 'else-case reached', encoder
|
|
127
|
-
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
last_token = match
|
|
131
|
-
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
if state == :string
|
|
135
|
-
encoder.end_group state
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
encoder
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
end
|
|
144
|
-
end
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Scanners
|
|
3
|
-
|
|
4
|
-
# Scanner for output of the diff command.
|
|
5
|
-
#
|
|
6
|
-
# Alias: +patch+
|
|
7
|
-
class Diff < Scanner
|
|
8
|
-
|
|
9
|
-
register_for :diff
|
|
10
|
-
title 'diff output'
|
|
11
|
-
|
|
12
|
-
DEFAULT_OPTIONS = {
|
|
13
|
-
:highlight_code => true,
|
|
14
|
-
:inline_diff => true,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
def scan_tokens encoder, options
|
|
20
|
-
|
|
21
|
-
line_kind = nil
|
|
22
|
-
state = :initial
|
|
23
|
-
deleted_lines_count = 0
|
|
24
|
-
scanners = Hash.new do |h, lang|
|
|
25
|
-
h[lang] = Scanners[lang].new '', :keep_tokens => true, :keep_state => true
|
|
26
|
-
end
|
|
27
|
-
content_scanner = scanners[:plain]
|
|
28
|
-
content_scanner_entry_state = nil
|
|
29
|
-
|
|
30
|
-
until eos?
|
|
31
|
-
|
|
32
|
-
if match = scan(/\n/)
|
|
33
|
-
deleted_lines_count = 0 unless line_kind == :delete
|
|
34
|
-
if line_kind
|
|
35
|
-
encoder.end_line line_kind
|
|
36
|
-
line_kind = nil
|
|
37
|
-
end
|
|
38
|
-
encoder.text_token match, :space
|
|
39
|
-
next
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
case state
|
|
43
|
-
|
|
44
|
-
when :initial
|
|
45
|
-
if match = scan(/--- |\+\+\+ |=+|_+/)
|
|
46
|
-
encoder.begin_line line_kind = :head
|
|
47
|
-
encoder.text_token match, :head
|
|
48
|
-
if match = scan(/[^\x00\n]+?(?=$|[\t\n]| \(revision)/)
|
|
49
|
-
encoder.text_token match, :filename
|
|
50
|
-
if options[:highlight_code] && match != '/dev/null'
|
|
51
|
-
file_type = CodeRay::FileType.fetch(match, :text)
|
|
52
|
-
file_type = :text if file_type == :diff
|
|
53
|
-
content_scanner = scanners[file_type]
|
|
54
|
-
content_scanner_entry_state = nil
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
next unless match = scan(/.+/)
|
|
58
|
-
encoder.text_token match, :plain
|
|
59
|
-
elsif match = scan(/Index: |Property changes on: /)
|
|
60
|
-
encoder.begin_line line_kind = :head
|
|
61
|
-
encoder.text_token match, :head
|
|
62
|
-
next unless match = scan(/.+/)
|
|
63
|
-
encoder.text_token match, :plain
|
|
64
|
-
elsif match = scan(/Added: /)
|
|
65
|
-
encoder.begin_line line_kind = :head
|
|
66
|
-
encoder.text_token match, :head
|
|
67
|
-
next unless match = scan(/.+/)
|
|
68
|
-
encoder.text_token match, :plain
|
|
69
|
-
state = :added
|
|
70
|
-
elsif match = scan(/\\ .*/)
|
|
71
|
-
encoder.text_token match, :comment
|
|
72
|
-
elsif match = scan(/@@(?>[^@\n]+)@@/)
|
|
73
|
-
content_scanner.state = :initial unless match?(/\n\+/)
|
|
74
|
-
content_scanner_entry_state = nil
|
|
75
|
-
if check(/\n|$/)
|
|
76
|
-
encoder.begin_line line_kind = :change
|
|
77
|
-
else
|
|
78
|
-
encoder.begin_group :change
|
|
79
|
-
end
|
|
80
|
-
encoder.text_token match[0,2], :change
|
|
81
|
-
encoder.text_token match[2...-2], :plain
|
|
82
|
-
encoder.text_token match[-2,2], :change
|
|
83
|
-
encoder.end_group :change unless line_kind
|
|
84
|
-
next unless match = scan(/.+/)
|
|
85
|
-
if options[:highlight_code]
|
|
86
|
-
content_scanner.tokenize match, :tokens => encoder
|
|
87
|
-
else
|
|
88
|
-
encoder.text_token match, :plain
|
|
89
|
-
end
|
|
90
|
-
next
|
|
91
|
-
elsif match = scan(/\+/)
|
|
92
|
-
encoder.begin_line line_kind = :insert
|
|
93
|
-
encoder.text_token match, :insert
|
|
94
|
-
next unless match = scan(/.+/)
|
|
95
|
-
if options[:highlight_code]
|
|
96
|
-
content_scanner.tokenize match, :tokens => encoder
|
|
97
|
-
else
|
|
98
|
-
encoder.text_token match, :plain
|
|
99
|
-
end
|
|
100
|
-
next
|
|
101
|
-
elsif match = scan(/-/)
|
|
102
|
-
deleted_lines_count += 1
|
|
103
|
-
if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/.*(?:\n\-.*)*/).count("\n")) && changed_lines_count <= 100_000 && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/)
|
|
104
|
-
deleted_lines = Array.new(changed_lines_count) { |i| skip(/\n\-/) if i > 0; scan(/.*/) }
|
|
105
|
-
inserted_lines = Array.new(changed_lines_count) { |i| skip(/\n\+/) ; scan(/.*/) }
|
|
106
|
-
|
|
107
|
-
deleted_lines_tokenized = []
|
|
108
|
-
inserted_lines_tokenized = []
|
|
109
|
-
for deleted_line, inserted_line in deleted_lines.zip(inserted_lines)
|
|
110
|
-
pre, deleted_part, inserted_part, post = diff deleted_line, inserted_line
|
|
111
|
-
content_scanner_entry_state = content_scanner.state
|
|
112
|
-
deleted_lines_tokenized << content_scanner.tokenize([pre, deleted_part, post], :tokens => Tokens.new)
|
|
113
|
-
content_scanner.state = content_scanner_entry_state || :initial
|
|
114
|
-
inserted_lines_tokenized << content_scanner.tokenize([pre, inserted_part, post], :tokens => Tokens.new)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
for pre, deleted_part, post in deleted_lines_tokenized
|
|
118
|
-
encoder.begin_line :delete
|
|
119
|
-
encoder.text_token '-', :delete
|
|
120
|
-
encoder.tokens pre
|
|
121
|
-
unless deleted_part.empty?
|
|
122
|
-
encoder.begin_group :eyecatcher
|
|
123
|
-
encoder.tokens deleted_part
|
|
124
|
-
encoder.end_group :eyecatcher
|
|
125
|
-
end
|
|
126
|
-
encoder.tokens post
|
|
127
|
-
encoder.end_line :delete
|
|
128
|
-
encoder.text_token "\n", :space
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
for pre, inserted_part, post in inserted_lines_tokenized
|
|
132
|
-
encoder.begin_line :insert
|
|
133
|
-
encoder.text_token '+', :insert
|
|
134
|
-
encoder.tokens pre
|
|
135
|
-
unless inserted_part.empty?
|
|
136
|
-
encoder.begin_group :eyecatcher
|
|
137
|
-
encoder.tokens inserted_part
|
|
138
|
-
encoder.end_group :eyecatcher
|
|
139
|
-
end
|
|
140
|
-
encoder.tokens post
|
|
141
|
-
changed_lines_count -= 1
|
|
142
|
-
if changed_lines_count > 0
|
|
143
|
-
encoder.end_line :insert
|
|
144
|
-
encoder.text_token "\n", :space
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
line_kind = :insert
|
|
149
|
-
|
|
150
|
-
elsif match = scan(/.*/)
|
|
151
|
-
encoder.begin_line line_kind = :delete
|
|
152
|
-
encoder.text_token '-', :delete
|
|
153
|
-
if options[:highlight_code]
|
|
154
|
-
if deleted_lines_count == 1
|
|
155
|
-
content_scanner_entry_state = content_scanner.state
|
|
156
|
-
end
|
|
157
|
-
content_scanner.tokenize match, :tokens => encoder unless match.empty?
|
|
158
|
-
if !match?(/\n-/)
|
|
159
|
-
if match?(/\n\+/)
|
|
160
|
-
content_scanner.state = content_scanner_entry_state || :initial
|
|
161
|
-
end
|
|
162
|
-
content_scanner_entry_state = nil
|
|
163
|
-
end
|
|
164
|
-
else
|
|
165
|
-
encoder.text_token match, :plain
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
next
|
|
169
|
-
elsif match = scan(/ .*/)
|
|
170
|
-
if options[:highlight_code]
|
|
171
|
-
content_scanner.tokenize match, :tokens => encoder
|
|
172
|
-
else
|
|
173
|
-
encoder.text_token match, :plain
|
|
174
|
-
end
|
|
175
|
-
next
|
|
176
|
-
elsif match = scan(/.+/)
|
|
177
|
-
encoder.begin_line line_kind = :comment
|
|
178
|
-
encoder.text_token match, :plain
|
|
179
|
-
else
|
|
180
|
-
raise_inspect 'else case rached'
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
when :added
|
|
184
|
-
if match = scan(/ \+/)
|
|
185
|
-
encoder.begin_line line_kind = :insert
|
|
186
|
-
encoder.text_token match, :insert
|
|
187
|
-
next unless match = scan(/.+/)
|
|
188
|
-
encoder.text_token match, :plain
|
|
189
|
-
else
|
|
190
|
-
state = :initial
|
|
191
|
-
next
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
encoder.end_line line_kind if line_kind
|
|
198
|
-
|
|
199
|
-
encoder
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
private
|
|
203
|
-
|
|
204
|
-
def diff a, b
|
|
205
|
-
# i will be the index of the leftmost difference from the left.
|
|
206
|
-
i_max = [a.size, b.size].min
|
|
207
|
-
i = 0
|
|
208
|
-
i += 1 while i < i_max && a[i] == b[i]
|
|
209
|
-
# j_min will be the index of the leftmost difference from the right.
|
|
210
|
-
j_min = i - i_max
|
|
211
|
-
# j will be the index of the rightmost difference from the right which
|
|
212
|
-
# does not precede the leftmost one from the left.
|
|
213
|
-
j = -1
|
|
214
|
-
j -= 1 while j >= j_min && a[j] == b[j]
|
|
215
|
-
return a[0...i], a[i..j], b[i..j], (j < -1) ? a[j + 1..-1] : ''
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
end
|
|
221
|
-
end
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Scanners
|
|
3
|
-
|
|
4
|
-
load :html
|
|
5
|
-
load :ruby
|
|
6
|
-
|
|
7
|
-
# Scanner for HTML ERB templates.
|
|
8
|
-
class ERB < Scanner
|
|
9
|
-
|
|
10
|
-
register_for :erb
|
|
11
|
-
title 'HTML ERB Template'
|
|
12
|
-
|
|
13
|
-
KINDS_NOT_LOC = HTML::KINDS_NOT_LOC
|
|
14
|
-
|
|
15
|
-
ERB_RUBY_BLOCK = /
|
|
16
|
-
(<%(?!%)[-=\#]?)
|
|
17
|
-
((?>
|
|
18
|
-
[^\-%]* # normal*
|
|
19
|
-
(?> # special
|
|
20
|
-
(?: %(?!>) | -(?!%>) )
|
|
21
|
-
[^\-%]* # normal*
|
|
22
|
-
)*
|
|
23
|
-
))
|
|
24
|
-
((?: -?%> )?)
|
|
25
|
-
/x # :nodoc:
|
|
26
|
-
|
|
27
|
-
START_OF_ERB = /
|
|
28
|
-
<%(?!%)
|
|
29
|
-
/x # :nodoc:
|
|
30
|
-
|
|
31
|
-
protected
|
|
32
|
-
|
|
33
|
-
def setup
|
|
34
|
-
@ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true
|
|
35
|
-
@html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def reset_instance
|
|
39
|
-
super
|
|
40
|
-
@html_scanner.reset
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def scan_tokens encoder, options
|
|
44
|
-
|
|
45
|
-
until eos?
|
|
46
|
-
|
|
47
|
-
if (match = scan_until(/(?=#{START_OF_ERB})/o) || scan_rest) and not match.empty?
|
|
48
|
-
@html_scanner.tokenize match, :tokens => encoder
|
|
49
|
-
|
|
50
|
-
elsif match = scan(/#{ERB_RUBY_BLOCK}/o)
|
|
51
|
-
start_tag = self[1]
|
|
52
|
-
code = self[2]
|
|
53
|
-
end_tag = self[3]
|
|
54
|
-
|
|
55
|
-
encoder.begin_group :inline
|
|
56
|
-
encoder.text_token start_tag, :inline_delimiter
|
|
57
|
-
|
|
58
|
-
if start_tag == '<%#'
|
|
59
|
-
encoder.text_token code, :comment
|
|
60
|
-
else
|
|
61
|
-
@ruby_scanner.tokenize code, :tokens => encoder
|
|
62
|
-
end unless code.empty?
|
|
63
|
-
|
|
64
|
-
encoder.text_token end_tag, :inline_delimiter unless end_tag.empty?
|
|
65
|
-
encoder.end_group :inline
|
|
66
|
-
|
|
67
|
-
else
|
|
68
|
-
raise_inspect 'else-case reached!', encoder
|
|
69
|
-
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
encoder
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
end
|