Author Topic: Questions relating to 'Introduction to Compilers' class  (Read 4538 times)

KK20

• Master Scripter Fixer
• Global Moderator
• Guardian of Chaos
• Posts: 3143
• LV: 378
• Gender:
• Choco Octo <3
Questions relating to 'Introduction to Compilers' class
« on: June 08, 2013, 09:18:08 AM »
I may have some more questions regarding this class I am taking right now, so I'll be making a thread just to make sure.

Anyways, my friend discovered in the course text a possible error. It says that the regular expression for a legal floating-point constant in Pascal is as follows:

(ε|+|-)(0|d*).(0|d*)

ε = null character
d = 0..9
The text says this ensures that a number exists on both the left and right sides of the decimal point. But how can that be?

If I choose ε and d* in both instances and set them to have zero repetitions, that would leave me with only the decimal point (from what I saw, this caused an error in Pascal).

Thus, I proposed this:

(ε|+|-)((d+.d*)|(d*.d+))

This ensures that we have at least one digit on the left or right sides of the decimal, right? Is there a better way to do this?

 Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Blizzard

• This sexy
• has over 9000 posts
• Posts: 19985
• LV: 648
• Gender:
• Magic midgets.
Re: Questions relating to 'Introduction to Compilers' class
« Reply #1 on: June 08, 2013, 10:07:18 AM »
I agree, the first one seems like it's possible to just get a dot character and your regular expression seems to solve that problem.
Check out Daygames and our games:

 King of Booze King of Booze: Never Ever Pet Bots Drinking Game for Android Never have I ever for Android Pet Bots for Android Drinking Game for iOS Never have I ever for iOS Pet Bots for iOS Drinking Game on Steam

Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson

KK20

• Master Scripter Fixer
• Global Moderator
• Guardian of Chaos
• Posts: 3143
• LV: 378
• Gender:
• Choco Octo <3
Re: Questions relating to 'Introduction to Compilers' class
« Reply #2 on: June 09, 2013, 09:29:30 AM »
Cool, thanks for the confirmation. It looks like we have something to address to the teacher, seeing as this is an instructor's text.

No other problems found so far. Got the DFSM for the lexer working. And they said it would take 20 hours to do... (half my time was spent figuring out how to use C++ again )

 Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

KK20

• Master Scripter Fixer
• Global Moderator
• Guardian of Chaos
• Posts: 3143
• LV: 378
• Gender:
• Choco Octo <3
Re: Questions relating to 'Introduction to Compilers' class
« Reply #3 on: June 13, 2013, 11:10:12 PM »
Bleh, that was a brutal first exam. Here are two questions I struggled with:

1.) Given that the alphabet is {a,b}, write a regular expression that contains all the strings that have exactly 2 a's and at least 1 b.
(click to show/hide)

2.) Remove left recursion and backtracking in the following grammar:
Code: [Select]
`X -> XaY | XbYX -> YY -> YcBY -> a | BB -> X`

 Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!