Computer Science, asked by Riyana602, 7 months ago

4. Generate the 10 smallest possible strings using the following rule base. If a word doesn’t
have a described rule treat it as a TERMINAL SYMBOL and count it as ONE CHARACTER.
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block
Condition = Expression
RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ]
InitStmt = SimpleStmt
PostStmt = SimpleStmt
SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl
Expression = UnaryExpr | Expression binary_op Expression
UnaryExpr = PrimaryExpr | unary_op UnaryExpr
binary_op = "||" | "&&" | rel_op | add_op | mul_op
unary_op = "+" | "-" | "!" | "ˆ" | "*" | "&" | "<-"
Block = "{" StatementList "}"
StatementList = { Statement ";" }
IdentifierList = identifier { "," identifier }
ExpressionList = Expression { "," Expression }

Answers

Answered by anwithuliyay115
0

Generate the 10 smallest possible strings using the following rule base. If a word doesn’t

have a described rule treat it as a TERMINAL SYMBOL and count it as ONE CHARACTER.

ForStmt = "for" [ Condition | ForClause | RangeClause ] Block

Condition = Expression

RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression

ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ]

InitStmt = SimpleStmt

PostStmt = SimpleStmt

SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl

Expression = UnaryExpr | Expression binary_op Expression

UnaryExpr = PrimaryExpr | unary_op UnaryExpr

binary_op = "||" | "&&" | rel_op | add_op | mul_op

unary_op = "+" | "-" | "!" | "ˆ" | "*" | "&" | "<-"

Block = "{" StatementList "}"

StatementList = { Statement ";" }

IdentifierList = identifier { "," identifier }

ExpressionList = Expression { "," Expression }

Similar questions