Skip to content

Commit 007d0b9

Browse files
committed
Initial commit.
1 parent 36af437 commit 007d0b9

File tree

252 files changed

+110820
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+110820
-0
lines changed

.clang-format

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Generated from CLion C/C++ Code Style settings
2+
BasedOnStyle: LLVM
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveAssignments: false
6+
AlignEscapedNewlines: Left
7+
AlignOperands: Align
8+
AllowAllArgumentsOnNextLine: false
9+
AllowAllConstructorInitializersOnNextLine: false
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: Empty
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: InlineOnly
14+
AllowShortIfStatementsOnASingleLine: Never
15+
AllowShortLambdasOnASingleLine: All
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakTemplateDeclarations: Yes
19+
BinPackArguments: false
20+
BinPackParameters: false
21+
BreakBeforeBraces: Custom
22+
BraceWrapping:
23+
AfterCaseLabel: false
24+
AfterClass: true
25+
AfterControlStatement: Never
26+
AfterEnum: true
27+
AfterFunction: true
28+
AfterNamespace: false
29+
AfterUnion: true
30+
BeforeCatch: false
31+
BeforeElse: false
32+
IndentBraces: false
33+
SplitEmptyFunction: false
34+
SplitEmptyRecord: true
35+
BreakBeforeBinaryOperators: None
36+
BreakBeforeTernaryOperators: true
37+
BreakConstructorInitializers: BeforeColon
38+
BreakInheritanceList: BeforeColon
39+
ColumnLimit: 120
40+
CompactNamespaces: false
41+
ContinuationIndentWidth: 4
42+
IncludeBlocks: Regroup
43+
IncludeCategories:
44+
- Regex: '^<(ps)/'
45+
Priority: 2
46+
SortPriority: 2
47+
- Regex: '^<(jgp)/'
48+
Priority: 3
49+
SortPriority: 3
50+
- Regex: '^<(SDL_)|(lua)'
51+
Priority: 4
52+
SortPriority: 4
53+
IndentCaseLabels: true
54+
IndentPPDirectives: BeforeHash
55+
IndentWidth: 4
56+
KeepEmptyLinesAtTheStartOfBlocks: true
57+
MacroBlockBegin: (PS_LUA_NEW_LIB)|(PS_LUA_NEW_FN_LIST)|(PS_LUA_NEW_METATABLE)
58+
MacroBlockEnd: (PS_LUA_END_LIB)|(PS_LUA_END_FN_LIST)|(PS_LUA_END_METATABLE)
59+
MaxEmptyLinesToKeep: 1
60+
NamespaceIndentation: None
61+
FixNamespaceComments: true
62+
ObjCSpaceAfterProperty: false
63+
ObjCSpaceBeforeProtocolList: true
64+
PointerAlignment: Left
65+
ReflowComments: true
66+
SortIncludes: CaseInsensitive
67+
SpaceAfterCStyleCast: false
68+
SpaceAfterLogicalNot: false
69+
SpaceAfterTemplateKeyword: true
70+
SpaceBeforeAssignmentOperators: true
71+
SpaceBeforeCpp11BracedList: true
72+
SpaceBeforeCtorInitializerColon: true
73+
SpaceBeforeInheritanceColon: true
74+
SpaceBeforeParens: ControlStatements
75+
SpaceBeforeRangeBasedForLoopColon: true
76+
SpaceInEmptyParentheses: false
77+
SpacesBeforeTrailingComments: 1
78+
SpacesInAngles: false
79+
SpacesInCStyleCastParentheses: false
80+
SpacesInContainerLiterals: true
81+
SpacesInParentheses: false
82+
SpacesInSquareBrackets: false
83+
TabWidth: 4
84+
UseTab: ForContinuationAndIndentation

.clang-tidy

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
Checks: 'clang-diagnostic-*,clang-analyzer-*,performance-*,-clang-diagnostic-c++98-compat,-clang-diagnostic-c++98-compat-local-type-template-args,-clang-diagnostic-c++98-compat-pedantic,-clang-diagnostic-c++98-compat-extra-semi,-clang-diagnostic-pre-c++14-compat,-clang-diagnostic-pre-c++17-compat,-clang-diagnostic-pre-c++20-compat-pedantic,-clang-diagnostic-shadow-field-in-constructor,-clang-diagnostic-missing-prototypes,-clang-diagnostic-old-style-cast,-clang-diagnostic-undefined-func-template,-clang-diagnostic-covered-switch-default,-clang-diagnostic-exit-time-destructors,-clang-diagnostic-global-constructors,-clang-analyzer-valist.Uninitialized,-clang-diagnostic-zero-as-null-pointer-constant,-clang-diagnostic-pragma-pack,-clang-analyzer-core.CallAndMessage'
3+
WarningsAsErrors: ''
4+
HeaderFilterRegex: ''
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: file
7+
User: Paul
8+
CheckOptions:
9+
- key: llvm-else-after-return.WarnOnConditionVariables
10+
value: 'false'
11+
- key: modernize-loop-convert.MinConfidence
12+
value: reasonable
13+
- key: modernize-replace-auto-ptr.IncludeStyle
14+
value: llvm
15+
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
16+
value: 'false'
17+
- key: google-readability-namespace-comments.ShortNamespaceLines
18+
value: '10'
19+
- key: cert-err33-c.CheckedFunctions
20+
value: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
21+
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
22+
value: 'false'
23+
- key: cert-dcl16-c.NewSuffixes
24+
value: 'L;LL;LU;LLU'
25+
- key: google-readability-braces-around-statements.ShortStatementLines
26+
value: '1'
27+
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
28+
value: 'true'
29+
- key: google-readability-namespace-comments.SpacesBeforeComments
30+
value: '2'
31+
- key: modernize-loop-convert.MaxCopySize
32+
value: '16'
33+
- key: modernize-pass-by-value.IncludeStyle
34+
value: llvm
35+
- key: modernize-use-nullptr.NullMacros
36+
value: 'NULL'
37+
- key: llvm-qualified-auto.AddConstToQualified
38+
value: 'false'
39+
- key: modernize-loop-convert.NamingStyle
40+
value: CamelCase
41+
- key: llvm-else-after-return.WarnOnUnfixable
42+
value: 'false'
43+
- key: google-readability-function-size.StatementThreshold
44+
value: '800'
45+
...
46+

CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.26)
2+
project(cxxlox)
3+
4+
set(CMAKE_CXX_STANDARD 20)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
8+
if (CMAKE_CONFIGURATION_TYPES)
9+
set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo;Release" CACHE STRING "" FORCE)
10+
endif (CMAKE_CONFIGURATION_TYPES)
11+
12+
# Use a vendored version of GoogleTest to provide everything out of the box.
13+
add_subdirectory(vendor/googletest-1.14.0)
14+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
15+
16+
add_subdirectory(tests)
17+
18+
add_executable(cxxlox main.cpp)
19+
20+
# Provides a command to run all tests, since CLion can't do that on it's own.
21+
# https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests#736838
22+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
23+
24+
# check-iterate is the target to use when iterating when using tests,
25+
# such as TDD's red->green pattern.
26+
add_custom_target(check-iterate COMMAND ${CMAKE_CTEST_COMMAND} -V --rerun-failed -C $<CONFIG>)
27+
28+
enable_testing()

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# C++ Lox Bytecode Virtual Machine
2+
3+
A C++ implementation of the bytecode interpreter from "Crafting Interpreters"
4+
by Robert Nystrom.

main.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
3+
int main() {
4+
std::cout << "Hello, World!" << std::endl;
5+
return 0;
6+
}

tests/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GoogleTest help: https://google.github.io/googletest/quickstart-cmake.html
2+
3+
include(GoogleTest)
4+
5+
add_executable(example_tests
6+
example_tests.cpp
7+
)
8+
target_link_libraries(example_tests GTest::gtest_main)
9+
gtest_discover_tests(example_tests)

tests/example_tests.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <gtest/gtest.h>
2+
3+
TEST(Example, Example)
4+
{
5+
ASSERT_EQ(false, false);
6+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Run manually to reformat a file:
2+
# clang-format -i --style=file <file>
3+
Language: Cpp
4+
BasedOnStyle: Google
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bug Report
2+
description: Let us know that something does not work as expected.
3+
title: "[Bug]: Please title this bug report"
4+
body:
5+
- type: textarea
6+
id: what-happened
7+
attributes:
8+
label: Describe the issue
9+
description: What happened, and what did you expect to happen?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: steps
14+
attributes:
15+
label: Steps to reproduce the problem
16+
description: It is important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful.
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: version
21+
attributes:
22+
label: What version of GoogleTest are you using?
23+
description: Please include the output of `git rev-parse HEAD` or the GoogleTest release version number that you are using.
24+
validations:
25+
required: true
26+
- type: textarea
27+
id: os
28+
attributes:
29+
label: What operating system and version are you using?
30+
description: If you are using a Linux distribution please include the name and version of the distribution as well.
31+
validations:
32+
required: true
33+
- type: textarea
34+
id: compiler
35+
attributes:
36+
label: What compiler and version are you using?
37+
description: Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler.
38+
validations:
39+
required: true
40+
- type: textarea
41+
id: buildsystem
42+
attributes:
43+
label: What build system are you using?
44+
description: Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system.
45+
validations:
46+
required: true
47+
- type: textarea
48+
id: additional
49+
attributes:
50+
label: Additional context
51+
description: Add any other context about the problem here.
52+
validations:
53+
required: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Feature request
2+
description: Propose a new feature.
3+
title: "[FR]: Please title this feature request"
4+
labels: "enhancement"
5+
body:
6+
- type: textarea
7+
id: version
8+
attributes:
9+
label: Does the feature exist in the most recent commit?
10+
description: We recommend using the latest commit from GitHub in your projects.
11+
validations:
12+
required: true
13+
- type: textarea
14+
id: why
15+
attributes:
16+
label: Why do we need this feature?
17+
description: Ideally, explain why a combination of existing features cannot be used instead.
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: proposal
22+
attributes:
23+
label: Describe the proposal.
24+
description: Include a detailed description of the feature, with usage examples.
25+
validations:
26+
required: true
27+
- type: textarea
28+
id: platform
29+
attributes:
30+
label: Is the feature specific to an operating system, compiler, or build system version?
31+
description: If it is, please specify which versions.
32+
validations:
33+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Get Help
4+
url: https://github.com/google/googletest/discussions
5+
about: Please ask and answer questions here.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
BAZEL_CXXOPTS: -std=c++14
9+
10+
jobs:
11+
Linux:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Tests
20+
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ...
21+
22+
macOS:
23+
runs-on: macos-latest
24+
steps:
25+
26+
- uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Tests
31+
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ...
32+
33+
34+
Windows:
35+
runs-on: windows-latest
36+
steps:
37+
38+
- uses: actions/checkout@v3
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Tests
43+
run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ...

0 commit comments

Comments
 (0)