Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6695939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:16:56+00:00 2026-05-26T06:16:56+00:00

Has anyone figured out how to detect errors when malformed input is given to

  • 0

Has anyone figured out how to detect errors when malformed input is given to Ruby’s ripper library?

ruby-1.9.2-p180 :002 > Ripper.sexp("array[1 2]")
 => [:program, [:@int, "2", [1, 8]]] 
ruby-1.9.2-p180 :003 >

I’ve poked around the sources a little and discovered #compile_error, #warning, #warn, and #yydebug, but it’s not yet clear how to get any of these methods to work. No doubt there’s some simple answer here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:16:57+00:00Added an answer on May 26, 2026 at 6:16 am

    I think I read somewhere that the ruby ripper extension is still under active development, so I wouldn’t be surprised if no one has gotten around to wiring up #compile_error, #warning or #warn yet.

    Ripper#yydebug works in Ruby 1.9.3, and it might work in 1.9.2 and I was just doing something wrong. But it prints out debugging information, only a little of which will be related to an error.

    This is one straightforward way to detect errors:

    require 'ripper'
    require 'pp'
    
    class SexpBuilderPP < Ripper::SexpBuilderPP
      def on_parse_error(*)
        raise "parse error!"
      end
    end
    
    while input = $stdin.gets
      pp SexpBuilderPP.new(input).parse
    end
    

    There are several events that contain “error” in the name: on_alias_error, on_assign_error, on_class_name_error, on_param_error and on_parse_error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone figured out how to return the SQL for an object that is
Has anyone figured out how to angle a text field in a form? I'm
I was wondering if anyone else has figured out how to solve this problem.
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices
Has anyone figured out a good way to embed video and audio into showoff
I know iBooks has this little nuance built in. Has anyone figured out how
Has anyone figured out a way to have more than one entity namespace within
Has anyone figured out a way to use matlab to send email from a
Has anyone figured out a good way to make a hidden table/matrix column take
Has anyone figured out how the Very Sleepy profiler finds PDB files? It seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.