ptree-gen.in
来自「这个程序是关于OpenC++的反射植入机制的编译器」· IN 代码 · 共 185 行
IN
185 行
#!/bin/sh##@beginlicenses@#@license{Grzegorz Jakacki}{2003-2004}@## Permission to use, copy, distribute and modify this software and its # documentation for any purpose is hereby granted without fee, provided that# the above copyright notice appears in all copies and that both that copyright# notice and this permission notice appear in supporting documentation.# # Grzegorz Jakacki make(s) no representations about the suitability of this# software for any purpose. It is provided "as is" without express or implied# warranty.# # Copyright (C) 2003-2004 Grzegorz Jakacki##@endlicenses@##set -xcmdname=`echo $0 | sed 's:.*/::'`cmdline="$0 $*"version=1.0header=ptree-generated.himplementation=ptree-generated.ccinclusion_guard=included_ptree_generated_hkind=noneset_expr() { ##########################################################keywords="\ Comma Assign Cond Infix Pm Cast Unary Throw Sizeof Typeid Typeof New \ Delete Array Funcall Postfix UserStatement DotMember ArrowMember Paren \ StaticUserStatement"header_template='namespace Opencxx{class Ptree;class AbstractTranslatingWalker;class AbstractTypingWalker;class TypeInfo;class Ptree%keyword%Expr : public NonLeaf {public: Ptree%keyword%Expr(Ptree* p, Ptree* q) : NonLeaf(p, q) {} int What() { return nt%keyword%Expr; } Ptree* Translate(AbstractTranslatingWalker* w); void Typeof(AbstractTypingWalker*, TypeInfo&);};}'implementation_template='namespace Opencxx{Ptree* Ptree%keyword%Expr::Translate(AbstractTranslatingWalker* w){ return w->Translate%keyword%(this);}void Ptree%keyword%Expr::Typeof(AbstractTypingWalker* w, TypeInfo& t){ w->Typeof%keyword%(this, t);}}'} set_statement() { ########################################################## keywords="\ If Switch While Do For Try Break Continue Return Goto Case \ Default Label"header_template='namespace Opencxx{class Ptree;class AbstractTranslatingWalker;class Ptree%keyword%Statement : public NonLeaf {public: Ptree%keyword%Statement(Ptree* p, Ptree* q) : NonLeaf(p, q) {} int What() { return nt%keyword%Statement; } Ptree* Translate(AbstractTranslatingWalker* w);};}'implementation_template='namespace Opencxx{Ptree* Ptree%keyword%Statement::Translate(AbstractTranslatingWalker* w){ return w->Translate%keyword%(this);}}'}set_word() { ##########################################################keywords="\ AUTO BOOLEAN CHAR WCHAR CONST DOUBLE EXTERN FLOAT FRIEND \ INLINE INT LONG MUTABLE NAMESPACE PRIVATE PROTECTED PUBLIC REGISTER SHORT \ SIGNED STATIC UNSIGNED USING VIRTUAL VOID VOLATILE UserKeyword2"header_template='namespace Opencxx{class Token;class Leaf%keyword% : public LeafReserved {public: Leaf%keyword%(Token& t) : LeafReserved(t) {} Leaf%keyword%(char* str, int len) : LeafReserved(str, len) {} int What() { return %keyword%; }};}'implementation_template=''}fail() { ########################################################## echo "$cmdname: $*" >&2 exit 1}help() { ##########################################################cat << __END__ USAGE: $cmdname [OPTION] --help print this help and exit --version print version and exit __END__}##########################################################while test "x$1" != x; do case "$1" in expr|statement|word) kind="$1";; --help) help; exit;; --version) echo $cmdname $version; exit;; *) fail "unknown argument \`$1'" esac shiftdoneset -erm -f $header $implementationecho "#ifndef $inclusion_guard" >$headerecho "#define $inclusion_guard" >>$headerecho '#include <opencxx/parser/NonLeaf.h>' >>$headerecho '#include <opencxx/parser/LeafReserved.h>' >>$headerecho '#include <opencxx/parser/token-names.h>' >>$headerecho "// DO NOT EDIT!!! Generated with \`$cmdline'" >>$headerecho "// DO NOT EDIT!!! Generated with \`$cmdline'" >>$implementationecho '#include <opencxx/parser/ptree-generated.h>' >>$implementationecho '#include <opencxx/parser/AbstractTypingWalker.h>' >>$implementationecho '#include <opencxx/parser/AbstractTranslatingWalker.h>' >>$implementationfor kind in expr statement word; do echo -n "$cmdname: generating $kind:" eval "set_$kind" for keyword in $keywords; do echo -n " $keyword" echo "$header_template" | sed 's/%keyword%/'$keyword'/g' >>$header echo "$implementation_template" | sed 's/%keyword%/'$keyword'/g' >>$implementation done echo ""doneecho "#endif /* ! defined($inclusion_guard) */" >>$header
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?