Here you can see a few examples of valid Abstract Syntax Trees in BSL Core Language.
(cond [e1 #t]
[else (asBool e2)])
(define (f x y) (+ x y))
(define-struct name (firstName lastName))
Given is the following Grammar:
"grammar": {
"<FavouriteNumber>": ["<RoundedNumber>", "<Mystery>"],
"<RoundedNumber>": ["0", "3", "6", "8", "9"],
"<Mystery>": ["<Pair>+", "7"],
"<Pair>": ["<RoundedNumber><RoundedNumber>"],
}
We can also make quizzes based on this custom Grammar. For example, why is 68087 a FavouriteNumber?
{
"grammar": {
"FavouriteNumber": ["RoundedNumber", "Mystery"],
"RoundedNumber": ["0", "3", "6", "8", "9"],
"Mystery": ["Pair+7"],
"Pair": ["RoundedNumberRoundedNumber"]
},
"production": "FavouriteNumber",
"code": "|68087|",
"holes": [{
"production": "Mystery",
"code": "|6808|7",
"holes": [{
"production": "Pair+",
"code": "|68||08|",
"holes": [{
"production": "Pair",
"code": "|6||8|",
"holes": [{
"production": "RoundedNumber",
"code": "6"
},
{
"production": "RoundedNumber",
"code": "8"
}
]
},
{
"production": "Pair",
"code": "|0||8|",
"holes": [{
"production": "RoundedNumber",
"code": "0"
},
{
"production": "RoundedNumber",
"code": "8"
}
]
}
]
}]
}]
}