source: proto/pablo/src/compiler/frontend/SyntacticAnalyzer.java @ 2710

Last change on this file since 2710 was 2710, checked in by ksherdy, 6 years ago

General refactoring.

File size: 987 bytes
Line 
1//
2// This code is modified scatter parser-generator code.
3// See applications.SampleApplication.java.
4//
5
6package  compiler.frontend;
7
8import parser.*;
9import ast.ASTNode;
10
11import lexicalAnalyzer.LexicalController;
12import logging.ScatterLogger;
13import compiler.frontend.SyntacticAnalyzer;
14
15public class SyntacticAnalyzer {
16       
17        static public ASTNode parse(String inputFile) throws SyntacticAnalysisFailedException {                         
18
19                LexicalController lexController = LexicalController.make(inputFile);
20                ASTNode ASTTree = Parser.parse(lexController);
21       
22                if(thereAreErrors()) {
23                        throw new SyntacticAnalysisFailedException();
24                }
25               
26                return ASTTree;
27        }               
28       
29        static private boolean thereAreErrors() {
30                return ScatterLogger.hasErrors();
31        }       
32                       
33        static private void informUserNoCodeGenerated() {
34                System.err.println("AST generation failed. Source program errors. No code generated.");
35        }
36       
37        static public void printCompletionMessage() {
38                System.out.println("Code generation complete.");
39        }
40       
41}
Note: See TracBrowser for help on using the repository browser.