source: src/Parser/RunParser.cpp @ d3b33d5

Last change on this file since d3b33d5 was c92bdcc, checked in by Andrew Beach <ajbeach@…>, 6 months ago

Updated the rest of the names in src/ (except for the generated files).

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[cbd1ba8]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
[bb7422a]12// Last Modified On : Mon Mar  6  9:42:00 2023
13// Update Count     : 3
[cbd1ba8]14//
15
16#include "RunParser.hpp"
17
[019b2d3]18#include "AST/TranslationUnit.hpp"          // for TranslationUnit
19#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
[c92bdcc]20#include "Parser/DeclarationNode.hpp"       // for DeclarationNode, buildList
21#include "Parser/TypedefTable.hpp"          // for TypedefTable
[cbd1ba8]22
23// Variables global to the parsing code.
[f2f595d7]24ast::Linkage::Spec linkage = ast::Linkage::Cforall;
[cbd1ba8]25TypedefTable typedefTable;
26DeclarationNode * parseTree = nullptr;
27
[f2f595d7]28void parse( FILE * input, ast::Linkage::Spec linkage, bool alwaysExit ) {
[cbd1ba8]29        extern int yyparse( void );
30        extern FILE * yyin;
31        extern int yylineno;
32
33        // Set global information.
34        ::linkage = linkage;
35        yyin = input;
36        yylineno = 1;
37
38        int parseStatus = yyparse();
39        fclose( input );
40        if ( alwaysExit || parseStatus != 0 ) {
41                exit( parseStatus );
42        } // if
43} // parse
44
[019b2d3]45ast::TranslationUnit buildUnit(void) {
[bb7422a]46        std::vector<ast::ptr<ast::Decl>> decls;
47        buildList( parseTree, decls );
[cbd1ba8]48        delete parseTree;
49        parseTree = nullptr;
50
[bb7422a]51        ast::TranslationUnit transUnit;
52        for ( auto decl : decls ) {
53                transUnit.decls.emplace_back( std::move( decl ) );
54        }
[019b2d3]55        return transUnit;
[cbd1ba8]56}
57
58// Local Variables: //
59// tab-width: 4 //
60// mode: c++ //
61// compile-command: "make install" //
62// End: //
Note: See TracBrowser for help on using the repository browser.