demotape 0.0.2 → 0.0.3
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/.rubocop.yml +6 -0
- data/CHANGELOG.md +9 -0
- data/Makefile +4 -2
- data/README.md +101 -10
- data/demotape.gemspec +1 -1
- data/demotape.y +224 -505
- data/demotape_new.y.backup +160 -0
- data/demotape_simple_test.y +32 -0
- data/editors/sublime-text/DemoTape.sublime-completions +4 -0
- data/editors/sublime-text/DemoTape.sublime-syntax +24 -2
- data/editors/vim/syntax/demotape.vim +16 -2
- data/editors/vscode/demotape.tmLanguage.json +31 -3
- data/lib/demo_tape/cli.rb +36 -0
- data/lib/demo_tape/command.rb +63 -103
- data/lib/demo_tape/exporter.rb +3 -0
- data/lib/demo_tape/formatter.rb +142 -0
- data/lib/demo_tape/lexer.rb +118 -34
- data/lib/demo_tape/parser/helpers.rb +363 -0
- data/lib/demo_tape/parser/rules.rb +396 -0
- data/lib/demo_tape/parser.rb +381 -592
- data/lib/demo_tape/runner.rb +82 -27
- data/lib/demo_tape/token.rb +86 -0
- data/lib/demo_tape/version.rb +1 -1
- data/lib/demo_tape.rb +5 -2
- metadata +10 -527
- data/examples/alt.mp4 +0 -0
- data/examples/alt.png +0 -0
- data/examples/alt.tape +0 -9
- data/examples/arrow.mp4 +0 -0
- data/examples/arrow.png +0 -0
- data/examples/arrow.tape +0 -7
- data/examples/backspace.mp4 +0 -0
- data/examples/backspace.png +0 -0
- data/examples/backspace.tape +0 -4
- data/examples/bash.mp4 +0 -0
- data/examples/bash.png +0 -0
- data/examples/bash.tape +0 -4
- data/examples/bg.jpg +0 -0
- data/examples/clear.mp4 +0 -0
- data/examples/clear.png +0 -0
- data/examples/clear.tape +0 -6
- data/examples/cli_ui_interactive_prompt.mp4 +0 -0
- data/examples/cli_ui_interactive_prompt.png +0 -0
- data/examples/cli_ui_interactive_prompt.tape +0 -16
- data/examples/cli_ui_nested_frames.mp4 +0 -0
- data/examples/cli_ui_nested_frames.png +0 -0
- data/examples/cli_ui_nested_frames.tape +0 -15
- data/examples/cli_ui_progress.mp4 +0 -0
- data/examples/cli_ui_progress.png +0 -0
- data/examples/cli_ui_progress.tape +0 -6
- data/examples/cli_ui_spinner.mp4 +0 -0
- data/examples/cli_ui_spinner.png +0 -0
- data/examples/cli_ui_spinner.tape +0 -6
- data/examples/cli_ui_status_widget.mp4 +0 -0
- data/examples/cli_ui_status_widget.png +0 -0
- data/examples/cli_ui_status_widget.tape +0 -6
- data/examples/cli_ui_symbols.mp4 +0 -0
- data/examples/cli_ui_symbols.png +0 -0
- data/examples/cli_ui_symbols.tape +0 -6
- data/examples/cli_ui_text_prompt.mp4 +0 -0
- data/examples/cli_ui_text_prompt.png +0 -0
- data/examples/cli_ui_text_prompt.tape +0 -10
- data/examples/clipboard.mp4 +0 -0
- data/examples/clipboard.png +0 -0
- data/examples/clipboard.tape +0 -5
- data/examples/ctrl.mp4 +0 -0
- data/examples/ctrl.png +0 -0
- data/examples/ctrl.tape +0 -5
- data/examples/ctrl_arrows.mp4 +0 -0
- data/examples/ctrl_arrows.png +0 -0
- data/examples/ctrl_arrows.tape +0 -14
- data/examples/demotape.mp4 +0 -0
- data/examples/demotape.png +0 -0
- data/examples/demotape.tape +0 -6
- data/examples/demotape.txt +0 -13
- data/examples/enter.mp4 +0 -0
- data/examples/enter.png +0 -0
- data/examples/enter.tape +0 -3
- data/examples/errors/include_itself.tape +0 -1
- data/examples/fastfetch.gif +0 -0
- data/examples/fastfetch.mp4 +0 -0
- data/examples/fastfetch.png +0 -0
- data/examples/fastfetch.tape +0 -11
- data/examples/fish.mp4 +0 -0
- data/examples/fish.png +0 -0
- data/examples/fish.tape +0 -4
- data/examples/format.mp4 +0 -0
- data/examples/format.png +0 -0
- data/examples/format.tape +0 -15
- data/examples/gh-cli.mp4 +0 -0
- data/examples/gh-cli.png +0 -0
- data/examples/gh-cli.tape +0 -13
- data/examples/gif_loop.gif +0 -0
- data/examples/gif_loop.png +0 -0
- data/examples/gif_loop.tape +0 -5
- data/examples/include.mp4 +0 -0
- data/examples/include.png +0 -0
- data/examples/include.tape +0 -1
- data/examples/include_with_set.mp4 +0 -0
- data/examples/include_with_set.png +0 -0
- data/examples/include_with_set.tape +0 -2
- data/examples/meta/cli.tape +0 -10
- data/examples/nerdfonts.mp4 +0 -0
- data/examples/nerdfonts.png +0 -0
- data/examples/nerdfonts.tape +0 -9
- data/examples/output.avi +0 -0
- data/examples/output.gif +0 -0
- data/examples/output.mov +0 -0
- data/examples/output.mp4 +0 -0
- data/examples/output.png +0 -0
- data/examples/output.tape +0 -9
- data/examples/output.webm +0 -0
- data/examples/products.json +0 -1803
- data/examples/screenshot.mp4 +0 -0
- data/examples/screenshot.png +0 -0
- data/examples/screenshot.tape +0 -9
- data/examples/script.rb +0 -3
- data/examples/set_cursor_bar.mp4 +0 -0
- data/examples/set_cursor_bar.png +0 -0
- data/examples/set_cursor_bar.tape +0 -5
- data/examples/set_cursor_blink.mp4 +0 -0
- data/examples/set_cursor_blink.png +0 -0
- data/examples/set_cursor_blink.tape +0 -4
- data/examples/set_cursor_underline.mp4 +0 -0
- data/examples/set_cursor_underline.png +0 -0
- data/examples/set_cursor_underline.tape +0 -5
- data/examples/set_dimensions.mp4 +0 -0
- data/examples/set_dimensions.png +0 -0
- data/examples/set_dimensions.tape +0 -5
- data/examples/set_font_family.mp4 +0 -0
- data/examples/set_font_family.png +0 -0
- data/examples/set_font_family.tape +0 -4
- data/examples/set_font_size.mp4 +0 -0
- data/examples/set_font_size.png +0 -0
- data/examples/set_font_size.tape +0 -4
- data/examples/set_line_height.mp4 +0 -0
- data/examples/set_line_height.png +0 -0
- data/examples/set_line_height.tape +0 -8
- data/examples/set_margin.mp4 +0 -0
- data/examples/set_margin.png +0 -0
- data/examples/set_margin.tape +0 -7
- data/examples/set_margin_with_border_radius.mp4 +0 -0
- data/examples/set_margin_with_border_radius.png +0 -0
- data/examples/set_margin_with_border_radius.tape +0 -8
- data/examples/set_margin_with_image.mp4 +0 -0
- data/examples/set_margin_with_image.png +0 -0
- data/examples/set_margin_with_image.tape +0 -7
- data/examples/set_padding.mp4 +0 -0
- data/examples/set_padding.png +0 -0
- data/examples/set_padding.tape +0 -7
- data/examples/set_theme.mp4 +0 -0
- data/examples/set_theme.png +0 -0
- data/examples/set_theme.tape +0 -9
- data/examples/set_theme_property.mp4 +0 -0
- data/examples/set_theme_property.png +0 -0
- data/examples/set_theme_property.tape +0 -10
- data/examples/set_typing_speed.mp4 +0 -0
- data/examples/set_typing_speed.png +0 -0
- data/examples/set_typing_speed.tape +0 -6
- data/examples/slides.mp4 +0 -0
- data/examples/slides.png +0 -0
- data/examples/slides.tape +0 -14
- data/examples/space.mp4 +0 -0
- data/examples/space.png +0 -0
- data/examples/space.tape +0 -3
- data/examples/stdin.mp4 +0 -0
- data/examples/stdin.png +0 -0
- data/examples/stdin.tape +0 -7
- data/examples/tab.mp4 +0 -0
- data/examples/tab.png +0 -0
- data/examples/tab.tape +0 -5
- data/examples/themes/3024_day.png +0 -0
- data/examples/themes/3024_night.png +0 -0
- data/examples/themes/aardvark_blue.png +0 -0
- data/examples/themes/abernathy.png +0 -0
- data/examples/themes/adventure.png +0 -0
- data/examples/themes/adventure_time.png +0 -0
- data/examples/themes/afterglow.png +0 -0
- data/examples/themes/alabaster.png +0 -0
- data/examples/themes/alien_blood.png +0 -0
- data/examples/themes/andromeda.png +0 -0
- data/examples/themes/apple_classic.png +0 -0
- data/examples/themes/apple_system_colors.png +0 -0
- data/examples/themes/arcoiris.png +0 -0
- data/examples/themes/argonaut.png +0 -0
- data/examples/themes/arthur.png +0 -0
- data/examples/themes/atelier_sulphurpool.png +0 -0
- data/examples/themes/atom.png +0 -0
- data/examples/themes/atom_one_light.png +0 -0
- data/examples/themes/aurora.png +0 -0
- data/examples/themes/ayu.png +0 -0
- data/examples/themes/ayu_light.png +0 -0
- data/examples/themes/ayu_mirage.png +0 -0
- data/examples/themes/banana_blueberry.png +0 -0
- data/examples/themes/batman.png +0 -0
- data/examples/themes/belafonte_day.png +0 -0
- data/examples/themes/belafonte_night.png +0 -0
- data/examples/themes/birds_of_paradise.png +0 -0
- data/examples/themes/blazer.png +0 -0
- data/examples/themes/blue_berry_pie.png +0 -0
- data/examples/themes/blue_dolphin.png +0 -0
- data/examples/themes/blue_matrix.png +0 -0
- data/examples/themes/bluloco_dark.png +0 -0
- data/examples/themes/bluloco_light.png +0 -0
- data/examples/themes/borland.png +0 -0
- data/examples/themes/breeze.png +0 -0
- data/examples/themes/bright_lights.png +0 -0
- data/examples/themes/broadcast.png +0 -0
- data/examples/themes/brogrammer.png +0 -0
- data/examples/themes/bubbles.png +0 -0
- data/examples/themes/builtin_dark.png +0 -0
- data/examples/themes/builtin_light.png +0 -0
- data/examples/themes/builtin_pastel_dark.png +0 -0
- data/examples/themes/builtin_solarized_dark.png +0 -0
- data/examples/themes/builtin_solarized_light.png +0 -0
- data/examples/themes/builtin_tango_dark.png +0 -0
- data/examples/themes/builtin_tango_light.png +0 -0
- data/examples/themes/c64.png +0 -0
- data/examples/themes/calamity.png +0 -0
- data/examples/themes/catppuccin_frappe.png +0 -0
- data/examples/themes/catppuccin_latte.png +0 -0
- data/examples/themes/catppuccin_macchiato.png +0 -0
- data/examples/themes/catppuccin_mocha.png +0 -0
- data/examples/themes/cga.png +0 -0
- data/examples/themes/chalk.png +0 -0
- data/examples/themes/chalkboard.png +0 -0
- data/examples/themes/challenger_deep.png +0 -0
- data/examples/themes/chester.png +0 -0
- data/examples/themes/ciapre.png +0 -0
- data/examples/themes/clrs.png +0 -0
- data/examples/themes/cobalt2.png +0 -0
- data/examples/themes/cobalt_neon.png +0 -0
- data/examples/themes/coffee_theme.png +0 -0
- data/examples/themes/contrast_light.png +0 -0
- data/examples/themes/coolnight.png +0 -0
- data/examples/themes/crayon_pony_fish.png +0 -0
- data/examples/themes/crystal_violet.png +0 -0
- data/examples/themes/cutie_pro.png +0 -0
- data/examples/themes/cyber_cube.png +0 -0
- data/examples/themes/cyber_punk2077.png +0 -0
- data/examples/themes/cyberdyne.png +0 -0
- data/examples/themes/cyberpunk.png +0 -0
- data/examples/themes/dark_pastel.png +0 -0
- data/examples/themes/dark_plus.png +0 -0
- data/examples/themes/darkermatrix.png +0 -0
- data/examples/themes/darkmatrix.png +0 -0
- data/examples/themes/darkside.png +0 -0
- data/examples/themes/dayfox.png +0 -0
- data/examples/themes/deep.png +0 -0
- data/examples/themes/desert.png +0 -0
- data/examples/themes/dimmed_monokai.png +0 -0
- data/examples/themes/django.png +0 -0
- data/examples/themes/django_reborn_again.png +0 -0
- data/examples/themes/django_smooth.png +0 -0
- data/examples/themes/doom_one.png +0 -0
- data/examples/themes/doom_peacock.png +0 -0
- data/examples/themes/dot_gov.png +0 -0
- data/examples/themes/dracula.png +0 -0
- data/examples/themes/dracula_plus.png +0 -0
- data/examples/themes/duckbones.png +0 -0
- data/examples/themes/duotone_dark.png +0 -0
- data/examples/themes/earthsong.png +0 -0
- data/examples/themes/elemental.png +0 -0
- data/examples/themes/elementary.png +0 -0
- data/examples/themes/encom.png +0 -0
- data/examples/themes/espresso.png +0 -0
- data/examples/themes/espresso_libre.png +0 -0
- data/examples/themes/everblush.png +0 -0
- data/examples/themes/fahrenheit.png +0 -0
- data/examples/themes/fairyfloss.png +0 -0
- data/examples/themes/farmhouse_dark.png +0 -0
- data/examples/themes/farmhouse_light.png +0 -0
- data/examples/themes/fideloper.png +0 -0
- data/examples/themes/firefly_traditional.png +0 -0
- data/examples/themes/firefox_dev.png +0 -0
- data/examples/themes/firewatch.png +0 -0
- data/examples/themes/fish_tank.png +0 -0
- data/examples/themes/flat.png +0 -0
- data/examples/themes/flatland.png +0 -0
- data/examples/themes/flexoki_dark.png +0 -0
- data/examples/themes/flexoki_light.png +0 -0
- data/examples/themes/floraverse.png +0 -0
- data/examples/themes/forest_blue.png +0 -0
- data/examples/themes/framer.png +0 -0
- data/examples/themes/front_end_delight.png +0 -0
- data/examples/themes/fun_forrest.png +0 -0
- data/examples/themes/galaxy.png +0 -0
- data/examples/themes/galizur.png +0 -0
- data/examples/themes/ganyu.png +0 -0
- data/examples/themes/git_hub_dark.png +0 -0
- data/examples/themes/github.png +0 -0
- data/examples/themes/glacier.png +0 -0
- data/examples/themes/glorious.png +0 -0
- data/examples/themes/grape.png +0 -0
- data/examples/themes/grass.png +0 -0
- data/examples/themes/grey_green.png +0 -0
- data/examples/themes/gruvbox_dark.png +0 -0
- data/examples/themes/gruvbox_dark_hard.png +0 -0
- data/examples/themes/gruvbox_light.png +0 -0
- data/examples/themes/guezwhoz.png +0 -0
- data/examples/themes/h4rithd.png +0 -0
- data/examples/themes/h4rithd_com.png +0 -0
- data/examples/themes/ha_x0_r_blue.png +0 -0
- data/examples/themes/ha_x0_r_gr33_n.png +0 -0
- data/examples/themes/ha_x0_r_r3_d.png +0 -0
- data/examples/themes/hacktober.png +0 -0
- data/examples/themes/hardcore.png +0 -0
- data/examples/themes/harper.png +0 -0
- data/examples/themes/highway.png +0 -0
- data/examples/themes/hipster_green.png +0 -0
- data/examples/themes/hivacruz.png +0 -0
- data/examples/themes/homebrew.png +0 -0
- data/examples/themes/hopscotch.png +0 -0
- data/examples/themes/hopscotch_256.png +0 -0
- data/examples/themes/horizon.png +0 -0
- data/examples/themes/hurtado.png +0 -0
- data/examples/themes/hybrid.png +0 -0
- data/examples/themes/hyper.png +0 -0
- data/examples/themes/ic_green_ppl.png +0 -0
- data/examples/themes/ic_orange_ppl.png +0 -0
- data/examples/themes/iceberg_dark.png +0 -0
- data/examples/themes/iceberg_light.png +0 -0
- data/examples/themes/idea.png +0 -0
- data/examples/themes/idle_toes.png +0 -0
- data/examples/themes/ir_black.png +0 -0
- data/examples/themes/iterm2_dark_background.png +0 -0
- data/examples/themes/iterm2_default.png +0 -0
- data/examples/themes/iterm2_light_background.png +0 -0
- data/examples/themes/iterm2_pastel_dark_background.png +0 -0
- data/examples/themes/iterm2_smoooooth.png +0 -0
- data/examples/themes/iterm2_solarized_dark.png +0 -0
- data/examples/themes/iterm2_solarized_light.png +0 -0
- data/examples/themes/iterm2_tango_dark.png +0 -0
- data/examples/themes/iterm2_tango_light.png +0 -0
- data/examples/themes/jackie_brown.png +0 -0
- data/examples/themes/japanesque.png +0 -0
- data/examples/themes/jellybeans.png +0 -0
- data/examples/themes/jet_brains_darcula.png +0 -0
- data/examples/themes/jubi.png +0 -0
- data/examples/themes/juicy_colors.png +0 -0
- data/examples/themes/kanagawa.png +0 -0
- data/examples/themes/kanagawabones.png +0 -0
- data/examples/themes/kibble.png +0 -0
- data/examples/themes/kolorit.png +0 -0
- data/examples/themes/konsolas.png +0 -0
- data/examples/themes/lab_fox.png +0 -0
- data/examples/themes/laser.png +0 -0
- data/examples/themes/later_this_evening.png +0 -0
- data/examples/themes/lavandula.png +0 -0
- data/examples/themes/liquid_carbon.png +0 -0
- data/examples/themes/liquid_carbon_transparent.png +0 -0
- data/examples/themes/liquid_carbon_transparent_inverse.png +0 -0
- data/examples/themes/lovelace.png +0 -0
- data/examples/themes/man_page.png +0 -0
- data/examples/themes/mariana.png +0 -0
- data/examples/themes/material.png +0 -0
- data/examples/themes/material_dark.png +0 -0
- data/examples/themes/material_darker.png +0 -0
- data/examples/themes/material_design_colors.png +0 -0
- data/examples/themes/material_ocean.png +0 -0
- data/examples/themes/mathias.png +0 -0
- data/examples/themes/matrix.png +0 -0
- data/examples/themes/medallion.png +0 -0
- data/examples/themes/mellifluous.png +0 -0
- data/examples/themes/midnight_in_mojave.png +0 -0
- data/examples/themes/mirage.png +0 -0
- data/examples/themes/misterioso.png +0 -0
- data/examples/themes/molokai.png +0 -0
- data/examples/themes/mona_lisa.png +0 -0
- data/examples/themes/monokai_cmder.png +0 -0
- data/examples/themes/monokai_pro.png +0 -0
- data/examples/themes/monokai_pro_filter_octagon.png +0 -0
- data/examples/themes/monokai_pro_filter_ristretto.png +0 -0
- data/examples/themes/monokai_remastered.png +0 -0
- data/examples/themes/monokai_soda.png +0 -0
- data/examples/themes/monokai_vivid.png +0 -0
- data/examples/themes/moonlight_ii.png +0 -0
- data/examples/themes/n0tch2k.png +0 -0
- data/examples/themes/neobones_dark.png +0 -0
- data/examples/themes/neobones_light.png +0 -0
- data/examples/themes/neon.png +0 -0
- data/examples/themes/neopolitan.png +0 -0
- data/examples/themes/neutron.png +0 -0
- data/examples/themes/night_city.png +0 -0
- data/examples/themes/night_lion_v1.png +0 -0
- data/examples/themes/night_lion_v2.png +0 -0
- data/examples/themes/night_owlish_light.png +0 -0
- data/examples/themes/nightfox.png +0 -0
- data/examples/themes/niji.png +0 -0
- data/examples/themes/nocturnal_winter.png +0 -0
- data/examples/themes/nord.png +0 -0
- data/examples/themes/nord_light.png +0 -0
- data/examples/themes/novel.png +0 -0
- data/examples/themes/nvim_dark.png +0 -0
- data/examples/themes/nvim_light.png +0 -0
- data/examples/themes/obsidian.png +0 -0
- data/examples/themes/ocean.png +0 -0
- data/examples/themes/oceanic_material.png +0 -0
- data/examples/themes/oceanic_next.png +0 -0
- data/examples/themes/ollie.png +0 -0
- data/examples/themes/one_dark.png +0 -0
- data/examples/themes/one_half_dark.png +0 -0
- data/examples/themes/one_half_light.png +0 -0
- data/examples/themes/one_star.png +0 -0
- data/examples/themes/operator_mono_dark.png +0 -0
- data/examples/themes/overnight_slumber.png +0 -0
- data/examples/themes/pale_night_hc.png +0 -0
- data/examples/themes/pandora.png +0 -0
- data/examples/themes/paraiso_dark.png +0 -0
- data/examples/themes/paul_millr.png +0 -0
- data/examples/themes/pencil_dark.png +0 -0
- data/examples/themes/pencil_light.png +0 -0
- data/examples/themes/peppermint.png +0 -0
- data/examples/themes/piatto_light.png +0 -0
- data/examples/themes/pnevma.png +0 -0
- data/examples/themes/popping_and_locking.png +0 -0
- data/examples/themes/primary.png +0 -0
- data/examples/themes/primer.png +0 -0
- data/examples/themes/pro.png +0 -0
- data/examples/themes/pro_light.png +0 -0
- data/examples/themes/purple_rain.png +0 -0
- data/examples/themes/purplepeter.png +0 -0
- data/examples/themes/qb64_super_dark_blue.png +0 -0
- data/examples/themes/rapture.png +0 -0
- data/examples/themes/raycast_dark.png +0 -0
- data/examples/themes/raycast_light.png +0 -0
- data/examples/themes/rebecca.png +0 -0
- data/examples/themes/red_alert.png +0 -0
- data/examples/themes/red_planet.png +0 -0
- data/examples/themes/red_sands.png +0 -0
- data/examples/themes/relaxed.png +0 -0
- data/examples/themes/retro.png +0 -0
- data/examples/themes/retrowave.png +0 -0
- data/examples/themes/rippedcasts.png +0 -0
- data/examples/themes/rose_pine.png +0 -0
- data/examples/themes/rose_pine_dawn.png +0 -0
- data/examples/themes/rose_pine_moon.png +0 -0
- data/examples/themes/rouge_2.png +0 -0
- data/examples/themes/royal.png +0 -0
- data/examples/themes/ryuuko.png +0 -0
- data/examples/themes/sakura.png +0 -0
- data/examples/themes/scarlet_protocol.png +0 -0
- data/examples/themes/sea_shells.png +0 -0
- data/examples/themes/seafoam_pastel.png +0 -0
- data/examples/themes/seoulbones_dark.png +0 -0
- data/examples/themes/seoulbones_light.png +0 -0
- data/examples/themes/serendipity_midnight.png +0 -0
- data/examples/themes/serendipity_morning.png +0 -0
- data/examples/themes/serendipity_sunset.png +0 -0
- data/examples/themes/seti.png +0 -0
- data/examples/themes/shades_of_purple.png +0 -0
- data/examples/themes/shaman.png +0 -0
- data/examples/themes/slate.png +0 -0
- data/examples/themes/sleepy_hollow.png +0 -0
- data/examples/themes/smyck.png +0 -0
- data/examples/themes/snazzy.png +0 -0
- data/examples/themes/soft_server.png +0 -0
- data/examples/themes/solarized_darcula.png +0 -0
- data/examples/themes/solarized_dark_higher_contrast.png +0 -0
- data/examples/themes/solarized_dark_patched.png +0 -0
- data/examples/themes/sonoran_gothic.png +0 -0
- data/examples/themes/sonoran_sunrise.png +0 -0
- data/examples/themes/space_gray.png +0 -0
- data/examples/themes/space_gray_eighties.png +0 -0
- data/examples/themes/space_gray_eighties_dull.png +0 -0
- data/examples/themes/spacedust.png +0 -0
- data/examples/themes/spiderman.png +0 -0
- data/examples/themes/spring.png +0 -0
- data/examples/themes/square.png +0 -0
- data/examples/themes/sublette.png +0 -0
- data/examples/themes/subliminal.png +0 -0
- data/examples/themes/sundried.png +0 -0
- data/examples/themes/symfonic.png +0 -0
- data/examples/themes/synthwave.png +0 -0
- data/examples/themes/synthwave_alpha.png +0 -0
- data/examples/themes/synthwave_everything.png +0 -0
- data/examples/themes/tango_adapted.png +0 -0
- data/examples/themes/tango_half_adapted.png +0 -0
- data/examples/themes/teerb.png +0 -0
- data/examples/themes/terafox.png +0 -0
- data/examples/themes/terminal_basic.png +0 -0
- data/examples/themes/thayer_bright.png +0 -0
- data/examples/themes/the_hulk.png +0 -0
- data/examples/themes/theme.tape +0 -13
- data/examples/themes/tinacious_design_dark.png +0 -0
- data/examples/themes/tinacious_design_light.png +0 -0
- data/examples/themes/tokyo_night.png +0 -0
- data/examples/themes/tokyo_night_light.png +0 -0
- data/examples/themes/tokyo_night_storm.png +0 -0
- data/examples/themes/tokyonight.png +0 -0
- data/examples/themes/tokyonight_day.png +0 -0
- data/examples/themes/tokyonight_storm.png +0 -0
- data/examples/themes/tomorrow.png +0 -0
- data/examples/themes/tomorrow_night.png +0 -0
- data/examples/themes/tomorrow_night_blue.png +0 -0
- data/examples/themes/tomorrow_night_bright.png +0 -0
- data/examples/themes/tomorrow_night_burns.png +0 -0
- data/examples/themes/tomorrow_night_eighties.png +0 -0
- data/examples/themes/toy_chest.png +0 -0
- data/examples/themes/treehouse.png +0 -0
- data/examples/themes/twilight.png +0 -0
- data/examples/themes/ubuntu.png +0 -0
- data/examples/themes/ultra_dark.png +0 -0
- data/examples/themes/ultra_violent.png +0 -0
- data/examples/themes/under_the_sea.png +0 -0
- data/examples/themes/unholy.png +0 -0
- data/examples/themes/unikitty.png +0 -0
- data/examples/themes/urple.png +0 -0
- data/examples/themes/vaughn.png +0 -0
- data/examples/themes/vesper.png +0 -0
- data/examples/themes/vibrant_ink.png +0 -0
- data/examples/themes/vimbones.png +0 -0
- data/examples/themes/violet_dark.png +0 -0
- data/examples/themes/violet_light.png +0 -0
- data/examples/themes/warm_neon.png +0 -0
- data/examples/themes/wez.png +0 -0
- data/examples/themes/whimsy.png +0 -0
- data/examples/themes/wild_cherry.png +0 -0
- data/examples/themes/wilmersdorf.png +0 -0
- data/examples/themes/wombat.png +0 -0
- data/examples/themes/wryan.png +0 -0
- data/examples/themes/zenbones.png +0 -0
- data/examples/themes/zenbones_dark.png +0 -0
- data/examples/themes/zenbones_light.png +0 -0
- data/examples/themes/zenburn.png +0 -0
- data/examples/themes/zenburned.png +0 -0
- data/examples/themes/zenwritten_dark.png +0 -0
- data/examples/themes/zenwritten_light.png +0 -0
- data/examples/themes/zeonica.png +0 -0
- data/examples/tmux.mp4 +0 -0
- data/examples/tmux.png +0 -0
- data/examples/tmux.tape +0 -28
- data/examples/type.mp4 +0 -0
- data/examples/type.png +0 -0
- data/examples/type.tape +0 -11
- data/examples/type_file.mp4 +0 -0
- data/examples/type_file.png +0 -0
- data/examples/type_file.tape +0 -23
- data/examples/variable_typing.mp4 +0 -0
- data/examples/variable_typing.png +0 -0
- data/examples/variable_typing.tape +0 -41
- data/examples/wait_until.mp4 +0 -0
- data/examples/wait_until.png +0 -0
- data/examples/wait_until.tape +0 -8
- data/examples/zsh.mp4 +0 -0
- data/examples/zsh.png +0 -0
- data/examples/zsh.tape +0 -4
data/demotape.y
CHANGED
|
@@ -1,520 +1,239 @@
|
|
|
1
1
|
class DemoTape::Parser
|
|
2
|
-
rule
|
|
3
|
-
tape: commands { result = val[0] }
|
|
4
|
-
| /* empty */ { result = [] }
|
|
5
|
-
|
|
6
|
-
commands: command trailing_space NEWLINE { result = [val[0]] }
|
|
7
|
-
| commands command trailing_space NEWLINE { result = val[0] << val[1] }
|
|
8
|
-
|
|
9
|
-
trailing_space: SPACE { result = nil }
|
|
10
|
-
| /* empty */ { result = nil }
|
|
11
|
-
|
|
12
|
-
command: IDENTIFIER SPACE PLUS {
|
|
13
|
-
space_index = @token_index - 2
|
|
14
|
-
line_info = @lexer.line_map[space_index] || {}
|
|
15
|
-
error_msg = "Unexpected token \"SPACE\" at #{@file}:#{line_info[:line]}:#{line_info[:column]}:\n"
|
|
16
|
-
error_msg += " #{line_info[:content]}\n"
|
|
17
|
-
error_msg += " #{' ' * (line_info[:column] - 1)}^"
|
|
18
|
-
raise DemoTape::ParseError, error_msg
|
|
19
|
-
}
|
|
20
|
-
| key_combo SPACE NUMBER {
|
|
21
|
-
@command_start_index = @last_key_index
|
|
22
|
-
keys = val[0][:keys]
|
|
23
|
-
key_tokens = val[0][:tokens]
|
|
24
|
-
command_name = keys.shift
|
|
25
|
-
|
|
26
|
-
tokens = key_tokens + [make_token(:number, val[2], @token_index - 1)]
|
|
27
|
-
|
|
28
|
-
cmd = DemoTape::Command.new(command_name, "", keys:, count: val[2])
|
|
29
|
-
cmd.tokens = tokens
|
|
30
|
-
result = attach_location(cmd).prepare!
|
|
31
|
-
}
|
|
32
|
-
| key_combo {
|
|
33
|
-
@command_start_index = @last_key_index
|
|
34
|
-
keys = val[0][:keys]
|
|
35
|
-
key_tokens = val[0][:tokens]
|
|
36
|
-
command_name = keys.shift
|
|
37
|
-
|
|
38
|
-
cmd = DemoTape::Command.new(command_name, "", keys:)
|
|
39
|
-
cmd.tokens = key_tokens
|
|
40
|
-
result = attach_location(cmd).prepare!
|
|
41
|
-
}
|
|
42
|
-
| IDENTIFIER SPACE NUMBER {
|
|
43
|
-
@command_start_index = @token_index - 4
|
|
44
|
-
duration_index = @token_index - 2
|
|
45
|
-
|
|
46
|
-
tokens = [
|
|
47
|
-
make_token(:identifier, val[0], @token_index - 4),
|
|
48
|
-
make_token(:number, val[2], @token_index - 2)
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
# Duration commands (Sleep, Wait) treat bare numbers as seconds
|
|
52
|
-
# Key commands treat numbers as repeat counts
|
|
53
|
-
if ["Sleep", "Wait"].include?(val[0])
|
|
54
|
-
cmd = DemoTape::Command.new(val[0], "#{val[2]}s")
|
|
55
|
-
cmd.tokens = tokens
|
|
56
|
-
result = attach_location(cmd, duration_index: duration_index).prepare!
|
|
57
|
-
else
|
|
58
|
-
cmd = DemoTape::Command.new(val[0], "", count: val[2])
|
|
59
|
-
cmd.tokens = tokens
|
|
60
|
-
result = attach_location(cmd).prepare!
|
|
61
|
-
end
|
|
62
|
-
}
|
|
63
|
-
| IDENTIFIER AT duration SPACE string {
|
|
64
|
-
@command_start_index = @token_index - 6
|
|
65
|
-
speed_index = @token_index - 3 # TIME_UNIT position
|
|
66
|
-
|
|
67
|
-
tokens = [
|
|
68
|
-
make_token(:identifier, val[0], @token_index - 6),
|
|
69
|
-
make_token(:operator, "@", @token_index - 5),
|
|
70
|
-
make_token(:duration, val[2], @token_index - 4),
|
|
71
|
-
make_token(:string, val[4], @token_index - 1)
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
cmd = DemoTape::Command.new(val[0], val[4], speed: val[2])
|
|
75
|
-
cmd.tokens = tokens
|
|
76
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
77
|
-
}
|
|
78
|
-
| IDENTIFIER AT duration SPACE NUMBER {
|
|
79
|
-
@command_start_index = @token_index - 6
|
|
80
|
-
speed_index = @token_index - 3 # TIME_UNIT position
|
|
81
|
-
|
|
82
|
-
tokens = [
|
|
83
|
-
make_token(:identifier, val[0], @token_index - 6),
|
|
84
|
-
make_token(:operator, "@", @token_index - 5),
|
|
85
|
-
make_token(:duration, val[2], @token_index - 4),
|
|
86
|
-
make_token(:number, val[4], @token_index - 1)
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
cmd = DemoTape::Command.new(val[0], "", speed: val[2], count: val[4])
|
|
90
|
-
cmd.tokens = tokens
|
|
91
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
92
|
-
}
|
|
93
|
-
| IDENTIFIER AT NUMBER SPACE NUMBER {
|
|
94
|
-
@command_start_index = @token_index - 5
|
|
95
|
-
speed_index = @token_index - 3
|
|
96
|
-
|
|
97
|
-
tokens = [
|
|
98
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
99
|
-
make_token(:operator, "@", @token_index - 4),
|
|
100
|
-
make_token(:number, val[2], @token_index - 3),
|
|
101
|
-
make_token(:number, val[4], @token_index - 1)
|
|
102
|
-
]
|
|
103
|
-
|
|
104
|
-
cmd = DemoTape::Command.new(val[0], "", speed: "#{val[2]}s", count: val[4])
|
|
105
|
-
cmd.tokens = tokens
|
|
106
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
107
|
-
}
|
|
108
|
-
| IDENTIFIER AT NUMBER SPACE string {
|
|
109
|
-
@command_start_index = @token_index - 5
|
|
110
|
-
speed_index = @token_index - 3
|
|
111
|
-
|
|
112
|
-
tokens = [
|
|
113
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
114
|
-
make_token(:operator, "@", @token_index - 4),
|
|
115
|
-
make_token(:number, val[2], @token_index - 3),
|
|
116
|
-
make_token(:string, val[4], @token_index - 1)
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
cmd = DemoTape::Command.new(val[0], val[4], speed: "#{val[2]}s")
|
|
120
|
-
cmd.tokens = tokens
|
|
121
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
122
|
-
}
|
|
123
|
-
| IDENTIFIER AT NUMBER {
|
|
124
|
-
@command_start_index = @token_index - 3
|
|
125
|
-
speed_index = @token_index - 1
|
|
126
|
-
|
|
127
|
-
tokens = [
|
|
128
|
-
make_token(:identifier, val[0], @token_index - 3),
|
|
129
|
-
make_token(:operator, "@", @token_index - 2),
|
|
130
|
-
make_token(:number, val[2], @token_index - 1)
|
|
131
|
-
]
|
|
132
|
-
|
|
133
|
-
cmd = DemoTape::Command.new(val[0], "", speed: "#{val[2]}s")
|
|
134
|
-
cmd.tokens = tokens
|
|
135
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
136
|
-
}
|
|
137
|
-
| IDENTIFIER AT duration {
|
|
138
|
-
@command_start_index = @token_index - 4
|
|
139
|
-
speed_index = @token_index - 1 # TIME_UNIT position
|
|
140
|
-
|
|
141
|
-
tokens = [
|
|
142
|
-
make_token(:identifier, val[0], @token_index - 4),
|
|
143
|
-
make_token(:operator, "@", @token_index - 3),
|
|
144
|
-
make_token(:duration, val[2], @token_index - 2)
|
|
145
|
-
]
|
|
146
|
-
|
|
147
|
-
cmd = DemoTape::Command.new(val[0], "", speed: val[2])
|
|
148
|
-
cmd.tokens = tokens
|
|
149
|
-
result = attach_location(cmd, speed_index: speed_index).prepare!
|
|
150
|
-
}
|
|
151
|
-
| IDENTIFIER AT duration SPACE REGEX {
|
|
152
|
-
@command_start_index = @token_index - 6
|
|
153
|
-
timeout_index = @token_index - 3 # TIME_UNIT position
|
|
154
|
-
regex_index = @token_index - 1
|
|
155
|
-
|
|
156
|
-
begin
|
|
157
|
-
Regexp.new(val[4])
|
|
158
|
-
rescue RegexpError => e
|
|
159
|
-
line_info = @lexer.line_map[regex_index] || {}
|
|
160
|
-
error_msg = "Invalid regex: #{e.message} at #{@file}:#{line_info[:line]}:#{line_info[:column]}:\n"
|
|
161
|
-
error_msg += " #{line_info[:content]}\n"
|
|
162
|
-
error_msg += " #{' ' * (line_info[:column] - 1)}^"
|
|
163
|
-
raise DemoTape::ParseError, error_msg
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
tokens = [
|
|
167
|
-
make_token(:identifier, val[0], @token_index - 6),
|
|
168
|
-
make_token(:operator, "@", @token_index - 5),
|
|
169
|
-
make_token(:duration, val[2], @token_index - 4),
|
|
170
|
-
make_token(:regex, val[4], regex_index)
|
|
171
|
-
]
|
|
172
|
-
|
|
173
|
-
cmd = DemoTape::Command.new(val[0], val[4], timeout: val[2])
|
|
174
|
-
cmd.tokens = tokens
|
|
175
|
-
result = attach_location(cmd, timeout_index: timeout_index).prepare!
|
|
176
|
-
}
|
|
177
|
-
| IDENTIFIER SPACE REGEX {
|
|
178
|
-
@command_start_index = @token_index - 3
|
|
179
|
-
regex_index = @token_index - 1
|
|
180
|
-
|
|
181
|
-
begin
|
|
182
|
-
Regexp.new(val[2])
|
|
183
|
-
rescue RegexpError => e
|
|
184
|
-
line_info = @lexer.line_map[regex_index] || {}
|
|
185
|
-
error_msg = "Invalid regex: #{e.message} at #{@file}:#{line_info[:line]}:#{line_info[:column]}:\n"
|
|
186
|
-
error_msg += " #{line_info[:content]}\n"
|
|
187
|
-
error_msg += " #{' ' * (line_info[:column] - 1)}^"
|
|
188
|
-
raise DemoTape::ParseError, error_msg
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
tokens = [
|
|
192
|
-
make_token(:identifier, val[0], @token_index - 3),
|
|
193
|
-
make_token(:regex, val[2], regex_index)
|
|
194
|
-
]
|
|
195
|
-
|
|
196
|
-
cmd = DemoTape::Command.new(val[0], val[2])
|
|
197
|
-
cmd.tokens = tokens
|
|
198
|
-
result = attach_location(cmd).prepare!
|
|
199
|
-
}
|
|
200
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER {
|
|
201
|
-
@command_start_index = @token_index - 9
|
|
202
|
-
|
|
203
|
-
tokens = [
|
|
204
|
-
make_token(:identifier, val[0], @token_index - 9),
|
|
205
|
-
make_token(:identifier, val[2], @token_index - 7),
|
|
206
|
-
make_token(:number, val[4], @token_index - 5),
|
|
207
|
-
make_token(:operator, ",", @token_index - 4),
|
|
208
|
-
make_token(:number, val[6], @token_index - 3),
|
|
209
|
-
make_token(:operator, ",", @token_index - 2),
|
|
210
|
-
make_token(:number, val[8], @token_index - 1),
|
|
211
|
-
make_token(:operator, ",", @token_index - 1),
|
|
212
|
-
make_token(:number, val[10], @token_index - 1)
|
|
213
|
-
]
|
|
214
|
-
|
|
215
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[6], val[8], val[10]], option: val[2])
|
|
216
|
-
cmd.tokens = tokens
|
|
217
|
-
result = attach_location(cmd).prepare!
|
|
218
|
-
}
|
|
219
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA SPACE NUMBER COMMA SPACE NUMBER COMMA SPACE NUMBER {
|
|
220
|
-
@command_start_index = @token_index - 13
|
|
221
|
-
|
|
222
|
-
tokens = [
|
|
223
|
-
make_token(:identifier, val[0], @token_index - 13),
|
|
224
|
-
make_token(:identifier, val[2], @token_index - 11),
|
|
225
|
-
make_token(:number, val[4], @token_index - 9),
|
|
226
|
-
make_token(:operator, ",", @token_index - 8),
|
|
227
|
-
make_token(:number, val[7], @token_index - 6),
|
|
228
|
-
make_token(:operator, ",", @token_index - 5),
|
|
229
|
-
make_token(:number, val[10], @token_index - 3),
|
|
230
|
-
make_token(:operator, ",", @token_index - 2),
|
|
231
|
-
make_token(:number, val[13], @token_index - 1)
|
|
232
|
-
]
|
|
233
|
-
|
|
234
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[7], val[10], val[13]], option: val[2])
|
|
235
|
-
cmd.tokens = tokens
|
|
236
|
-
result = attach_location(cmd).prepare!
|
|
237
|
-
}
|
|
238
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA NUMBER COMMA NUMBER {
|
|
239
|
-
@command_start_index = @token_index - 7
|
|
240
|
-
|
|
241
|
-
tokens = [
|
|
242
|
-
make_token(:identifier, val[0], @token_index - 7),
|
|
243
|
-
make_token(:identifier, val[2], @token_index - 5),
|
|
244
|
-
make_token(:number, val[4], @token_index - 3),
|
|
245
|
-
make_token(:operator, ",", @token_index - 2),
|
|
246
|
-
make_token(:number, val[6], @token_index - 1),
|
|
247
|
-
make_token(:operator, ",", @token_index - 1),
|
|
248
|
-
make_token(:number, val[8], @token_index - 1)
|
|
249
|
-
]
|
|
250
|
-
|
|
251
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[6], val[8]], option: val[2])
|
|
252
|
-
cmd.tokens = tokens
|
|
253
|
-
result = attach_location(cmd).prepare!
|
|
254
|
-
}
|
|
255
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA SPACE NUMBER COMMA SPACE NUMBER {
|
|
256
|
-
@command_start_index = @token_index - 11
|
|
257
|
-
|
|
258
|
-
tokens = [
|
|
259
|
-
make_token(:identifier, val[0], @token_index - 11),
|
|
260
|
-
make_token(:identifier, val[2], @token_index - 9),
|
|
261
|
-
make_token(:number, val[4], @token_index - 7),
|
|
262
|
-
make_token(:operator, ",", @token_index - 6),
|
|
263
|
-
make_token(:number, val[7], @token_index - 4),
|
|
264
|
-
make_token(:operator, ",", @token_index - 3),
|
|
265
|
-
make_token(:number, val[10], @token_index - 1)
|
|
266
|
-
]
|
|
267
|
-
|
|
268
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[7], val[10]], option: val[2])
|
|
269
|
-
cmd.tokens = tokens
|
|
270
|
-
result = attach_location(cmd).prepare!
|
|
271
|
-
}
|
|
272
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA NUMBER {
|
|
273
|
-
@command_start_index = @token_index - 5
|
|
274
|
-
|
|
275
|
-
tokens = [
|
|
276
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
277
|
-
make_token(:identifier, val[2], @token_index - 3),
|
|
278
|
-
make_token(:number, val[4], @token_index - 1),
|
|
279
|
-
make_token(:operator, ",", @token_index - 1),
|
|
280
|
-
make_token(:number, val[6], @token_index - 1)
|
|
281
|
-
]
|
|
282
|
-
|
|
283
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[6]], option: val[2])
|
|
284
|
-
cmd.tokens = tokens
|
|
285
|
-
result = attach_location(cmd).prepare!
|
|
286
|
-
}
|
|
287
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER COMMA SPACE NUMBER {
|
|
288
|
-
@command_start_index = @token_index - 8
|
|
289
|
-
|
|
290
|
-
tokens = [
|
|
291
|
-
make_token(:identifier, val[0], @token_index - 8),
|
|
292
|
-
make_token(:identifier, val[2], @token_index - 6),
|
|
293
|
-
make_token(:number, val[4], @token_index - 4),
|
|
294
|
-
make_token(:operator, ",", @token_index - 3),
|
|
295
|
-
make_token(:number, val[7], @token_index - 1)
|
|
296
|
-
]
|
|
297
|
-
|
|
298
|
-
cmd = DemoTape::Command.new(val[0], [val[4], val[7]], option: val[2])
|
|
299
|
-
cmd.tokens = tokens
|
|
300
|
-
result = attach_location(cmd).prepare!
|
|
301
|
-
}
|
|
302
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE duration {
|
|
303
|
-
@command_start_index = @token_index - 6
|
|
304
|
-
|
|
305
|
-
tokens = [
|
|
306
|
-
make_token(:identifier, val[0], @token_index - 6),
|
|
307
|
-
make_token(:identifier, val[2], @token_index - 4),
|
|
308
|
-
make_token(:duration, val[4], @token_index - 2)
|
|
309
|
-
]
|
|
310
|
-
|
|
311
|
-
cmd = DemoTape::Command.new(val[0], val[4], option: val[2])
|
|
312
|
-
cmd.tokens = tokens
|
|
313
|
-
result = attach_location(cmd).prepare!
|
|
314
|
-
}
|
|
315
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE NUMBER {
|
|
316
|
-
@command_start_index = @token_index - 5
|
|
317
|
-
|
|
318
|
-
tokens = [
|
|
319
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
320
|
-
make_token(:identifier, val[2], @token_index - 3),
|
|
321
|
-
make_token(:number, val[4], @token_index - 1)
|
|
322
|
-
]
|
|
323
|
-
|
|
324
|
-
cmd = DemoTape::Command.new(val[0], val[4].to_s, option: val[2])
|
|
325
|
-
cmd.tokens = tokens
|
|
326
|
-
result = attach_location(cmd).prepare!
|
|
327
|
-
}
|
|
328
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE IDENTIFIER {
|
|
329
|
-
@command_start_index = @token_index - 5
|
|
330
|
-
|
|
331
|
-
tokens = [
|
|
332
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
333
|
-
make_token(:identifier, val[2], @token_index - 3),
|
|
334
|
-
make_token(:identifier, val[4], @token_index - 1)
|
|
335
|
-
]
|
|
336
|
-
|
|
337
|
-
cmd = DemoTape::Command.new(val[0], val[4], option: val[2])
|
|
338
|
-
cmd.tokens = tokens
|
|
339
|
-
result = attach_location(cmd).prepare!
|
|
340
|
-
}
|
|
341
|
-
| IDENTIFIER SPACE IDENTIFIER SPACE string {
|
|
342
|
-
@command_start_index = @token_index - 5
|
|
343
|
-
|
|
344
|
-
tokens = [
|
|
345
|
-
make_token(:identifier, val[0], @token_index - 5),
|
|
346
|
-
make_token(:identifier, val[2], @token_index - 3),
|
|
347
|
-
make_token(:string, val[4], @token_index - 1)
|
|
348
|
-
]
|
|
349
|
-
|
|
350
|
-
cmd = DemoTape::Command.new(val[0], val[4], option: val[2])
|
|
351
|
-
cmd.tokens = tokens
|
|
352
|
-
result = attach_location(cmd).prepare!
|
|
353
|
-
}
|
|
354
|
-
| IDENTIFIER SPACE string {
|
|
355
|
-
@command_start_index = @token_index - 3
|
|
356
|
-
|
|
357
|
-
tokens = [
|
|
358
|
-
make_token(:identifier, val[0], @token_index - 3),
|
|
359
|
-
make_token(:string, val[2], @token_index - 1)
|
|
360
|
-
]
|
|
361
|
-
|
|
362
|
-
cmd = DemoTape::Command.new(val[0], val[2])
|
|
363
|
-
cmd.tokens = tokens
|
|
364
|
-
result = attach_location(cmd).prepare!
|
|
365
|
-
}
|
|
366
|
-
| IDENTIFIER SPACE duration {
|
|
367
|
-
@command_start_index = @token_index - 4
|
|
368
|
-
duration_index = @token_index - 1 # TIME_UNIT position
|
|
369
|
-
|
|
370
|
-
tokens = [
|
|
371
|
-
make_token(:identifier, val[0], @token_index - 4),
|
|
372
|
-
make_token(:duration, val[2], @token_index - 2)
|
|
373
|
-
]
|
|
374
|
-
|
|
375
|
-
cmd = DemoTape::Command.new(val[0], val[2])
|
|
376
|
-
cmd.tokens = tokens
|
|
377
|
-
result = attach_location(cmd, duration_index: duration_index).prepare!
|
|
378
|
-
}
|
|
379
|
-
| IDENTIFIER {
|
|
380
|
-
@command_start_index = @token_index - 2
|
|
381
|
-
|
|
382
|
-
tokens = [make_token(:identifier, val[0], @token_index - 2)]
|
|
383
|
-
|
|
384
|
-
cmd = DemoTape::Command.new(val[0], "")
|
|
385
|
-
cmd.tokens = tokens
|
|
386
|
-
result = attach_location(cmd).prepare!
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
key_combo: IDENTIFIER PLUS IDENTIFIER {
|
|
390
|
-
@last_key_index = @token_index - 1
|
|
391
|
-
|
|
392
|
-
tokens = [
|
|
393
|
-
make_token(:identifier, val[0], @token_index - 3),
|
|
394
|
-
make_token(:operator, "+", @token_index - 2),
|
|
395
|
-
make_token(:identifier, val[2], @token_index - 1)
|
|
396
|
-
]
|
|
397
2
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
3
|
+
# Precedence rules to resolve shift/reduce conflicts
|
|
4
|
+
# When we see LEADING_SPACE and END is in lookahead, reduce group_body instead of shifting
|
|
5
|
+
prechigh
|
|
6
|
+
nonassoc END
|
|
7
|
+
left LEADING_SPACE
|
|
8
|
+
preclow
|
|
402
9
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
10
|
+
rule
|
|
11
|
+
# Document is a flat list - mix of tokens and command contexts
|
|
12
|
+
document: lines { result = val[0].flatten.compact }
|
|
13
|
+
| /* empty */ { result = [] }
|
|
14
|
+
|
|
15
|
+
lines: line { result = val[0] }
|
|
16
|
+
| lines line { result = val[0] + val[1] }
|
|
17
|
+
|
|
18
|
+
# A line can be a comment, newline, group, or command
|
|
19
|
+
line: COMMENT NEWLINE {
|
|
20
|
+
result = [
|
|
21
|
+
make_token(:comment, val[0], index_for_value(val[0])),
|
|
22
|
+
make_token(:newline, val[1], index_for_value(val[1]))
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
| LEADING_SPACE COMMENT NEWLINE {
|
|
26
|
+
result = [
|
|
27
|
+
make_token(:leading_space, val[0], index_for_value(val[0])),
|
|
28
|
+
make_token(:comment, val[1], index_for_value(val[1])),
|
|
29
|
+
make_token(:newline, val[2], index_for_value(val[2]))
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
| NEWLINE { result = [make_token(:newline, val[0], index_for_value(val[0]))] }
|
|
33
|
+
| group { result = [val[0]] }
|
|
34
|
+
| line_tokens NEWLINE {
|
|
35
|
+
tokens, start_idx = val[0]
|
|
36
|
+
result = [
|
|
37
|
+
{ type: :command, tokens: tokens, line: line_for_token_at(start_idx), column: column_for_token_at(start_idx) },
|
|
38
|
+
make_token(:newline, val[1], index_for_value(val[1]))
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
| LEADING_SPACE line_tokens NEWLINE {
|
|
42
|
+
idx_lead = index_for_value(val[0])
|
|
43
|
+
tokens, _ = val[1]
|
|
44
|
+
result = [
|
|
45
|
+
{ type: :command, tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens, line: line_for_token_at(idx_lead), column: column_for_token_at(idx_lead) },
|
|
46
|
+
make_token(:newline, val[2], index_for_value(val[2]))
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Group block: tokens ending with 'do', body, then 'end'
|
|
51
|
+
group: line_tokens DO NEWLINE group_body END NEWLINE {
|
|
52
|
+
tokens, start_idx = val[0]
|
|
53
|
+
idx_do = index_for_value(val[1])
|
|
54
|
+
idx_nl = index_for_value(val[2])
|
|
55
|
+
idx_end = index_for_value(val[4])
|
|
56
|
+
result = {
|
|
57
|
+
type: :group,
|
|
58
|
+
tokens: tokens + [make_token(:keyword, val[1], idx_do), make_token(:keyword, val[4], idx_end)],
|
|
59
|
+
children: [make_token(:newline, val[2], idx_nl)] + val[3],
|
|
60
|
+
line: line_for_token_at(start_idx),
|
|
61
|
+
column: column_for_token_at(start_idx)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
| line_tokens DO NEWLINE group_body LEADING_SPACE END NEWLINE {
|
|
65
|
+
tokens, start_idx = val[0]
|
|
66
|
+
idx_do = index_for_value(val[1])
|
|
67
|
+
idx_nl = index_for_value(val[2])
|
|
68
|
+
idx_end = index_for_value(val[5])
|
|
69
|
+
# Discard the LEADING_SPACE before END (val[4])
|
|
70
|
+
result = {
|
|
71
|
+
type: :group,
|
|
72
|
+
tokens: tokens + [make_token(:keyword, val[1], idx_do), make_token(:keyword, val[5], idx_end)],
|
|
73
|
+
children: [make_token(:newline, val[2], idx_nl)] + val[3],
|
|
74
|
+
line: line_for_token_at(start_idx),
|
|
75
|
+
column: column_for_token_at(start_idx)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
| LEADING_SPACE line_tokens DO NEWLINE group_body END NEWLINE {
|
|
79
|
+
idx_lead = index_for_value(val[0])
|
|
80
|
+
tokens, _ = val[1]
|
|
81
|
+
idx_do = index_for_value(val[2])
|
|
82
|
+
idx_nl = index_for_value(val[3])
|
|
83
|
+
idx_end = index_for_value(val[5])
|
|
84
|
+
result = {
|
|
85
|
+
type: :group,
|
|
86
|
+
tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens + [make_token(:keyword, val[2], idx_do), make_token(:keyword, val[5], idx_end)],
|
|
87
|
+
children: [make_token(:newline, val[3], idx_nl)] + val[4],
|
|
88
|
+
line: line_for_token_at(idx_lead),
|
|
89
|
+
column: column_for_token_at(idx_lead)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
| LEADING_SPACE line_tokens DO NEWLINE group_body LEADING_SPACE END NEWLINE {
|
|
93
|
+
idx_lead = index_for_value(val[0])
|
|
94
|
+
tokens, _ = val[1]
|
|
95
|
+
idx_do = index_for_value(val[2])
|
|
96
|
+
idx_nl = index_for_value(val[3])
|
|
97
|
+
idx_end = index_for_value(val[6])
|
|
98
|
+
# Discard the LEADING_SPACE before END (val[5])
|
|
99
|
+
result = {
|
|
100
|
+
type: :group,
|
|
101
|
+
tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens + [make_token(:keyword, val[2], idx_do), make_token(:keyword, val[6], idx_end)],
|
|
102
|
+
children: [make_token(:newline, val[3], idx_nl)] + val[4],
|
|
103
|
+
line: line_for_token_at(idx_lead),
|
|
104
|
+
column: column_for_token_at(idx_lead)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
| line_tokens DO TRAILING_SPACE NEWLINE group_body END NEWLINE {
|
|
108
|
+
tokens, start_idx = val[0]
|
|
109
|
+
idx_do = index_for_value(val[1])
|
|
110
|
+
idx_trail = index_for_value(val[2])
|
|
111
|
+
idx_nl = index_for_value(val[3])
|
|
112
|
+
idx_end = index_for_value(val[5])
|
|
113
|
+
result = {
|
|
114
|
+
type: :group,
|
|
115
|
+
tokens: tokens + [make_token(:keyword, val[1], idx_do), make_token(:trailing_space, val[2], idx_trail), make_token(:keyword, val[5], idx_end)],
|
|
116
|
+
children: [make_token(:newline, val[3], idx_nl)] + val[4],
|
|
117
|
+
line: line_for_token_at(start_idx),
|
|
118
|
+
column: column_for_token_at(start_idx)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
| line_tokens DO TRAILING_SPACE NEWLINE group_body LEADING_SPACE END NEWLINE {
|
|
122
|
+
tokens, start_idx = val[0]
|
|
123
|
+
idx_do = index_for_value(val[1])
|
|
124
|
+
idx_trail = index_for_value(val[2])
|
|
125
|
+
idx_nl = index_for_value(val[3])
|
|
126
|
+
idx_end = index_for_value(val[6])
|
|
127
|
+
# Discard the LEADING_SPACE before END (val[5])
|
|
128
|
+
result = {
|
|
129
|
+
type: :group,
|
|
130
|
+
tokens: tokens + [make_token(:keyword, val[1], idx_do), make_token(:trailing_space, val[2], idx_trail), make_token(:keyword, val[6], idx_end)],
|
|
131
|
+
children: [make_token(:newline, val[3], idx_nl)] + val[4],
|
|
132
|
+
line: line_for_token_at(start_idx),
|
|
133
|
+
column: column_for_token_at(start_idx)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
| LEADING_SPACE line_tokens DO TRAILING_SPACE NEWLINE group_body LEADING_SPACE END NEWLINE {
|
|
137
|
+
idx_lead = index_for_value(val[0])
|
|
138
|
+
tokens, _ = val[1]
|
|
139
|
+
idx_do = index_for_value(val[2])
|
|
140
|
+
idx_trail = index_for_value(val[3])
|
|
141
|
+
idx_nl = index_for_value(val[4])
|
|
142
|
+
idx_end = index_for_value(val[7])
|
|
143
|
+
# Discard the LEADING_SPACE before END (val[6])
|
|
144
|
+
result = {
|
|
145
|
+
type: :group,
|
|
146
|
+
tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens + [make_token(:keyword, val[2], idx_do), make_token(:trailing_space, val[3], idx_trail), make_token(:keyword, val[7], idx_end)],
|
|
147
|
+
children: [make_token(:newline, val[4], idx_nl)] + val[5],
|
|
148
|
+
line: line_for_token_at(idx_lead),
|
|
149
|
+
column: column_for_token_at(idx_lead)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
| LEADING_SPACE line_tokens DO TRAILING_SPACE NEWLINE group_body END NEWLINE {
|
|
153
|
+
idx_lead = index_for_value(val[0])
|
|
154
|
+
tokens, _ = val[1]
|
|
155
|
+
idx_do = index_for_value(val[2])
|
|
156
|
+
idx_trail = index_for_value(val[3])
|
|
157
|
+
idx_nl = index_for_value(val[4])
|
|
158
|
+
idx_end = index_for_value(val[6])
|
|
159
|
+
result = {
|
|
160
|
+
type: :group,
|
|
161
|
+
tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens + [make_token(:keyword, val[2], idx_do), make_token(:trailing_space, val[3], idx_trail), make_token(:keyword, val[6], idx_end)],
|
|
162
|
+
children: [make_token(:newline, val[4], idx_nl)] + val[5],
|
|
163
|
+
line: line_for_token_at(idx_lead),
|
|
164
|
+
column: column_for_token_at(idx_lead)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# Group body - same structure as document
|
|
170
|
+
group_body: /* empty */ { result = [] }
|
|
171
|
+
| group_lines { result = val[0].flatten.compact }
|
|
172
|
+
|
|
173
|
+
group_lines: group_line { result = val[0] }
|
|
174
|
+
| group_lines group_line { result = val[0] + val[1] }
|
|
175
|
+
|
|
176
|
+
# Group line - same as document line but need to be careful not to consume LEADING_SPACE before END
|
|
177
|
+
group_line: COMMENT NEWLINE {
|
|
178
|
+
result = [
|
|
179
|
+
make_token(:comment, val[0], index_for_value(val[0])),
|
|
180
|
+
make_token(:newline, val[1], index_for_value(val[1]))
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
| NEWLINE { result = [make_token(:newline, val[0], index_for_value(val[0]))] }
|
|
184
|
+
| line_tokens NEWLINE {
|
|
185
|
+
tokens, start_idx = val[0]
|
|
186
|
+
result = [
|
|
187
|
+
{ type: :command, tokens: tokens, line: line_for_token_at(start_idx), column: column_for_token_at(start_idx) },
|
|
188
|
+
make_token(:newline, val[1], index_for_value(val[1]))
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
| LEADING_SPACE line_tokens NEWLINE {
|
|
192
|
+
idx_lead = index_for_value(val[0])
|
|
193
|
+
tokens, _ = val[1]
|
|
194
|
+
result = [
|
|
195
|
+
{ type: :command, tokens: [make_token(:leading_space, val[0], idx_lead)] + tokens, line: line_for_token_at(idx_lead), column: column_for_token_at(idx_lead) },
|
|
196
|
+
make_token(:newline, val[2], index_for_value(val[2]))
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
| LEADING_SPACE COMMENT NEWLINE {
|
|
200
|
+
result = [
|
|
201
|
+
make_token(:leading_space, val[0], index_for_value(val[0])),
|
|
202
|
+
make_token(:comment, val[1], index_for_value(val[1])),
|
|
203
|
+
make_token(:newline, val[2], index_for_value(val[2]))
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# Collect all tokens on a line (anything but NEWLINE and COMMENT)
|
|
208
|
+
# Returns [tokens_array, start_index]
|
|
209
|
+
line_tokens: line_token { result = [[val[0][:token]], val[0][:index]] }
|
|
210
|
+
| line_tokens line_token { result = [val[0][0] << val[1][:token], val[0][1]] }
|
|
211
|
+
|
|
212
|
+
line_token: IDENTIFIER { idx = index_for_value(val[0]); result = { token: make_token(:identifier, val[0], idx), index: idx } }
|
|
213
|
+
| STRING { idx = index_for_value(val[0]); result = { token: make_token(:string, val[0], idx), index: idx } }
|
|
214
|
+
| MULTILINE_STRING { idx = index_for_value(val[0]); result = { token: make_token(:multiline_string, val[0], idx), index: idx } }
|
|
215
|
+
| NUMBER { idx = index_for_value(val[0]); result = { token: make_token(:number, val[0], idx), index: idx } }
|
|
216
|
+
| DURATION { idx = index_for_value(val[0]); result = { token: make_token(:duration, val[0], idx), index: idx } }
|
|
217
|
+
| REGEX { idx = index_for_value(val[0]); result = { token: make_token(:regex, val[0], idx), index: idx } }
|
|
218
|
+
| SPACE { idx = index_for_value(val[0]); result = { token: make_token(:space, val[0], idx), index: idx } }
|
|
219
|
+
| TRAILING_SPACE { idx = index_for_value(val[0]); result = { token: make_token(:trailing_space, val[0], idx), index: idx } }
|
|
220
|
+
| COMMA { idx = index_for_value(val[0]); result = { token: make_token(:operator, ",", idx), index: idx } }
|
|
221
|
+
| PLUS { idx = index_for_value(val[0]); result = { token: make_token(:operator, "+", idx), index: idx } }
|
|
222
|
+
| AT { idx = index_for_value(val[0]); result = { token: make_token(:operator, "@", idx), index: idx } }
|
|
223
|
+
| TIME_UNIT { idx = index_for_value(val[0]); result = { token: make_token(:time_unit, val[0], idx), index: idx } }
|
|
438
224
|
|
|
439
225
|
---- header
|
|
440
226
|
|
|
441
227
|
---- inner
|
|
228
|
+
include Helpers
|
|
229
|
+
|
|
442
230
|
def parse(str, file: "<unknown>")
|
|
443
231
|
@file = file
|
|
444
232
|
@lexer = DemoTape::Lexer.new
|
|
445
233
|
@tokens = @lexer.tokenize(str)
|
|
446
234
|
@token_index = 0
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
def next_token
|
|
451
|
-
token = @tokens.shift
|
|
452
|
-
@current_token_index = @token_index
|
|
453
|
-
@token_index += 1
|
|
454
|
-
token
|
|
455
|
-
end
|
|
456
|
-
|
|
457
|
-
def make_token(type, value, index)
|
|
458
|
-
line_info = @lexer.line_map[index] || {}
|
|
459
|
-
token_class = case type
|
|
460
|
-
when :identifier then Token::Identifier
|
|
461
|
-
when :string then Token::String
|
|
462
|
-
when :number then Token::Number
|
|
463
|
-
when :duration then Token::Duration
|
|
464
|
-
when :regex then Token::Regex
|
|
465
|
-
when :time_unit then Token::TimeUnit
|
|
466
|
-
when :operator then Token::Operator
|
|
467
|
-
else Token::Base
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
token_class.new(
|
|
471
|
-
value,
|
|
472
|
-
line: line_info[:line],
|
|
473
|
-
column: line_info[:column],
|
|
474
|
-
raw: line_info[:raw]
|
|
475
|
-
)
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
def attach_location(command, duration_index: nil, speed_index: nil, timeout_index: nil)
|
|
479
|
-
line_info = @lexer.line_map[@command_start_index] || {}
|
|
480
|
-
command.line = line_info[:line]
|
|
481
|
-
command.column = line_info[:column]
|
|
482
|
-
command.line_content = line_info[:content]
|
|
483
|
-
command.file = @file
|
|
484
|
-
|
|
485
|
-
# Attach duration/speed/timeout specific columns if provided
|
|
486
|
-
if duration_index
|
|
487
|
-
duration_info = @lexer.line_map[duration_index] || {}
|
|
488
|
-
command.duration_column = duration_info[:column]
|
|
489
|
-
end
|
|
490
|
-
|
|
491
|
-
if speed_index
|
|
492
|
-
speed_info = @lexer.line_map[speed_index] || {}
|
|
493
|
-
command.speed_column = speed_info[:column]
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
if timeout_index
|
|
497
|
-
timeout_info = @lexer.line_map[timeout_index] || {}
|
|
498
|
-
command.timeout_column = timeout_info[:column]
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
command
|
|
502
|
-
end
|
|
503
|
-
|
|
504
|
-
def on_error(token_id, token_value, value_stack)
|
|
505
|
-
# Get line metadata from the lexer's line map
|
|
506
|
-
line_info = @lexer.line_map[@current_token_index] || {}
|
|
507
|
-
line_num = line_info[:line] || "?"
|
|
508
|
-
col_num = line_info[:column] || 1
|
|
509
|
-
line_content = line_info[:content] || ""
|
|
510
|
-
|
|
511
|
-
token_name = token_to_str(token_id) || token_id.to_s
|
|
512
|
-
|
|
513
|
-
error_msg = "Unexpected token #{token_name.inspect} at #{@file}:#{line_num}:#{col_num}:\n"
|
|
514
|
-
error_msg += " #{line_content}\n"
|
|
515
|
-
error_msg += " #{' ' * (col_num - 1)}^"
|
|
516
|
-
|
|
517
|
-
raise DemoTape::ParseError, error_msg
|
|
235
|
+
@token_indices = {} # Map token object_id to its index
|
|
236
|
+
validate_tree!(do_parse)
|
|
518
237
|
end
|
|
519
238
|
|
|
520
239
|
---- footer
|