Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BasedOnStyle: LLVM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting largely follows our existing codebase but can be altered as per needs.

AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: LeftWithLastLine
AlignTrailingComments: Leave
AllowShortCaseExpressionOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
BreakAfterReturnType: ExceptShortType
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
BraceWrapping:
AfterCaseLabel: true
AfterFunction: true
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterNamespace: false
BeforeElse: true
IndentBraces: false
ColumnLimit: 80
Cpp11BracedListStyle: False
IndentCaseLabels: false
IndentCaseBlocks: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
PointerAlignment: Left
ReflowComments: IndentOnly
SpaceInEmptyBlock: true
SpacesBeforeTrailingComments: 3
12 changes: 12 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Checks: >
-*,
bugprone-*,
modernize-use-override,
clang-analyzer-*,
-bugprone-easily-swappable-parameters,
-clang-diagnostic-error,
-clang-analyzer-cplusplus.NewDelete,

WarningsAsErrors: '' # keep warnings first, promote to errors later
HeaderFilterRegex: 'src/.*'
FormatStyle: none
33 changes: 10 additions & 23 deletions ASTNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,19 @@ void ASTNodeList::removeFirst()
m_nodes.erase(m_nodes.begin());
}


/* ASTUnary */
const char* ASTUnary::op_str() const
{
static const char* s_op_strings[] = {
"+", "-", "~", "not "
};
static const char* s_op_strings[] = { "+", "-", "~", "not " };
return s_op_strings[op()];
}


/* ASTBinary */
const char* ASTBinary::op_str() const
{
static const char* s_op_strings[] = {
".", " ** ", " * ", " / ", " // ", " % ", " + ", " - ",
" << ", " >> ", " & ", " ^ ", " | ", " and ", " or ", " @ ",
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
static const char* s_op_strings[] = { ".", " ** ", " * ", " / ", " // ",
" % ", " + ", " - ", " << ", " >> ", " & ", " ^ ", " | ", " and ",
" or ", " @ ", " += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
" >>= ", " &= ", " ^= ", " |= ", " //= ", " @= ", " <INVALID> "

};
Expand Down Expand Up @@ -162,28 +157,22 @@ ASTBinary::BinOp ASTBinary::from_binary_op(int operand)
}
}


/* ASTCompare */
const char* ASTCompare::op_str() const
{
static const char* s_cmp_strings[] = {
" < ", " <= ", " == ", " != ", " > ", " >= ", " in ", " not in ", " is ", " is not ",
"<EXCEPTION MATCH>", "<BAD>"
};
static const char* s_cmp_strings[] = { " < ", " <= ", " == ", " != ", " > ",
" >= ", " in ", " not in ", " is ", " is not ", "<EXCEPTION MATCH>",
"<BAD>" };
return s_cmp_strings[op()];
}


/* ASTKeyword */
const char* ASTKeyword::word_str() const
{
static const char* s_word_strings[] = {
"pass", "break", "continue"
};
static const char* s_word_strings[] = { "pass", "break", "continue" };
return s_word_strings[key()];
}


/* ASTBlock */
void ASTBlock::removeLast()
{
Expand All @@ -199,9 +188,7 @@ void ASTBlock::removeFirst()

const char* ASTBlock::type_str() const
{
static const char* s_type_strings[] = {
"", "if", "else", "elif", "try", "CONTAINER", "except",
"finally", "while", "for", "with", "async for"
};
static const char* s_type_strings[] = { "", "if", "else", "elif", "try",
"CONTAINER", "except", "finally", "while", "for", "with", "async for" };
return s_type_strings[blktype()];
}
Loading
Loading