programming4us
programming4us
DESKTOP

Algorithms for Compiler Design: DATA STRUCTURES FOR REPRESENTING PARSING TABLES

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
7/24/2010 7:48:52 PM
5.5 DATA STRUCTURES FOR REPRESENTING PARSING TABLES
Since there are only a few entries in the goto table, separate data structures must be used for the action table and the goto table. These data structures are described below.

Representing the Action Table

One of the simplest ways to represent the action table is to use a two-dimensional array. But since many rows of the action table are identical, we can save considerable space (and expend a negligible cost in processing time) by creating an array of pointers for each state. Then, pointers for states with the same actions will point to the same location, as shown in Figure 1.

Click To expand
Figure 1: States with actions in common point to the same location via an array.

To access information, we assign each terminal a number from zero to one less than the number of terminals. We use this integer as an offset from the pointer value for each state. Further reduction in the space is possible at the expense of speed by creating a list of actions for each state. Each node on a list will be comprised of a terminal symbol and the action for that terminal symbol. It is here that the most frequent actions, like error actions, can be appended at the end of the list.

Click To expand
Figure 2: List that incorporates the ability to append actions.

Representing the GOTO Table

An efficient way to represent the goto table is to make a list of pairs for each nonterminal A. Each pair is of the form:

  • goto(current-state, A) = next-state

Since the error entries in the goto table are never consulted, we can replace each error entry by the most common nonerror entry in its column is represented by any in place of current-state.


Other  
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us
programming4us
 
 
programming4us