ADTast-experimental
Last change
on this file since 9bb8ee42 was
bb7422a,
checked in by Andrew Beach <ajbeach@…>, 17 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
|
Rev | Line | |
---|
[b87a5ed] | 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 | // |
---|
[9335ecc] | 7 | // parserutility.cc -- |
---|
[b87a5ed] | 8 | // |
---|
| 9 | // Author : Rodolfo G. Esteves |
---|
| 10 | // Created On : Sat May 16 15:30:39 2015 |
---|
[ac10576] | 11 | // Last Modified By : Andrew Beach |
---|
[bb7422a] | 12 | // Last Modified On : Wed Mar 1 10:42:00 2023 |
---|
| 13 | // Update Count : 9 |
---|
[4cb935e] | 14 | // |
---|
[b87a5ed] | 15 | |
---|
[a67b60e] | 16 | #include "parserutility.h" |
---|
[d180746] | 17 | |
---|
| 18 | #include <list> // for list |
---|
| 19 | #include <string> // for string |
---|
| 20 | |
---|
[bb7422a] | 21 | #include "AST/Expr.hpp" // for UntypedExpr, CastExpr, ConstantExpr |
---|
| 22 | #include "AST/Type.hpp" // for BasicType, ZeroType, BasicType::Kind... |
---|
[51b7345] | 23 | |
---|
[e82aa9df] | 24 | // rewrite |
---|
| 25 | // if ( x ) ... |
---|
| 26 | // as |
---|
| 27 | // if ( (int)(x != 0) ) ... |
---|
| 28 | |
---|
[bb7422a] | 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 | ); |
---|
[51b7345] | 44 | } |
---|
[b87a5ed] | 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.