Last change
on this file since 45d1ab9 was
bb7422a,
checked in by Andrew Beach <ajbeach@…>, 19 months ago
|
Translated parser to the new ast. This incuded a small fix in the resolver so larger expressions can be used in with statements and some updated tests. errors/declaration just is a formatting update. attributes now actually preserves more attributes (unknown if all versions work).
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 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 | // parserutility.cc -- |
---|
8 | // |
---|
9 | // Author : Rodolfo G. Esteves |
---|
10 | // Created On : Sat May 16 15:30:39 2015 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Wed Mar 1 10:42:00 2023 |
---|
13 | // Update Count : 9 |
---|
14 | // |
---|
15 | |
---|
16 | #include "parserutility.h" |
---|
17 | |
---|
18 | #include <list> // for list |
---|
19 | #include <string> // for string |
---|
20 | |
---|
21 | #include "AST/Expr.hpp" // for UntypedExpr, CastExpr, ConstantExpr |
---|
22 | #include "AST/Type.hpp" // for BasicType, ZeroType, BasicType::Kind... |
---|
23 | |
---|
24 | // rewrite |
---|
25 | // if ( x ) ... |
---|
26 | // as |
---|
27 | // if ( (int)(x != 0) ) ... |
---|
28 | |
---|
29 | ast::Expr * notZeroExpr( ast::Expr * orig ) { |
---|
30 | return ( !orig ) ? nullptr : new ast::CastExpr( orig->location, |
---|
31 | ast::UntypedExpr::createCall( orig->location, |
---|
32 | "?!=?", |
---|
33 | { |
---|
34 | orig, |
---|
35 | new ast::ConstantExpr( orig->location, |
---|
36 | new ast::ZeroType(), |
---|
37 | "0", |
---|
38 | std::optional<unsigned long long>( 0 ) |
---|
39 | ), |
---|
40 | } |
---|
41 | ), |
---|
42 | new ast::BasicType( ast::BasicType::SignedInt ) |
---|
43 | ); |
---|
44 | } |
---|
45 | |
---|
46 | // Local Variables: // |
---|
47 | // tab-width: 4 // |
---|
48 | // mode: c++ // |
---|
49 | // compile-command: "make install" // |
---|
50 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.