[VC MFC C++ flex bison] flex example(Pascal-like language scanner)
来源:互联网 发布:ps淘宝主图广告 编辑:程序博客网 时间:2024/05/01 06:58
//scanner.l
%{
/* need this for the call to atof() below */
#include <math.h>
%}
DIGIT [0-9]
ID [a-z][a-z0-9]*
%%
{DIGIT}+ {
printf( "An integer: %s (%d)/n", yytext,
atoi( yytext ) );
}
{DIGIT}+"."{DIGIT}* {
printf( "A float: %s (%g)/n", yytext,
atof( yytext ) );
}
if|then|begin|end|procedure|function {
printf( "A keyword: %s/n", yytext );
}
{ID} printf( "An identifier: %s/n", yytext );
"+"|"-"|"*"|"/" printf( "An operator: %s/n", yytext );
"{"[^}/n]*"}" /* eat up one-line comments */
[ /t/n]+ /* eat up whitespace */
. printf( "Unrecognized character: %s/n", yytext );
%%
main( argc, argv )
int argc;
char **argv;
{
++argv, --argc; /* skip over program name */
if ( argc > 0 )
yyin = fopen( argv[0], "r" );
else
yyin = stdin;
yylex();
}
以下方法生成:
fl scanner
- [VC MFC C++ flex bison] flex example(Pascal-like language scanner)
- [VC MFC C++ flex bison] flex format
- [VC MFC C++ flex bison] flex rules(规则)
- [VC MFC C++ flex bison] flex 特别action
- flex bison
- bison & flex
- flex&bison
- flex bison
- flex&&bison
- Flex&Bison Tips - 如何改善 flex & bison 在VC下的编辑环境
- Flex/Lex&Bison/Yacc
- flex and bison.[link]
- Bison-Flex 笔记
- flex&bison 学习笔记
- Bison-Flex 笔记
- Bison-Flex 笔记
- Bison-Flex 笔记
- Bison-Flex 笔记
- 工厂方法模式
- 常用编辑器之列/块选择方法及快捷方式大集中
- [VC MFC C++ flex bison] flex 特别action
- Windows.Server.2008.RTM
- TREEVIEW数据库绑定
- [VC MFC C++ flex bison] flex example(Pascal-like language scanner)
- MySQL优化经验
- Agile 敏捷建模思想
- CSDN新功能建议
- 用streambuf简单封装socket
- 生活小技巧
- 这个冬天有大雪
- 如何导出存储过程和自定义函数?
- 中文字符无法在CB中编译