0
$\begingroup$

number -> digits(.digits)?(E[+ -]?digits)? This transition diagram runs the above mentioned token I can not understand this how this is work.what is meaning of "?"Symbol and digits. can anyone explain me this

enter image description here

$\endgroup$
0
0
$\begingroup$

digits(.digits)?(E[+ -]?digits)? is a regular expression for the set of strings that the pictured automaton accepts. That is, all of the strings accepted by the automaton will match this pattern. If you're unfamiliar with regular expression syntax, you can check out this explanation from Wikipedia.

In particular, if you see some pattern followed by the ? operator, it means that pattern is optional. So something like digits(.digits)? will match strings of the form digits.digits or just digits because the last (.digits) part is optional.

I would guess that digits is a placeholder for a series of numeric digits (0-9). So something like digits(.digits)? would match strings like "33.5", "0.8", "1.892", "7", etc.

$\endgroup$
2
  • $\begingroup$ digits should be a placeholder for consecutive numeric digits (the plural form of digit). $\endgroup$ – John L. Nov 30 '18 at 7:11
  • $\begingroup$ @Apass.Jack ah thanks, nice catch! Edited to fix $\endgroup$ – roctothorpe Nov 30 '18 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.