source: src/Parser/RunParser.cpp@ 466787a

ADT ast-experimental
Last change on this file since 466787a was 64b3cda, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Adjusted -Pasterr so it works while using the new ast. Removed the -Ptree option as it doesn't seem to work and no one uses it.

  • Property mode set to 100644
File size: 2.0 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
[019b2d3]12// Last Modified On : Thr Dec 22 10:18:00 2022
13// Update Count : 1
[cbd1ba8]14//
15
16#include "RunParser.hpp"
17
[019b2d3]18#include "AST/Convert.hpp" // for convert
19#include "AST/TranslationUnit.hpp" // for TranslationUnit
20#include "CodeTools/TrackLoc.h" // for fillLocations
21#include "Common/CodeLocationTools.hpp" // for forceFillCodeLocations
[cbd1ba8]22#include "Parser/ParseNode.h" // for DeclarationNode, buildList
23#include "Parser/TypedefTable.h" // for TypedefTable
24
25// Variables global to the parsing code.
26LinkageSpec::Spec linkage = LinkageSpec::Cforall;
27TypedefTable typedefTable;
28DeclarationNode * parseTree = nullptr;
29
30void parse( FILE * input, LinkageSpec::Spec linkage, bool alwaysExit ) {
31 extern int yyparse( void );
32 extern FILE * yyin;
33 extern int yylineno;
34
35 // Set global information.
36 ::linkage = linkage;
37 yyin = input;
38 yylineno = 1;
39
40 int parseStatus = yyparse();
41 fclose( input );
42 if ( alwaysExit || parseStatus != 0 ) {
43 exit( parseStatus );
44 } // if
45} // parse
46
[019b2d3]47ast::TranslationUnit buildUnit(void) {
[cbd1ba8]48 std::list<Declaration *> translationUnit;
49 buildList( parseTree, translationUnit );
50
51 delete parseTree;
52 parseTree = nullptr;
53
[019b2d3]54 // When the parse/buildList code is translated to the new ast, these
55 // fill passes (and the one after 'Hoist Type Decls') should be redundent
56 // because the code locations should already be filled.
57 CodeTools::fillLocations( translationUnit );
58 ast::TranslationUnit transUnit = convert( std::move( translationUnit ) );
59 forceFillCodeLocations( transUnit );
60 return transUnit;
[cbd1ba8]61}
62
63// Local Variables: //
64// tab-width: 4 //
65// mode: c++ //
66// compile-command: "make install" //
67// End: //
Note: See TracBrowser for help on using the repository browser.