add *comments* and TEST MY SHI
This commit is contained in:
parent
668f597b48
commit
76fc6d8d11
@ -4,6 +4,7 @@ project(xlang
|
||||
DESCRIPTION "XLANG Compiler")
|
||||
|
||||
enable_language(CXX)
|
||||
enable_testing()
|
||||
set(CMAKE_CXX_COMPILER /bin/clang++)
|
||||
set(CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++${CXX_STANDARD}")
|
||||
@ -21,3 +22,9 @@ add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
)
|
||||
|
||||
add_test(NAME CompactSourceAll COMMAND ${PROJECT_NAME} ../examples/compact/exitall.x)
|
||||
add_test(NAME TestOutputBinary COMMAND ${CMAKE_COMMAND}
|
||||
-DTEST_EXECUTABLE=./out
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_exit_9.cmake)
|
||||
set_tests_properties(TestOutputBinary PROPERTIES DEPENDS CompactSourceAll)
|
||||
10
check_exit_9.cmake
Normal file
10
check_exit_9.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
execute_process(
|
||||
COMMAND ${TEST_EXECUTABLE} ${TEST_ARGS}
|
||||
RESULT_VARIABLE EXIT_CODE
|
||||
)
|
||||
|
||||
message(STATUS "Test exited with code: ${EXIT_CODE}")
|
||||
|
||||
if(NOT EXIT_CODE EQUAL 9)
|
||||
message(FATAL_ERROR "Expected exit code 9, but got ${EXIT_CODE}")
|
||||
endif()
|
||||
@ -5,7 +5,7 @@ var x = 1 + 2 * 3;
|
||||
}
|
||||
var y = x - 3;
|
||||
var z = (3 * 5) / 3;
|
||||
if (x) {
|
||||
if (x ) {
|
||||
exit(y + z);
|
||||
}
|
||||
exit (1); // Should never exit
|
||||
exit (1);
|
||||
@ -83,6 +83,12 @@ public:
|
||||
}
|
||||
tokens.push_back({.type = TokenType::int_lit, .value = buffer});
|
||||
buffer.clear();
|
||||
} else if (peek().value() == '/' && peek(1).has_value() && peek(1).value() == '/') {
|
||||
consume();
|
||||
consume();
|
||||
while (peek().has_value() && peek().value() != '\n') {
|
||||
consume();
|
||||
}
|
||||
} else if (std::isspace(peek().value())) {
|
||||
consume();
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user