Lalr parser - xml table output, Programming Languages

Assignment Help:

LALR Parser:

Rule Table - Contains definitions of production rules within the grammar.

Attributes:

  • Count - Number of production rules in the table

Child items:

  • Rule

Rule - Defines a given production rule in the grammar.  Each production rule has a Left Hand Side (LHS) which is a single non-terminal) and a Right Hand Side (RHS), which can be a mix of terminals and non-terminals.  This structure can be used to determine how many and which symbols to pop off the parser stack during a reduction.  The LHS symbol must be placed on the parser stack to complete the rule reduction.

Attributes:

  • Index - Unique identifier of rule in the rule table
  • NonTerminalIndex - Provides the index for the non-terminal symbol (LHS) in the symbol table.
  • Symbol Count - number of symbols in the RHS of the production

Child items:

  • Rule Symbol

Rule Symbol - Defines a terminal or non-terminal in the RHS of the rule.  Symbols are listed in order of appearance on the RHS (from leftmost to rightmost). 

Attributes:

  • SymbolIndex - Provides the index into the symbol table for the particular symbol on the RHS of the production

LALR Table - This structure represents the LALR parse table.  Recall from class that the LALR table has symbols (terminals and non-terminals) on its X-Axis and LALR states on its Y-Axis (refer to class slides).  This table is defined in terms of states, which call out the appropriate symbols that are applicable to that state.

Attributes:

  • Count - Total number of LALR states in the table
  • Initial State - Start state for the parser (nominally state 0)

Child items:

  • LALR State

LALR State - This item defines a given state in the LALR parse table.  Each state is mapped to one or more symbols.  For each mapping, an action is specified (shift, reduce, goto, or accept).  If a state does not reference a symbol, then no action is specified when the parser is in that state and the symbol is at the front of the input queue-in short, this is a parser error.

Attributes:

  • Index - State number within the table
  • Action count - Number of actions associated with a given state (at least one)

Child items:

  • LALR Action

LALR Action - This item defines the action for a given state-symbol pair.  Since the LALR Action is a child of LALR State, all listed actions are associated with the parent state.  Each pair will have a single mapping associated with it of type:  shift, reduce, goto, or accept. 

Attributes:

  • SymbolIndex - The index of the symbol mapped to the LALR state for this action.
  • Action - The type of action being accomplished.  Actions:  1- Shift, 2- Reduce, 3 - Goto, 4 - Accept.
  • Value - The meaning of this value is dependent on the action type.  For a shift or goto action, the value refers to the next LALR state.  For a reduce action, the value refers to the rule index in the Rule Table.  For an accept action, the value is meaningless (nominally 0) as it ends the parsing process for a given statement.

 

 

 

Best Programming Strategy:

  • Mimic the GPB XML structure
  • Implement each structure that has items as an array of objects

 

 


Related Discussions:- Lalr parser - xml table output

Linux commans, Corrected Exercise #1: 1. Explain the following unexpected r...

Corrected Exercise #1: 1. Explain the following unexpected result: why did you get the system date command instead of the script? $ whereis date date: /bin/date ... $ echo $PATH

Ajax and php, would you like to see some of my code. I am trying to do an a...

would you like to see some of my code. I am trying to do an add friend request. when I view my friends page I click on the add button. with ajax I want the script to send over the

Application for a mid , The assignment has two parts: first you generate a ...

The assignment has two parts: first you generate a simple application for a MID that operates independently of other MIDs. As a second part, the application is extended to keep so

Write an application to assign seats for each flight, ( Airline Reservation...

( Airline Reservations System ) A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to w

C programming, Write an interactive C program which prompts the user with t...

Write an interactive C program which prompts the user with the following options on the opening menu: 1) Student information 2) Theory counselling batch-scheduling

Software application, Does anyone know anything about java programming here...

Does anyone know anything about java programming here?

ARM LANGUAGE, I WANT TO MAKE PROJECT IN ARM LANGUAGE CAN YOU HELP ME

I WANT TO MAKE PROJECT IN ARM LANGUAGE CAN YOU HELP ME

Implement a lunar lander simulation, 1. Modify your solution to #8 so that ...

1. Modify your solution to #8 so that if an ellipse is touched by the mouse, it turns permanently green.Bonus (up to +5): a green ellipse stops moving, but recovers after 5 seconds

Design and construct a basic math program, For this assignment you will nee...

For this assignment you will need to design and construct a basic math program which targets elementary school children. Your program must adhere to the following steps and require

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd