git-afsantos / bonsai

Simplified interface for syntax trees and program models.
MIT License
16 stars 8 forks source link

Feature/literals #4

Closed davla closed 6 years ago

davla commented 6 years ago

I added CodeLiteral to the bonsai model, to represent literals that cannot be handled by basic Python types.

It comes in handy when describing None values, so that Python Nones in the parsed files are not mixed with Nones in the bonsai AST, with catastrophic outcomes. This has been implemented by the class CodeNull.

Another handy use is to describe composite literals, as seen in the class CodeCompositeLiteral. While it could be replaced by a plain Python list (an element for each item in the composite literal), its result attribute makes for more reusable code in cases where, like Python, more than one type of composite literal exist (tuples, lists, dictionaries...).

It is already used in the branch davla:feature/py-parser

git-afsantos commented 6 years ago

Sorry for the delay. I just went through the changes, and it seems good to go. :+1: