From c272a8d045fa1c342757d1d655233e803a0f9be3 Mon Sep 17 00:00:00 2001 From: rigved-desai <109571041+rigved-desai@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:28:11 +0530 Subject: [PATCH] Implement tokens for unsigned int and double data types (#68) * feat: Implement tokens for unsigned int and double data types. * chore: Add test for data type tokenization * feat: Refactor unsigned int to uint after review and edit tests for same --- crosstl/src/translator/lexer.py | 2 ++ tests/test_translator/test_lexer.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/crosstl/src/translator/lexer.py b/crosstl/src/translator/lexer.py index 5d5afd97..904da4fa 100644 --- a/crosstl/src/translator/lexer.py +++ b/crosstl/src/translator/lexer.py @@ -17,6 +17,8 @@ ("FLOAT_NUMBER", r"\d*\.\d+|\d+\.\d*"), ("FLOAT", r"\bfloat\b"), ("INT", r"\bint\b"), + ("UINT", r"\buint\b"), + ("DOUBLE", r"\bdouble\b"), ("SAMPLER2D", r"\bsampler2D\b"), ("IDENTIFIER", r"[a-zA-Z_][a-zA-Z_0-9]*"), ("NUMBER", r"\d+(\.\d+)?"), diff --git a/tests/test_translator/test_lexer.py b/tests/test_translator/test_lexer.py index 0fa3f2cc..fa217442 100644 --- a/tests/test_translator/test_lexer.py +++ b/tests/test_translator/test_lexer.py @@ -99,3 +99,17 @@ def test_function_call_tokenization(): tokenize_code(code) except SyntaxError: pytest.fail("Function call tokenization not implemented.") + + +def test_data_types_tokenization(): + code = """ + int a; + uint b; + float c; + double d; + bool e; + """ + try: + tokenize_code(code) + except SyntaxError: + pytest.fail("Data types tokenization not implemented.")