/*
 * This file is part of JICI, licensed under the MIT License (MIT).
 *
 * Copyright (c) 2015-2015 Aleksi Sapon <http://sapon.ca/jici/>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package ca.sapon.jici;

import java.util.List;
import java.util.Scanner;

import ca.sapon.jici.decoder.Decoder;
import ca.sapon.jici.evaluator.Environment;
import ca.sapon.jici.lexer.Lexer;
import ca.sapon.jici.lexer.Token;
import ca.sapon.jici.parser.Parser;
import ca.sapon.jici.parser.statement.Statement;

public class Main {
    public static void main(String[] args) {
        System.out.println("JICI\n\n");
        final Environment environment = new Environment();
        final Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            eval(environment, scanner.nextLine());
        }
        scanner.close();
    }

    private static void eval(Environment environment, String source) {
        final SourceMetadata metadata = new SourceMetadata(source);
        try {
            source = Decoder.decode(source, metadata);
            final List<Token> tokens = Lexer.lex(source);
            final List<Statement> statements = Parser.parse(tokens);
            for (Statement statement : statements) {
                statement.execute(environment);
            }
        } catch (SourceException exception) {
            System.out.println(metadata.generateErrorMessage(exception));
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}

@@ -1391,89 +1391,273 @@
 ici.
-lexer.Lexer;%0Aimport ca.sapon.jici.lexer.Token;%0Aimport ca.sapon.jici.parser.Parser
+evaluator.value.Value;%0Aimport ca.sapon.jici.evaluator.value.type.ValueType;%0Aimport ca.sapon.jici.lexer.Lexer;%0Aimport ca.sapon.jici.lexer.Token;%0Aimport ca.sapon.jici.lexer.TokenID;%0Aimport ca.sapon.jici.parser.Parser;%0Aimport ca.sapon.jici.parser.expression.Expression
 ;%0Aim
@@ -2315,32 +2315,121 @@
 er.lex(source);%0A
+            if (tokens.get(tokens.size() - 1).getID() == TokenID.SYMBOL_SEMICOLON) %7B%0A    
             fina
@@ -2493,16 +2493,20 @@
         
+    
 for (Sta
@@ -2554,16 +2554,20 @@
         
+    
 statemen
@@ -2590,16 +2590,388 @@
 nment);%0A
+                %7D%0A            %7D else %7B%0A                final Expression expression = Parser.parseExpression(tokens);%0A                final ValueType type = expression.getValueType(environment);%0A                final Value value = expression.getValue(environment);%0A                System.out.println(%22Type: %22 + type);%0A                System.out.println(%22Value: %22 + value);%0A
         

Add evaluation of expression to the "shell"