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

  • SEARCH
  • Home
  • 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 4117142
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:47:52+00:00 2026-05-20T22:47:52+00:00

I have 3 objects: Parser ParserState – a state machine that tracks the current

  • 0

I have 3 objects:

  • Parser
  • ParserState – a state machine that tracks the current state and transitions between states
  • ParserDefinitions – it reads from a json file and supplies the regexes of a given state, as well as some other rules that govern how the parser operates

ParserState and ParserDefinitions are both subclasses (?) of Parser and are defined as Parser::ParserState and Parser::ParserDefinitions. It would be great if the ParserState object could have access to the current instance of ParserDefinitions and vice versa. Is this possible, or does it imply that they should actually be combined in to one class?

Btw, I am using Ruby so if it is possible that they share instance information between them it would be great if Ruby code could be used.

  • 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-20T22:47:53+00:00Added an answer on May 20, 2026 at 10:47 pm
    1. Those are not subclasses, they are simply namespaced under the class. This provides no linkage between the class objects.

    2. The way that object A accesses the state of object B is by invoking methods on object B and looking at the return values. It seems that the only issue here is how to make object A know about object B.

    3. You have capitalized the names of these as though they are modules or classes, but you seem to be referring to them as instances. Are these singleton objects, or does (for example) a Parser instance create both ParserStart and ParserDefinitions instances? Assuming that the latter is the case:

      class Parser
        attr_accessor :states, :defns
        def initialize
          self.states = ParserStates.new( self )
          self.defns  = ParserDefinitions.new( self )
        end
      end
      
      class Parser::ParserStates
        attr_accessor :parser
        def initialize( parent_parser )
          self.parser = parent_parser
        end
        def defns
          parser.defns
        end
      end
      
      class Parser::ParserDefinitions
        attr_accessor :parser
        def initialize( parent_parser )
          self.parser = parent_parser
        end
        def states
          parser.states
        end
      end
      

      Given the above, where each ‘child’ object knows about its ‘parent’ and the parent exposes accessors to the children, all objects can talk to one another.

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

Sidebar

Related Questions

My application receives strings that represent objects. I have to parse the strings to
I have a question with fluent interfaces. We have some objects that are used
I want to implement an aplication where I have various Objects that can be
I have an antlr generated Java parser that uses the C target and it
I have an ANTLR3 simple grammar parser that takes short lines of text and
Hey, I have an iphone program that has a parser that parses some XML
I have an object. fp = open(self.currentEmailPath, rb) p = email.Parser.Parser() self._currentEmailParsedInstance= p.parse(fp) fp.close()
I have two objects, let's call them Input and Output Input has properties Input_ID
I have a bunch of objects in a flat structure. These objects have an
I have several objects in the database. Url to edit an object using the

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.