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:

http://imgur.com/a/98551

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.

  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."

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.