// Path: ngscript-core/src/main/java/org/ngscript/Ngscript.java
// @Slf4j
// public class Ngscript {
// 
//     Configuration configuration;
//     NgLalrParser parser;
//     Compiler compiler;
//     VirtualMachine vm = new VirtualMachine(new PrintWriter(System.out), new PrintWriter(System.err));
// 
//     public Ngscript() {
//         this(Configuration.DEFAULT);
//     }
// 
//     public Ngscript(Configuration configuration) {
//         this.configuration = configuration;
//         this.compiler = new Compiler(configuration);
//         this.parser = new NgLalrParser(configuration);
//     }
// 
//     public Object eval(String code) throws ParserException, CompilerException {
//         feed(code);
//         return vm.eax;
//     }
// 
//     public boolean feed(String code) throws CompilerException, LexerException, ParserException {
//         List<Token> tokens = Lexer.scan(code);
//         if (!configuration.isInteractive()) {
//             tokens.add(new Token(Symbol.EOF.identifier));
//         }
//         Token[] ts = tokens.toArray(new Token[0]);
//         boolean compiled = parser.feed(ts);
//         if (compiled) {
//             AstNode ast = parser.getResult();
//             parser.reduce(ast);
//             NgLalrParser.removeNULL(ast);
//             if (configuration.isGenerateDebugInfo()) {
//                 log.info(ast.toString());
//             }
//             //
//             List<Instruction> ins = compiler.compileCode(ast, code);
//             if (configuration.isGenerateDebugInfo()) {
//                 log.info(ins.toString());
//             }
//             vm.loadInstructions(ins);
//             vm.run();
//         }
//         return compiled;
//     }
// }


import org.apache.commons.io.IOUtils;
import org.ngscript.Ngscript;
import java.nio.charset.StandardCharsets;
/*
 * Copyright 2021 wssccc
 *
 * 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 org.ngscript.examples;



/**
 * @author wssccc
 */
public class RoseRender {

    public static void main(String[] args) throws Exception {
        long time = System.currentTimeMillis();
// Path: ngscript-core/src/main/java/org/ngscript/Ngscript.java
// @Slf4j
// public class Ngscript {
// 
//     Configuration configuration;
//     NgLalrParser parser;
//     Compiler compiler;
//     VirtualMachine vm = new VirtualMachine(new PrintWriter(System.out), new PrintWriter(System.err));
// 
//     public Ngscript() {
//         this(Configuration.DEFAULT);
//     }
// 
//     public Ngscript(Configuration configuration) {
//         this.configuration = configuration;
//         this.compiler = new Compiler(configuration);
//         this.parser = new NgLalrParser(configuration);
//     }
// 
//     public Object eval(String code) throws ParserException, CompilerException {
//         feed(code);
//         return vm.eax;
//     }
// 
//     public boolean feed(String code) throws CompilerException, LexerException, ParserException {
//         List<Token> tokens = Lexer.scan(code);
//         if (!configuration.isInteractive()) {
//             tokens.add(new Token(Symbol.EOF.identifier));
//         }
//         Token[] ts = tokens.toArray(new Token[0]);
//         boolean compiled = parser.feed(ts);
//         if (compiled) {
//             AstNode ast = parser.getResult();
//             parser.reduce(ast);
//             NgLalrParser.removeNULL(ast);
//             if (configuration.isGenerateDebugInfo()) {
//                 log.info(ast.toString());
//             }
//             //
//             List<Instruction> ins = compiler.compileCode(ast, code);
//             if (configuration.isGenerateDebugInfo()) {
//                 log.info(ins.toString());
//             }
//             vm.loadInstructions(ins);
//             vm.run();
//         }
//         return compiled;
//     }
// }


// Path: ngscript-examples/src/main/java/org/ngscript/examples/RoseRender.java
import org.apache.commons.io.IOUtils;
import org.ngscript.Ngscript;
import java.nio.charset.StandardCharsets;

/*
 * Copyright 2021 wssccc
 *
 * 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 org.ngscript.examples;



/**
 * @author wssccc
 */
public class RoseRender {

    public static void main(String[] args) throws Exception {
        long time = System.currentTimeMillis();
        new Ngscript().eval(IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream("RoseRender.ngs"), StandardCharsets.UTF_8));