Filbert provides the basics of Python, suitable for playing CodeCombat. Additionally, it provides a strong foundation for adding more advanced Python language features in the future.
I chose Python because it is the most useful language to add to CodeCombat. It is very common in both industry and as an introductory programming language.
And, I could provide a basic implementation suitable for beginners in the time allowed.
Leveraging a mature parser allowed me to focus more on Python language features, and less on tokenizing and AST generation. It also got us Python parseDammit at low cost, and a strong framework for adding additional Python language features in the future.
My goal was to implement the most useful parts of Python for the purpose of playing CodeCombat levels. For example, I punted regular expressions and advanced string operations in favor of classes, tuples, and more built-in function support.
False None True and break class continue def elif else for if in is not or pass return while
abs() all() any() bool() chr() dict() enumerate() filter() float() hex() int() len() list() map() max() min() oct() ord() pow() print() range() repr() reversed() round() sorted() str() sum() tuple()
Operator precedence and basic scoping rules are also working.
- Remaining keywords and built-ins
- More advanced features, such as slices and list comprehensions
The original source node range info is preserved in the AST nodes, via the ranges or locations properties. Ranges provides a ‘range’ array property, and ‘locations’ provides a ‘loc’ line/column object on the nodes.
Filbert has been successfully integrated into CodeCombat, and players can use Python to play through the levels.
This challenge has been a lot of fun, and it’s exciting to see so many languages being added to CodeCombat.