亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? pat5c.htm

?? java設(shè)計(jì)范式.rar
?? HTM
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
<CODE>true</CODE> and <CODE>false</CODE>.   Nonterminal symbols representexpressions containing the operators <CODE>and</CODE>, <CODE>or</CODE>, and<CODE>not</CODE>.  The grammar is defined asfollows<A NAME="fn1"></A><A HREF="#footnote1"><SUP>1</SUP></A>:</P><A NAME="auto1089"></A><PRE>    BooleanExp ::= VariableExp | Constant | OrExp | AndExp | NotExp |                   '(' BooleanExp ')'    AndExp ::= BooleanExp  'and' BooleanExp    OrExp ::= BooleanExp  'or' BooleanExp    NotExp ::= 'not' BooleanExp    Constant ::= 'true' |  'false'    VariableExp ::= 'A' | 'B' | ... | 'X' | 'Y' | 'Z'</PRE><A NAME="auto1090"></A><P>We define two operations on Boolean expressions. The first,<CODE>Evaluate</CODE>, evaluates a Boolean expression in a contextthat assigns a true or false value to each variable.  The secondoperation, <CODE>Replace</CODE>, produces a new Boolean expression byreplacing a variable with an expression. <CODE>Replace</CODE> showshow the Interpreter pattern can be used for more than just evaluatingexpressions. In this case, it manipulates the expression itself.</P><A NAME="variableexp"></A><P>We give details of just the <CODE>BooleanExp</CODE>,<CODE>VariableExp</CODE>, and <CODE>AndExp</CODE> classes here. Classes<CODE>OrExp</CODE> and <CODE>NotExp</CODE> are similar to <CODE>AndExp</CODE>.The <CODE>Constant</CODE> class represents the Boolean constants.</P><A NAME="auto1091"></A><P><CODE>BooleanExp</CODE> defines the interface for all classes that definea Boolean expression:</P><A NAME="auto1092"></A><PRE>    class BooleanExp {    public:        BooleanExp();        virtual ~BooleanExp();            virtual bool Evaluate(Context&amp;) = 0;        virtual BooleanExp* Replace(const char*, BooleanExp&amp;) = 0;        virtual BooleanExp* Copy() const = 0;    };</PRE><A NAME="auto1093"></A><P>The class <CODE>Context</CODE> defines a mapping from variables toBoolean values, which we represent with the C++ constants<CODE>true</CODE> and <CODE>false</CODE>. <CODE>Context</CODE> has thefollowing interface:</P><A NAME="auto1094"></A><PRE>    class Context {    public:        bool Lookup(const char*) const;        void Assign(VariableExp*, bool);    };</PRE><A NAME="auto1095"></A><P>A <CODE>VariableExp</CODE> represents a named variable:</P><A NAME="auto1096"></A><PRE>    class VariableExp : public BooleanExp {    public:        VariableExp(const char*);        virtual ~VariableExp();            virtual bool Evaluate(Context&amp;);        virtual BooleanExp* Replace(const char*, BooleanExp&amp;);        virtual BooleanExp* Copy() const;    private:        char* _name;    };</PRE><A NAME="auto1097"></A><P>The constructor takes the variable's name as an argument:</P><A NAME="auto1098"></A><PRE>    VariableExp::VariableExp (const char* name) {        _name = strdup(name);    }</PRE><A NAME="auto1099"></A><P>Evaluating a variable returns its value in the current context.</P><A NAME="auto1100"></A><PRE>    bool VariableExp::Evaluate (Context&amp; aContext) {        return aContext.Lookup(_name);    }</PRE><A NAME="auto1101"></A><P>Copying a variable returns a new <CODE>VariableExp</CODE>:</P><A NAME="auto1102"></A><PRE>    BooleanExp* VariableExp::Copy () const {        return new VariableExp(_name);    }</PRE><A NAME="auto1103"></A><P>To replace a variable with an expression, we check to see if thevariable has the same name as the one it is passed as an argument:</P><A NAME="auto1104"></A><PRE>    BooleanExp* VariableExp::Replace (        const char* name, BooleanExp&amp; exp    ) {        if (strcmp(name, _name) == 0) {            return exp.Copy();        } else {            return new VariableExp(_name);       }    }</PRE><A NAME="andexp"></A><P>An <CODE>AndExp</CODE> represents an expression made by ANDing twoBoolean expressions together.</P><A NAME="auto1105"></A><PRE>    class AndExp : public BooleanExp {    public:        AndExp(BooleanExp*, BooleanExp*);        virtual ~ AndExp();            virtual bool Evaluate(Context&amp;);        virtual BooleanExp* Replace(const char*, BooleanExp&amp;);        virtual BooleanExp* Copy() const;    private:        BooleanExp* _operand1;        BooleanExp* _operand2;    };        AndExp::AndExp (BooleanExp* op1, BooleanExp* op2) {        _operand1 = op1;        _operand2 = op2;    }</PRE><A NAME="auto1106"></A><P>Evaluating an <CODE>AndExp</CODE> evaluates its operands and returnsthe logical "and" of the results.</P><A NAME="auto1107"></A><PRE>    bool AndExp::Evaluate (Context&amp; aContext) {        return            _operand1->Evaluate(aContext) &amp;&amp;            _operand2->Evaluate(aContext);    }</PRE><A NAME="auto1108"></A><P>An <CODE>AndExp</CODE> implements <CODE>Copy</CODE> and <CODE>Replace</CODE> bymaking recursive calls on its operands:</P><A NAME="auto1109"></A><PRE>    BooleanExp* AndExp::Copy () const {        return            new AndExp(_operand1->Copy(), _operand2->Copy());    }        BooleanExp* AndExp::Replace (const char* name, BooleanExp&amp; exp) {        return            new AndExp(                _operand1->Replace(name, exp),                _operand2->Replace(name, exp)            );    }</PRE><A NAME="auto1110"></A><P>Now we can define the Boolean expression</P><A NAME="auto1111"></A><PRE>    (true and x) or (y and (not x))</PRE><A NAME="auto1112"></A><P>and evaluate it for a given assignment of <CODE>true</CODE> or<CODE>false</CODE> to the variables <CODE>x</CODE> and <CODE>y</CODE>:</P><A NAME="auto1113"></A><PRE>    BooleanExp* expression;    Context context;        VariableExp* x = new VariableExp("X");    VariableExp* y = new VariableExp("Y");        expression = new OrExp(        new AndExp(new Constant(true), x),        new AndExp(y, new NotExp(x))    );        context.Assign(x, false);    context.Assign(y, true);        bool result = expression->Evaluate(context);</PRE><A NAME="auto1114"></A><P>The expression evaluates to <CODE>true</CODE> for this assignment to<CODE>x</CODE> and <CODE>y</CODE>.  We can evaluate the expression with adifferent assignment to the variables simply by changing thecontext.</P><A NAME="auto1115"></A><P>Finally, we can replace the variable <CODE>y</CODE> with a new expression andthen reevaluate it:</P><A NAME="auto1116"></A><PRE>    VariableExp* z = new VariableExp("Z");    NotExp not_z(z);        BooleanExp* replacement = expression->Replace("Y", not_z);        context.Assign(z, true);        result = replacement->Evaluate(context);</PRE><A NAME="auto1117"></A><P>This example illustrates an important point about the Interpreterpattern: many kinds of operations can "interpret" a sentence.  Ofthe three operations defined for <CODE>BooleanExp</CODE>,<CODE>Evaluate</CODE> fits our idea of what an interpreter should do mostclosely&#151;that is, it interprets a program or expression and returns asimple result.</P><A NAME="variable-w-interp2"></A><P>However, <CODE>Replace</CODE> can be viewed as an interpreter as well.It's an interpreter whose context is the name of the variable beingreplaced along with the expression that replaces it, and whose resultis a new expression.  Even <CODE>Copy</CODE> can be thought of as aninterpreter with an empty context.  It may seem a little strange toconsider <CODE>Replace</CODE> and <CODE>Copy</CODE> to be interpreters, becausethese are just basic operations on trees.  The examples in<A HREF="pat5kfs.htm" TARGET="_mainDisplayFrame">Visitor (331)</A> illustrate how all three operations can berefactored into a separate "interpreter" visitor, thus showing thatthe similarity is deep.</P><A NAME="auto1118"></A><P>The Interpreter pattern is more than just an operation distributedover a class hierarchy that uses the <A HREF="pat4cfs.htm" TARGET="_mainDisplayFrame">Composite (163)</A>pattern.  We consider <CODE>Evaluate</CODE> an interpreter because wethink of the <CODE>BooleanExp</CODE> class hierarchy as representing alanguage.  Given a similar class hierarchy for representing automotivepart assemblies, it's unlikely we'd consider operations like<CODE>Weight</CODE> and <CODE>Copy</CODE> as interpreters even though theyare distributed over a class hierarchy that uses the Compositepattern&#151;we just don't think of automotive parts as a language.  It'sa matter of perspective; if we started publishing grammars ofautomotive parts, then we could consider operations on those parts tobe ways of interpreting the language.</P><A NAME="knownuses"><A><H2><A HREF="#relatedpatterns"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Related Patterns"></A> Known Uses</H2> <A NAME="smalltalk-use-interp"></A><A NAME="spectalk-use-interp"></A><P>The Interpreter pattern is widely used in compilers implemented withobject-oriented languages, as the Smalltalk compilers are.  SPECTalkuses the pattern to interpret descriptions of input fileformats [<A HREF="bibfs.htm#szafron_tools92" TARGET="_mainDisplayFrame">Sza92</A>].  The QOCA constraint-solving toolkituses it to evaluate constraints [<A HREF="bibfs.htm#qoca" TARGET="_mainDisplayFrame">HHMV92</A>].</P><A NAME="auto1119"></A><P>Considered in its most general form (i.e., an operation distributedover a class hierarchy based on the Composite pattern), nearly everyuse of the Composite pattern will also contain the Interpreterpattern.  But the Interpreter pattern should be reserved for thosecases in which you want to think of the class hierarchy as defining alanguage.</P><A NAME="relatedpatterns"></A><H2><A HREF="#last"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: navigation"></A> Related Patterns</H2> <A NAME="auto1120"></A><P><A HREF="pat4cfs.htm" TARGET="_mainDisplayFrame">Composite (163)</A>:The abstract syntax tree is an instance of the Composite pattern.</P><A NAME="auto1121"></A><P><A HREF="pat4ffs.htm" TARGET="_mainDisplayFrame">Flyweight (195)</A>shows how to share terminal symbols within the abstract syntaxtree.</P><A NAME="auto1122"></A><P><A HREF="pat5dfs.htm" TARGET="_mainDisplayFrame">Iterator (257)</A>:The interpreter can use an Iterator to traverse the structure.</P><A NAME="auto1123"></A><P><A HREF="pat5kfs.htm" TARGET="_mainDisplayFrame">Visitor (331)</A> canbe used to maintain the behavior in each node in the abstract syntaxtree in one class.</P><A NAME="last"></A><P><A HREF="#intent"><IMG SRC="gifsb/up3.gif" BORDER=0></A><BR><A HREF="pat5dfs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/rightar3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5dfs.htm"        TARGET="_mainDisplayFrame">Iterator</A><BR><A HREF="pat5bfs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/leftarr3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5bfs.htm"        TARGET="_mainDisplayFrame">Command</A></P><HR><A NAME="footnote1"></A><P><SUP>1</SUP>For simplicity, we ignore operator precedence andassume it's the responsibility of whichever object constructs thesyntax tree.</P></BODY></HTML>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产亚洲5555| 天天综合天天综合色| 91精品福利视频| 一区二区三区中文字幕在线观看| 欧美精品久久99| 国产精品亚洲一区二区三区妖精 | 亚瑟在线精品视频| 精品国产3级a| 一本色道久久综合亚洲aⅴ蜜桃| 亚洲成人精品在线观看| 国产日产欧美精品一区二区三区| 在线观看视频欧美| 激情综合一区二区三区| 亚洲精品成人精品456| 欧美精品一区二区三区久久久| 一本色道久久综合精品竹菊| 精品一区二区国语对白| 一区二区三区在线视频免费观看| 日韩精品自拍偷拍| 欧美综合久久久| 国产91精品入口| 蜜芽一区二区三区| 一区二区三区四区亚洲| 久久久99精品免费观看| 日韩亚洲欧美一区二区三区| 欧美亚洲综合色| av日韩在线网站| 精品一区二区三区在线观看国产| 亚洲福利视频一区| 欧美激情一区二区三区| 国产精品无人区| 欧美一级夜夜爽| 欧美性大战久久久久久久蜜臀| 国产69精品久久久久毛片 | 日本高清成人免费播放| 国产乱码一区二区三区| 蜜桃av噜噜一区二区三区小说| 亚洲综合av网| 亚洲欧洲综合另类在线| 国产午夜精品一区二区三区视频 | 欧美午夜宅男影院| 成人午夜精品一区二区三区| 毛片av一区二区三区| 亚洲成a人v欧美综合天堂| 悠悠色在线精品| 亚洲欧美综合色| 久久久久久夜精品精品免费| 国产亚洲人成网站| 国产精品久久久久久久第一福利 | 亚洲自拍偷拍麻豆| 亚洲高清三级视频| 丝袜诱惑制服诱惑色一区在线观看| 天天av天天翘天天综合网| 丝袜美腿亚洲综合| 日韩精品电影一区亚洲| 日韩和欧美的一区| 亚洲一区二区精品久久av| 亚洲人精品午夜| 一区二区三区在线视频免费| 亚洲综合色网站| 亚洲综合一区在线| 午夜欧美电影在线观看| 视频一区欧美日韩| 日韩av午夜在线观看| 蜜臀av一区二区在线观看| 青青草视频一区| 精品一区二区日韩| 国产aⅴ综合色| 国产一区在线观看麻豆| 国产精品1区2区3区在线观看| 色综合网色综合| 精品视频在线免费| 欧美日韩一区二区三区在线看| 欧美丰满少妇xxxxx高潮对白| 欧美乱妇15p| 久久婷婷国产综合精品青草| 国产亚洲一二三区| 亚洲视频在线一区二区| 一区二区三区毛片| 日韩在线播放一区二区| 成人激情免费电影网址| av电影在线观看完整版一区二区| 91丨九色丨蝌蚪丨老版| 欧美性感一类影片在线播放| 91精品国产一区二区三区| wwwwxxxxx欧美| 国产精品久久久久一区二区三区共| 亚洲综合色婷婷| 激情图片小说一区| 99在线精品免费| 欧美一区二区三区免费观看视频| 欧美日韩国产综合视频在线观看| 91麻豆精品91久久久久久清纯| 国产午夜精品一区二区| 亚洲一区二区三区在线看| 久久99九九99精品| 一本色道久久综合狠狠躁的推荐| 日韩一区二区三区四区| 国产精品视频第一区| 日韩成人一级片| 国产成人免费在线视频| 欧美日韩一卡二卡三卡| 国产午夜精品一区二区三区嫩草| 一区二区国产盗摄色噜噜| 亚洲一区二区三区四区中文字幕| 亚洲成人自拍网| 丁香网亚洲国际| 91精品国产一区二区| 亚洲人成人一区二区在线观看| 日韩激情一区二区| 91尤物视频在线观看| 日韩欧美国产高清| 亚洲综合精品自拍| 精品一区二区三区视频| 91丨九色丨蝌蚪富婆spa| 欧美videofree性高清杂交| 亚洲综合色网站| 成人激情开心网| www成人在线观看| 日日摸夜夜添夜夜添国产精品| 粉嫩aⅴ一区二区三区四区| 日韩亚洲欧美一区二区三区| 亚洲免费视频成人| 琪琪一区二区三区| 欧美综合一区二区| 国产精品久久国产精麻豆99网站| 久久精品噜噜噜成人av农村| 日本道色综合久久| 中文字幕国产一区| 韩国女主播成人在线观看| 色94色欧美sute亚洲线路二| 国产精品视频yy9299一区| 精品一区二区三区欧美| 欧美一区二区三区在线看| 亚洲第一福利一区| 色综合天天综合狠狠| 国产亚洲欧美日韩俺去了| 精久久久久久久久久久| 日韩欧美国产三级| 蜜臂av日日欢夜夜爽一区| 日韩美女一区二区三区四区| 国内精品写真在线观看| 国产亚洲婷婷免费| 99国产精品久久久久久久久久| 亚洲欧美中日韩| 在线观看成人小视频| 亚洲成人免费在线| 欧美mv日韩mv国产网站app| 国产在线播放一区| 国产精品久久久久久户外露出| 91亚洲精品久久久蜜桃| 亚洲午夜久久久| 精品日韩在线观看| 国产成人小视频| 亚洲免费av高清| 欧美丰满少妇xxxbbb| 国产专区综合网| 亚洲品质自拍视频网站| 欧美日韩国产123区| 国产一区亚洲一区| 亚洲精品亚洲人成人网在线播放| 欧美日韩一区二区在线观看视频| 久久精品国产久精国产| 国产欧美日韩精品在线| 日本久久一区二区| 久久精品国产久精国产| 国产精品视频你懂的| 欧美欧美欧美欧美| 国产精品白丝av| 一区二区三区成人| 精品88久久久久88久久久| www.日韩av| 六月丁香婷婷久久| 亚洲人成网站影音先锋播放| 日韩三级免费观看| 99久久99久久精品免费观看| 日本最新不卡在线| 中文字幕不卡的av| 7777精品久久久大香线蕉| 高清不卡在线观看| 男人的j进女人的j一区| 中文字幕视频一区二区三区久| 欧美一级精品在线| 一本大道久久a久久综合| 精品亚洲国产成人av制服丝袜| 亚洲欧洲综合另类| 精品久久一二三区| 欧美午夜影院一区| 懂色av一区二区三区免费看| 日本视频在线一区| 亚洲综合久久久久| 中文字幕精品三区| 欧美成人激情免费网| 欧美中文字幕不卡| 成人精品视频.| 免费在线观看精品| 夜夜爽夜夜爽精品视频| 中文无字幕一区二区三区| 日韩一级欧美一级| 欧美体内she精视频|