X-Git-Url: https://code.kerkeslager.com/?p=fur;a=blobdiff_plain;f=transformation.py;h=ef4e9bf4a5db3484b1d95fd2f81d29e3e14f2f8a;hp=9ba0c0a2027cd38b0df12c28144c028007558f0f;hb=c40954b865b48ffa4993f735d56213fb91c3e90e;hpb=2b8b0fd7071b4a829253e7564289aa179b9a47d9 diff --git a/transformation.py b/transformation.py index 9ba0c0a..ef4e9bf 100644 --- a/transformation.py +++ b/transformation.py @@ -2,6 +2,13 @@ import collections import parsing +CIntegerLiteral = collections.namedtuple( + 'CIntegerLiteral', + [ + 'value', + ], +) + CStringLiteral = collections.namedtuple( 'CStringLiteral', [ @@ -31,10 +38,10 @@ BUILTINS = { } def transform_argument(builtin_dependencies, argument): - if isinstance(argument, parsing.StringLiteral): - return CStringLiteral(value=argument.value) - - raise Exception() + return { + parsing.IntegerLiteral: CIntegerLiteral, + parsing.StringLiteral: CStringLiteral, + }[type(argument)](value=argument.value) def transform_function_call_statement(builtin_dependencies, function_call): if function_call.name in BUILTINS.keys():