source: src/Parser/RunParser.cpp @ d18540f

ADTast-experimental
Last change on this file since d18540f was cbd1ba8, checked in by Andrew Beach <ajbeach@…>, 18 months ago

Moved parsing code out of main into the parsing directly, as an organizational improvement. The new files use the new naming convention, and should be converted to the new AST.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// RunParser.cpp -- External interface to the parser.
8//
9// Author           : Andrew Beach
10// Created On       : Mon Dec 19 11:00:00 2022
11// Last Modified By : Andrew Beach
12// Last Modified On : Mon Dec 19 11:15:00 2022
13// Update Count     : 0
14//
15
16#include "RunParser.hpp"
17
18#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
19#include "Parser/TypedefTable.h"            // for TypedefTable
20
21// Variables global to the parsing code.
22LinkageSpec::Spec linkage = LinkageSpec::Cforall;
23TypedefTable typedefTable;
24DeclarationNode * parseTree = nullptr;
25
26void parse( FILE * input, LinkageSpec::Spec linkage, bool alwaysExit ) {
27        extern int yyparse( void );
28        extern FILE * yyin;
29        extern int yylineno;
30
31        // Set global information.
32        ::linkage = linkage;
33        yyin = input;
34        yylineno = 1;
35
36        int parseStatus = yyparse();
37        fclose( input );
38        if ( alwaysExit || parseStatus != 0 ) {
39                exit( parseStatus );
40        } // if
41} // parse
42
43void dumpParseTree( std::ostream & out ) {
44        parseTree->printList( out );
45        delete parseTree;
46        parseTree = nullptr;
47}
48
49std::list<Declaration *> buildUnit(void) {
50        std::list<Declaration *> translationUnit;
51        buildList( parseTree, translationUnit );
52
53        delete parseTree;
54        parseTree = nullptr;
55
56        return translationUnit;
57}
58
59// Local Variables: //
60// tab-width: 4 //
61// mode: c++ //
62// compile-command: "make install" //
63// End: //
Note: See TracBrowser for help on using the repository browser.