Tuesday, May 9, 2017

Jack Grammar - Only Rules Support * and ? - Not Primitives

After coding, I had to use Excel to see this - rather than comb through my text. The power of visualization..

Part of it is doing a rule using a formula : (in the box, type)

=AND( ISNUMBER(B2), B2 > 1 )

class
1
1
1
3
3
1
class
 keyword
 identifier
 symbol
 rule
 rule
 symbol
classVarDec
1
1
1
3
1
classVarDec
 keyword
 rule
 identifier
 rule
 symbol
addlVarDec
1
1
addlVarDec
 symbol
 identifier
type
1
type
 keyword||identifier
subroutineDec
1
1
1
1
1
1
1
subroutineDec
 keyword
 keyword||rule
 identifier
 symbol
 rule
 symbol
 rule
parameterList
2
parameterList
 rule
params
1
3
params
 rule
 rule
param
1
1
param
 rule
 identifier
addlParam
1
1
addlParam
 symbol
 identifier
subroutineBody
1
3
1
1
subroutineBody
 symbol
 rule
 rule
 symbol
varDec
1
1
1
3
1
varDec
 keyword
 rule
 identifier
 rule
 symbol
statements
3
statements
 rule
statement
1
statement
 rule
letStatement
1
1
2
1
1
1
letStatement
 keyword
 identifier
 rule
 symbol
 rule
 symbol
index
1
1
1
index
 symbol
 rule
 symbol
ifStatement
1
1
1
1
1
1
1
2
ifStatement
 keyword
 symbol
 rule
 symbol
 symbol
 rule
 symbol
 rule
elseBlock
1
1
1
1
elseBlock
 keyword
 symbol
 rule
 symbol
whileStatement
1
 expression
 )
1
1
1
whileStatement
 keyword
 symbol
 rule
 symbol
 symbol
 rule
 symbol
doStatement
1
1
1
doStatement
 keyword
 rule
 symbol
returnStatement
1
2
1
returnStatement
 keyword
 rule
 symbol
expression
1
3
expression
 rule
 rule
subExp
1
1
subExp
 symbol
 rule
term
1
term
 rule
constant
1
constant
 integerConstant||stringConstant
arrayElem
1
1
1
1
arrayElem
 rule
 symbol
 rule
 symbol
paranthExp
1
1
paranthExp
 symbol
 rule
 symbol
unOpTerm
1
1
unOpTerm
 symbol
 rule
subroutineCall
1
subroutineCall
 rule
simpleCall
1
1
1
1
simpleCall
 identifier
 symbol
 rule
 symbol
classMethCall
1
1
1
1
1
1
classMethCall
 identifier
 symbol
 identifier
 symbol
 rule
 symbol
expressionList
2
expressionList
 rule
expressions
1
3
expressions
 rule
 rule
addlExpr
1
1
addlExpr
 symbol
 rule
keywordConstant
 true|false|null|this
keywordConstant
 keyword


No comments:

Post a Comment