The following EBNF rules describe the syntax of binary liter
The following EBNF rules describe the syntax of binary literals in Java. Write a single Perl pattern that matches these constants. Simplify your pattern as much as possible, using only the Perl features discussed in class. BinaryNumeral: 0 b BinaryDigits 0 b BinaryDigits BinaryDigits: Binary Digit BinaryDigit BinaryDigitsAndUnderscoresopi BinaryDigit BinaryDigit: one of 0 1 Binary DigitsAndUnderscores: Binary DigitOrUnderscore BinaryDigitsAndUnderscores BinaryDigitOrUnderscore
Solution
public static void main(string,[]args)
public method(int a, int b)
<&various code&>
codeblock = \"<&\" {ANY} \"&>\"
nonZeroDigit = \"123456789\".
digit = \'0\' + nonZeroDigit .
letter = \'A\' .. \'Z\' + \'a\' .. \'z\' + \'_\' + \'$\'.
TOKENS
ident = letter { letter | digit }.
PRODUCTIONS JavaLike = {ClassDeclaration}.
ClassDeclaration =\"class\" ident [\"extends\" ident] \"{\" {VarDeclaration} {MethodDeclaration }\"}\"
. MethodDeclaration =\"public\" Type ident \"(\"ParamList\")\"
. Codeblock = \"<&\" {ANY} \"&>\".
if (Peek() == CODE_START)
{
while (NextToken() != CODE_END
{
}
}
