Posted onEdited onWord count in article: 795Reading time ≈1 mins.
This is graph for getting through firewall. This is another method for climbing over the wall.
Phase1. setup the connection between client and server by three-way handshake. when server send ACK and seq to the client. Client should let the wall know this connection is over. So client send FIN and seq to server. The wall get it, and consider the connection from client is over. Because the wall is not based on status. Then server get it, and find the seq of package is wrong. And server send the RESET package to client. The wall get the package and consider the connection from server is over. Client receive and ignore the RESET package, and then it send the ACK and seq+1 to server. The connection between client and server is established. However, the connection between client and server is over from viewpiont of the wall. The wall will not exam contents of the connection. So we can get though the wall!
Warning: Permanently added ‘bazaar.launchpad.net,91.189.90.11’ (RSA) to the
list of known hosts.
Permission denied (publickey).
bzr: ERROR: Connection closed: Unexpected end of message. Please check
connectivity and permissions, and report a bug if problems persist.
ex3.l: In function ‘yylex’:
ex3.l:11: error: ‘yylval’ undeclared (first use in this function)
ex3.l:11: error: (Each undeclared identifier is reported only once
ex3.l:11: error: for each function it appears in.)
ex3.y: In function ‘yyparse’:
ex3.y:26: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type
‘YYSTYPE’
这是因为YYSTYPE这个变量是int型的。所以要在.y文件的%{…%}中添加两行
typedef char* string; #define YYSTPYE string
然后编译成功,却冒出了:
ex3.l: In function ‘yylex’:
ex3.l:10: warning: assignment makes integer from pointer without a cast
这肯定是yylval=strdup(yytext);处没有进行强制转换。于是改为yylval=(int)strdup(yytext);就ok了。但这里的问题
是yylval应该是一个YYSTYPE的变量。但是却必须转换为int型,确实有些诡异。之后又尝试在gcc中添加-Wstrict-
prototypes来查看此错误。结果发现又报一错⚠️ function declaration isn’t a
prototype.这个错误的确是自己从来不喜欢写void造成的。将main()改为main(void)
即可。
%{ typedef char* string; #define YYSTYPE string #include <stdio.h> #include
<string.h> int main(void) { // extern int yyparse(void); yyparse(); return 0;
} int yyerror(char * msg) { printf(“%s is error in line”,msg); } %} %token
NAME EQ AGE %% file : record file | record ; record : NAME EQ NAME {
printf(“%s’s age is equal with %s./n”,$1,$3); } | NAME EQ AGE {
printf(“ssssss/n”); } ; %%
这之后执行:
root@chico-laptop:~/compiler# bison -d ex3.y root@chico-laptop:~/compiler#
flex ex3.l root@chico-laptop:~/compiler# cc -Wstrict-prototypes lex.yy.c
ex3.tab.c -o test root@chico-laptop:~/compiler# ./test
%{ #include #include using namespace std; typedef char*
strings; #define YYSTYPE strings extern “C” { int yyparse(void); int
yylex(void); int yydebug; int yyerror(const char*); } int main(void) { //
extern int yyparse(void); yydebug=1; yyparse(); return 0; } int yyerror(const
char * msg) { printf(“%s is error in line”,msg); } %} %token NAME EQ AGE %%
file : record file | record ; record : NAME EQ NAME { printf(“%s’s age is
equal with %s./n”,$1,$3); } | NAME EQ AGE { printf(“ssssss/n”); } ; %%
ex4.l
%{ #include <stdio.h> #include “ex4.tab.h” %} name [a-zA-Z][a-zA-Z0-9]* age
[1-9][0-9]* eq = %% {name} {yylval=(int)strdup(yytext); return NAME;} {age}
{yylval=(int)strdup(yytext); return AGE;} {eq} {return EQ;} %% int
yywrap(){return 1;}
编译指令:
root@chico-laptop:~/compiler# bison -d ex4.y root@chico-laptop:~/compiler#
flex ex4.l root@chico-laptop:~/compiler# cc -c lex.yy.c -o lex.yy.o root
@chico-laptop:~/compiler# c++ lex.yy.o ex4.tab.c -o ex4test
常见的编译error和warning有:
ex4.tab.c:1519: warning: deprecated conversion from string constant to ‘char*’
这里去查看了一下ex4.tab.c发现是函数yyerror的问题,将int yyerror(char*)改为int yyerror(const
char*)即可。
另外不要typedef char* string;这可能会重,不定义又会报出:
ex4.y: In function ‘int yyparse()’:
ex4.y:36: warning: cannot pass objects of non-POD type ‘struct
std::basic_string<char, std::char_traits, std::allocator >’
through ‘…’; call will abort at runtime
让我们看一下 Lex 描述我们所要匹配的标记的规则。(我们将使用 C 来定义标记匹配后的动作。)继续看我们的字数统计程序,下面是标记匹配的规则。
** 字数统计程序中的 Lex 规则 **
{words} { wordCount++; /*
increase the word count by one*/ }
{whitespace} { /* do
nothing*/ }
{numbers} { /* one may
want to add some processing here*/ }
%%
C 代码
{% typedef char* string; #define YYSTYPE string %} %token NAME EQ AGE %% file : record file | record ; record : NAME EQ AGE { printf("%s is %s years old!!!/n", $1, $3); } ; %% int main() { yyparse(); return 0; } int yyerror(char *msg) { printf("Error encountered: %s /n", msg); }
Posted onEdited onWord count in article: 5kReading time ≈5 mins.
程序员能力矩阵 by XGuru is licensed under a
Creative Commons 署名-非商业性使用-相同方式共享 2.5 中国大陆 License . 原文请看 [ 这 里
](http://www.indiangeek.net/wp-
content/uploads/Programmer%20competency%20matrix.htm) 。
Thanks to bearice for debugging.
Thanks to John Haugeland for a reformatting of it that
works much more nicely on the web.
[译文]程序员能力矩阵 Programmer Competency Matrix
注意:每个层次的知识都是渐增的,位于层次 _ n _ ,也蕴涵了你需了解所有低于层次 _ n _ 的 知识。
This is an often under rated but very critical criteria for judging a
programmer. With the increase in outsourcing of programming tasks to places
where English is not the native tongue this issue has become more prominent. I
know of several projects that failed because the programmers could not
understand what the intent of the communication was.
同一文件中代码组织
同一文件中组织没有依据
按照逻辑 性或者易接近的方法
代码分块和对于其他源文件来说是易于是释,引用其他源文件时有良好的注释
文档头部有许可声 明,总结,良好的注释,一致的空格缩进。文档外观美观。
2 n (Level 0)
n 2 (Level 1)
n (Level 2)
log(n) (Level 3)
Comments
跨文件代码组织
没够想过给代码跨文件组织
相关文件按文件 夹分组
每个物理文件都有独立的目的,比如一个类的定义,一个特性的实现等。
代码在物理层组织紧密,在文件名上与 设计和外观相匹配,可以通过文件分布方式洞察设计理念。
源码树组织
一切都放在一个文件夹内
初步地将代码分散进 对应逻辑的文件夹。
没有循环依赖,二进制文件,库,文档,构建,第三方的代码都组织进合适的文件夹内。
源码树的 物理布局与逻辑层次、组织方式相匹配。可以通过目录名称和组织方式洞察设计理念。
The difference between this and the previous item is in the scale of
organization, source tree organization relates to the entire set of artifacts
that define the system.