1 /*
2  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  *  Copyright (C) 2007-2008 - DIGITEO - Bruno JOFRET
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 
16 #ifndef AST_COMMENTEXP_HXX
17 #define AST_COMMENTEXP_HXX
18 
19 #include "constexp.hxx"
20 
21 namespace ast
22 {
23 /** \brief Abstract an string Expression node.
24 **
25 ** \b Example: string*/
26 class CommentExp : public ConstExp
27 {
28 public:
CommentExp(const Location & location,std::wstring * comment)29     CommentExp (const Location& location,
30                 std::wstring* comment)
31         : ConstExp (location),
32           _comment (comment)
33     {
34     }
35     /** \brief Destroy an string Exp node.
36     **
37     ** Delete value (see constructor). */
~CommentExp()38     virtual ~CommentExp ()
39     {
40         delete _comment;
41     }
42     /** \} */
43 
clone()44     virtual CommentExp* clone()
45     {
46         CommentExp* cloned = new CommentExp(getLocation(), new std::wstring(getComment()));
47         cloned->setVerbose(isVerbose());
48         return cloned;
49     }
50 
equal(const Exp & e) const51     virtual bool equal(const Exp & e) const
52     {
53         return e.getType() == COMMENTEXP;
54     }
55 
56     /** \name Visitors entry point.
57     ** \{ */
58 public:
59     /** \brief Accept a const visitor \a v. */
accept(Visitor & v)60     virtual void accept (Visitor& v)
61     {
62         v.visit (*this);
63     }
64     /** \brief Accept a non-const visitor \a v. */
accept(ConstVisitor & v) const65     virtual void accept (ConstVisitor& v) const
66     {
67         v.visit (*this);
68     }
69     /** \} */
70 
71 
72     /** \name Accessors.
73     ** \{ */
74 public:
75     /** \brief Return the comment (read only). */
getComment() const76     std::wstring &getComment() const
77     {
78         return *_comment;
79     }
80     /** \} */
81 
getType() const82     virtual ExpType getType() const
83     {
84         return COMMENTEXP;
85     }
isCommentExp() const86     inline bool isCommentExp() const
87     {
88         return true;
89     }
90 protected:
91     std::wstring* _comment;
92 };
93 
94 } // namespace ast
95 
96 #endif // !AST_COMMENTEXP_HXX
97