Example #1
0
        public void FullParse()
        {
            string[] lines = File.ReadAllLines("test.glsl");

            GLSLLexer lexer = new GLSLLexer();

            MultiLineTextSource source = MultiLineTextSource.FromString(lines, true);

            GLSLParser parser = new GLSLParser(source.Settings);

            LinkedList <Token> tokens = lexer.Run(source.CurrentSnapshot);

            SyntaxTree tree = parser.Run(source.CurrentSnapshot, tokens);

            tree.WriteToXml("tree.xml", source.CurrentSnapshot);
        }
Example #2
0
        public static string Minify(string shaderCode)
        {
            AntlrInputStream  input  = new AntlrInputStream(shaderCode);
            GLSLLexer         lexer  = new GLSLLexer(input);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            GLSLParser        parser = new GLSLParser(tokens);

            //parser.Ac
            // need to add visitors so
            //https://www.antlr2.org/doc/trees.html
            //https://stackoverflow.com/questions/29929062/antlr4-ast-vistor-and-node-return-type-should-i-have-more-than-one-visitor
            // https://stackoverflow.com/questions/23092081/antlr4-visitor-pattern-on-simple-arithmetic-example
            //var unit = parser.translation_unit();

            //unit.external_declaration_list().external_declaration_list().GetChild(0)
            return(shaderCode);// unit.ToStringTree();
        }
Example #3
0
 public void SetFrom(GLSLParser glsl)
 {
     Body.Structs.ExtraStructs = glsl.GetProperties();
     Body.Main.Content         = glsl.GetMain();
 }