diff --git a/Sources/rxcc/rxcc.swift b/Sources/rxcc/rxcc.swift index 6c83180..814bb0b 100644 --- a/Sources/rxcc/rxcc.swift +++ b/Sources/rxcc/rxcc.swift @@ -104,6 +104,9 @@ enum ConstructVariant { case EqualTo case NotEqualTo + case LogicalAnd + case LogicalOr + // Unary operation variants case Negation case BitwiseCompliment @@ -111,6 +114,10 @@ enum ConstructVariant { // Expression variants case TermSequence + case AdditiveExpressionSequence + case RelationalExpressionSequence + case EqualityExpressionSequence + case LogicalAndExpressionSequence // Term variants case FactorSequence @@ -141,6 +148,8 @@ enum ConstructType { case AdditionPriorityOperator case InequalityPriorityOperator case EqualityPriorityOperator + case LogicalAndPriorityOperator + case LogicalOrPriorityOperator case Program case Function @@ -214,13 +223,55 @@ let constructDefinitions: Dictionary String { } break + case .LogicalAndExpressionSequence: + for child in node.children { + text += generateOutput(child) + } + break + + case .EqualityExpressionSequence: + for child in node.children { + text += generateOutput(child) + } + break + + case .RelationalExpressionSequence: + for child in node.children { + text += generateOutput(child) + } + break + + case .AdditiveExpressionSequence: + for child in node.children { + text += generateOutput(child) + } + break + case .TermSequence: var operation: ConstructVariant = .Error let count = node.children.count @@ -678,49 +754,6 @@ func validateConstruct(type: ConstructType, variant: ConstructVariant, tokens: i break } -/* - if valid == .Invalid { - print("\(indent)Subconstruct validation failed") - return .Invalid - } else if valid == .Break { - print("\(indent)End validate subconstruct (variant \"\(validVariant) by breaking\")") - break - } - */ - - //print("\(indent)End validate subconstruct (variant \"\(validVariant)\")") - break - - case .Token(let type): - if let token: Token = tokens.popLast() { - if type != token.type { - print("\(indent)VALIDATION FAILED FOR TOKEN \"\(token.content)\"") - return .Invalid - } - print("\(indent)Validated token \"\(token.content)\"") - - if token.type == .LITERAL_INTEGER { - node.value = String(token.content) - } - else if token.type == .IDENTIFIER { - node.value = String(token.content) - } - - continue - - } else { - print("\(indent)RAN OUT OF TOKENS") - return .Invalid - } - - - - - - - - break - case .Construct(let type): print("\(indent)Begin validate subconstruct (type \"\(type)\")") @@ -750,12 +783,6 @@ func validateConstruct(type: ConstructType, variant: ConstructVariant, tokens: i break } - - - - - - if valid == .Invalid {