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 6874869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:14:57+00:00 2026-05-27T04:14:57+00:00

I am implementing my own fsm to parse a file. I am new to

  • 0

I am implementing my own fsm to parse a file. I am new to fsm pattern so trying to learn about it.

My fsm class takes a stream of the file that is being parsed along with the current state and a collection of all accepting states.

Now I am confused about couple of things.

  1. How does the fsm move through states and keep track of what has been parsed so far?

  2. What information should the state object store? Right now they have a pattern that they match on the line and see if fsm can move to this state or not.

Example:

File to parse:

Person:  bob smith
        Age: 33
        Location: new York
End person
Person:  Jane smith
        Age: 66
        Location: Chicago
End person

So I have a state for person start, age, location and end person. Each state object has a patter. (regex) to check if the given line is accepted by them or not.

But I am stuck on how would I construct a Person object when parsing this file using fsm??

  • 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-27T04:14:57+00:00Added an answer on May 27, 2026 at 4:14 am

    Have a list of persons (empty initially). Have a currentPerson variable.

    • When the state is “person start”, initialize the currentPerson variable to a new Person.
    • When the state is “age”, set the age into the currentPerson.
    • Same for the “location” state.
    • When the state is “end of person”, add the currentPerson to the list of persons.

    When you reach the end of the file, the list of persons contains all your persons.

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

Sidebar

Related Questions

Where can I get info about implementing my own methods that have the ellipsis
I am implementing my own RSA algorithm in ruby to learn more about the
i'm just trying out the new font-face feature in css3 for implementing own ttf/otf
I'm implementing my own double-buffering for a BufferedImage in a JPanel so that I
I am implementing my own LinkedList . I've a class which calls MyLinkedLlist ,
We have an application that is essentially implementing its own messaging queue. When a
I am implementing my own Java class for sorting a List<T> in eclipse. I
I was implementing my own ArrayList class and was left surprised when I realised
Is it possible, and if so how would you go about implementing your own
While implementing my own IFilter I found that most likely some consumers will require

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.