Hello. I'm taking subject compiler construction. and there is a question and the answer that i don't anderstand.

if it was digit -> [0 - 9] then it would be ->0->1->2->3->4->5->6->7->8->9 final state

digits -> digit+ then it would be ->digit->digit->digit loop final state

but this question i dont understand the solution:
write a transition diagram for scientific number

number → digits (. digits)?(E[+-]? digits)?

the answer:


my question:

why is there a loop before the period? The dot . between 13 and 14, does the period mean something?

why is there a loop at 15? is it because of the question mark? question mark means zero or one

then after the +- I am so lost. as well as the "other" 's and keene star on the "other" 's

why is it looped at 18 not 17 ?

i'm also lost on the bottom arrows. 13 -> 16, 16 -> 18

Sorry for the questions and if the questions really stupid. my lecturer is like a f1 car in class.

7 Months
Discussion Span
Last Post by rubberman
  1. The dot . between 13 and 14, does the period mean something?
    To me it means the same thing it has forever in numbers. 14.5 is 14 whole things and the .5 is the fraction. So to me it's simply how we represent other than whole numbers.

  2. number → digits (. digits)?(E[+-]? digits)?
    The question marks there are to convey the number of digits is variable so you have to deal with the number of digits being 0 to many.

  3. I wish they changed "scientific number" to "a number presented in scientific notation."

Edited by rproffitt


I think that you can consider the ? to be the same as 'then'. IE, 1.45, then E+1, ... Remember, E is the power of 10 that is applied to the number. So, 1.45E+1 == 14.5. Clear as mud yet?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.