All Downloads are FREE. Search and download functionalities are using the official Maven repository.

one.empty3.library.lang.Node Maven / Gradle / Ivy

There is a newer version: 2024.5.10
Show newest version
/*
 * Copyright (c) 2022-2023. Manuel Daniel Dahmen
 *
 *
 *    Copyright 2012-2023 Manuel Daniel Dahmen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package one.empty3.library.lang;

import one.empty3.library.lang.Token.TokenTypeTxt;

import java.util.*;


public class Node {

    public static final int declaration = 1;
    public static final int instruction = 2;
    public static final int inference   = 4;
    public static final int declarationTypeClass = 1;
    public static final int declarationTypeMethod = 2;
    public static final int declarationTypeScalar = 4;
    public static final int declarationTypeScalarInteger = 8;
    public static final int declarationTypeScalarLongInteger = 16;
    public static final int declarationTypeScalarShortInteger = 32;
    public static final int declarationTypeScalarFloatingPoint = 64;
    public static final int declarationTypeScalarFloatingPointDoublePrecision = 128;
    public static final int declarationTypeScalarCharacter = 256;
    public static final int declarationTypeScalarCharCodeInt = 512;
    public static final int declarationTypeScalarBoolean = 512;
    public static final int declarationTypeObject = 2048;
    public static final int declarationTypeString = 4096;

    int dec;
    Node parent;
    List children = new ArrayList();

    public Node(List tokens) {
        int index = 0;
        while((index < tokens.size())) {
            Token t = tokens.get(index);
            switch (t.getTypeTxt()) {
                case Space:
                    break;
                case SpecialChar:
                    switch (t.getLiteral()) {
                        case "=":
                            break;
                        case "<":
                            break;
                        case ">":
                            break;
                        case "!":
                            break;
                        case "+":
                            break;
                        case "-":
                            break;
                        case "*":
                            break;
                        case "/":
                            break;
                        case "(":
                            break;
                        case ")":
                            break;
                        case "{":
                            break;
                        case "}":
                            break;
                        case "[":
                            break;
                        case "]":
                            break;
                        case "&":
                            break;
                        case "|":
                            break;
                        case "\'":
                            break;
                        case "\"":
                            break;
                        case "\\":
                            break;
                        case ":":
                            break;
                        case ",":
                            break;
                        case ";":
                            break;
                        case ".":
                            break;
                        case "?":
                            break;
                    }
                    break;
                case Keyword:
                    break;
                case Name:
                    break;
                case Literal:
                    break;
                default:
                    throw new IllegalStateException("Unexpected value: " + t.getTypeTxt());

            }
            index++;
        }
    }

    public boolean canExec() {
        return false;
    }

    public void run() {
        int index = 0;
        TokenType tt = children.get(index).tt;


        while(!isExiting()) {
            if(children.get(index).canExec())
                children.get(index).run();
            else {
                addToDeclaration(children.get(index));
            }
        }
    }

    private void addToDeclaration(Node node) {

    }

    private boolean isExiting() {
        return false;
    }


    public enum TokenType {Name, Keyword,  Comment, JavadocComment,
        Literal};
    public enum Literal {StringLiteral,
        FloatLiteral, DoubleLiteral, CharLiteral };
    public enum InstructionBlock { Unnamed, For, While, Do, Method };
    public enum Declaration {Package, Imports, Classes, Interfaces, MethodMember, VarMember, Variable, Param};
    TokenType tt;
    public Node(TokenType tt, Literal l, 
            String text, InstructionBlock ib,
            Declaration d) {
        this.tt = tt;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy