Meta Languages Flashcards
1
Q
What is recursion in BNF and when is it used?
A
Recursion is the referencing of a rule within the rule itself, allowing for infinite possibilities. Recursion should be used when both an unknown number, greater than 1 is required.
2
Q
Given the following BNF:
::= procedure ( )
::= | ;
::= : |
ref :
::= | ,
::= |
::= int | float | bool | char | string
Would the following inputs be valid?
1 - parameter - ref health, lives, points, deaths : int
2 - identifier - Michael1sth3b3st
3 - procedure-def - procedure 2ndlife(points:int,lives:int)
A
1 - Valid
2 - Invalid (contains numbers, which are no supported in the BNF given)
3 - Invalid (parameters should be delimited with a ; not a ,)