Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
PsychedelicPalimpsest committed May 21, 2024
1 parent 63ee2d4 commit bf00c99
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
8 changes: 6 additions & 2 deletions source/fnc/treegen/ast_types.d
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ enum OperationVariety {
Pipe,
Assignment,

BitwiseNot,
Concatenate,
BitwiseOr,
BitwiseXor,
BitwiseAnd,

BitwiseNotEq,
ConcatenateEq,
BitwiseOrEq,
BitwiseXorEq,
BitwiseAndEq,
Expand Down Expand Up @@ -274,6 +274,10 @@ class AstNode {
printTabs();

switch (action) {
case AstAction.Voidable:
writeln(action);
voidableType.tree(tabCount + 1);
break;
case AstAction.GenericOf:
write(action);
writeln(":");
Expand Down
10 changes: 6 additions & 4 deletions source/fnc/treegen/relationships.d
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,9 @@ const OperatorPrecedenceLayer[] operatorPrecedence = [
]),

OperationPrecedenceEntry(OperationVariety.LogicalNot, [
OPR('!'), Token(TokenType.Filler)
Token(TokenType.ExclamationMark, "!".makeUnicodeString), Token(TokenType.Filler)
]),
OperationPrecedenceEntry(OperationVariety.BitwiseNot, [
OperationPrecedenceEntry(OperationVariety.Concatenate, [
OPR('~'), Token(TokenType.Filler)
]),
]),
Expand Down Expand Up @@ -849,7 +849,7 @@ const OperatorPrecedenceLayer[] operatorPrecedence = [
Token(TokenType.Filler), OPR('|'), OPR('='),
Token(TokenType.Filler)
]),
OperationPrecedenceEntry(OperationVariety.BitwiseNotEq, [
OperationPrecedenceEntry(OperationVariety.ConcatenateEq, [
Token(TokenType.Filler), OPR('~'), OPR('='),
Token(TokenType.Filler)
]),
Expand Down Expand Up @@ -896,14 +896,16 @@ bool testAndJoin(const(OperationPrecedenceEntry) entry, ref Array!AstNode nodes,
operands ~= node;
break;
case TokenType.QuestionMark:
case TokenType.ExclamationMark:
case TokenType.Equals:
case TokenType.Operator:
if (node.action != AstAction.TokenHolder)
return false;
Token token = node.tokenBeingHeld;
if (token.tokenVariety != TokenType.Equals
&& token.tokenVariety != TokenType.Operator
&& token.tokenVariety != TokenType.QuestionMark)
&& token.tokenVariety != TokenType.QuestionMark
&& token.tokenVariety != TokenType.ExclamationMark)
return false;
if (token.value != entry.tokens[index].value)
return false;
Expand Down
11 changes: 8 additions & 3 deletions source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ public enum GenerationFlags {
Common,
Native, // Remaining features may be toggled, sourced from gallinule ID enums (not CR)
}
import fnc.tokenizer.make_tokens;

import fnc.treegen.scope_parser;
import fnc.treegen.expression_parser;
import fnc.treegen.relationships;
void main() {
import fnc.treegen.scope_parser : parseMultilineScope, ScopeData, tree;
import fnc.treegen.relationships : GLOBAL_SCOPE_PARSE;


ScopeData globalScope = parseMultilineScope(GLOBAL_SCOPE_PARSE, "
public module foo.bar;
int main(){
byte c = (1 + 5 )|> B.c;
!false;
}
");

globalScope.tree;
}

0 comments on commit bf00c99

Please sign in to comment.