⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 separse.y

📁 功能丰富的串口通讯程序
💻 Y
字号:
%{#include <stdio.h>#include <ctype.h>#include "SeParse.h"void (*callbackProc)();%}%token <sval> WORD%union {  char *sval;}%start Script%%Script		: Script FunCall		    | Empty;FunCall		: FunName '(' ArgList ')' ';'			{ (*callbackProc)(3, NULL); };FunName		: WORD { (*callbackProc)(1, $1); };ArgList		: Args  		    | Empty;Args	    : Args ',' Arg		    | Arg;Arg		    : WORD { (*callbackProc)(2, $1); };Empty		:;%%voidParseThis(line, callback)	 char     *line;	 void     (*callback)();{  callbackProc = callback;  scSetInputBuffer(line);  yyparse();}void yyerror(char *msg){  (*callbackProc)(4, msg);}#ifdef TESTvoid SignalBeginFunction(char *name){  printf("** Function call: %s(", name);}void SignalArg(char *arg){  char *p = arg;  printf("\n++Arg: (");  while (*p) {    if (isprint(*p))      putchar(*p);    else       printf("\\0%o", (int)*p);    p++;  }  putchar(')');}void SignalEndFunction(){  printf("\n)\n");}voidmain(int argc, char *argv[]){  char long_line[1000];  char input_str[] = "This(is, a, real, funky); script();            Scripts(); Can(be); Multi(Line, \"Can't they?\");            Commas(are, no, longer, optional, inside, arglists);	    Scripts(); Can(); contain(\"tabs \\t and backspaces \\b\");	    As(\"Well\\ as Quoted Strings\", and, '\"Quoted Strings inside	    quoted strings\"');	esc(can, appear, outside, strings, ^z, \\012\\015\\n);	    But(parenthesis, should, match);  We(\"have a funny way of specifying \\012 chars and even)\"); 	backslashes( \" \\\\ \");  new(\"in this version are ^m and ^A ctr-escapes, as in ^S^Q\"); The(next, line, will, give, a, syntax, error, because, it, has, two, adj, functions,	without, a, separating, semicolon); End() script()";  printf("------ String to parse: \n%s\n\n---- Parsing begins:\n", input_str);  strcpy(long_line, input_str);  ParseThis(long_line);  strcpy(long_line, input_str);  ParseThis(long_line);}#endif TEST

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -