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

📄 lexer.l

📁 linux 下的源代码分析阅读器 red hat公司新版
💻 L
📖 第 1 页 / 共 2 页
字号:
/*Copyright (c) 2000, Red Hat, Inc.This file is part of Source-Navigator.Source-Navigator is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public License as publishedby the Free Software Foundation; either version 2, or (at your option)any later version.Source-Navigator is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith Source-Navigator; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.*//* * lexer.l * * Copyright (C) 1998 Cyngus Solutions *  * Description: * A GNU flex scanner for the GNU CHILL programming language. * * A few of these keywords are not even recognised in the current version * of the parser, but we will recognise them anyway in the hope that they * will generate warnings/errors to prevent the use of reserved words. */%{#include <stdio.h>#include <string.h>#include "symtab.h"#include "snptools.h"#include "parser.h"#include "emit.h"#include "lexinput.h"#undef YY_INPUT#define YY_INPUT(buf,r,ms) (r = sn_encoded_input(buf, ms)) /* For keeping count of how deep in an #ifdef nest we get. */static int ifdef_nesting = 0;#if 0#define keyword(k) emitarg("keyword", k)#define symbol(s) emitarg("symbol", s)#define literal(kind, text) emitarg(kind"literal", text)#define ident(i) emitarg("ident", i)#define include(i) emitarg("include", i)#else#define keyword(k)#define symbol(s)#define literal(kind, text)#define ident(i)#define include(i)#endif%}whitesp         [ \t]+letter          [A-Za-z]digit           [0-9]digit-sequence  ({digit}|_)+bin-digit       [01]bin-sequence    ({bin-digit}|_)+oct-digit       [0-7]oct-sequence    ({oct-digit}|_)+hex-digit       [0-9A-Fa-f]hex-sequence    ({hex-digit}|_)+bin-literal     [Bb]'{bin-sequence}oct-literal     [Oo]'{oct-sequence}dec-literal     ([Dd]')?{digit-sequence}hex-literal     [Hh]'{hex-sequence}bin-bit-literal	[Bb]'({bin-digit}|_)*'oct-bit-literal [Oo]'({oct-digit}|_)*'hex-bit-literal [Hh]'({hex-digit}|_)*'char-string	[Cc]'{hex-sequence}'char-literal    '(.|"^^"|\^{whitesp}?\(.*\))'bitstr-literal  ({bin-bit-literal}|{oct-bit-literal}|{hex-bit-literal})boolean-literal (FALSE|TRUE)float-literal	((\.{digit-sequence})|({digit-sequence}\.)|({digit-sequence}\.{digit-sequence}))({exponent})?integer-literal ({bin-literal}|{oct-literal}|{dec-literal}|{hex-literal})string-literal  (\"(\"\"|[^\"])*\")|('(''|[^'])*')empty-literal   NULLexponent        [eE]-?{digit-sequence}name            {letter}({letter}|{digit}|_)*known-directvs  (use_seize_file|USE_SEIZE_FILE)(_restricted|_RESTRICTED)?%x COMMENT%x ELSEDIRECTIVE%x PREDIRECTIVE%x DIRECTIVE%x POSTDIRECTIVE%%"/*"		{ BEGIN(COMMENT); sn_advance_column(2); }--.*$ 		{ sn_advance_column(yyleng); }^[ \t]*#[ \t]*include[ \t]*[\"\<].*[\"\>] {  char *filename, *end;  filename = strchr(yytext, '\"');  if (!filename)  {     filename = strchr(yytext, '<');  }   /* Skip the leading delimiter. */  filename++;  end = strchr(filename, '\"');  if (!end)  {     end = strchr(filename, '>');  }  /* Lop off the trailing delimiter. */  *end = 0;  include(filename);  emit_include(filename, sn_line(), sn_column() + (filename - yytext - 1), 	 		 sn_line(), sn_column() + strlen(filename) + 1);  sn_advance_column(yyleng);}^[ \t]*#[ \t]*(if|ifdef).*\n {  sn_advance_line();  sn_reset_column();  ifdef_nesting++;}^[ \t]*#[ \t]*(else|elseif).*\n {  sn_advance_line();  sn_reset_column();  BEGIN(ELSEDIRECTIVE);}^[ \t]*#[ \t]*endif.*\n {  assert(ifdef_nesting >= 0);  sn_advance_line();  sn_reset_column();  /* Just left a non-nested #ifdef. */  ifdef_nesting--;}<ELSEDIRECTIVE>^[ \t]*#[ \t]*endif.*\n {  assert(ifdef_nesting >= 0);  sn_advance_line();  sn_reset_column();  ifdef_nesting--;  if (ifdef_nesting == 0)  {    /* Just fallen out of the nesting with this #endif. */    BEGIN(INITIAL);  }}<ELSEDIRECTIVE>. {  /* Eat conditional code. */  sn_advance_column(1);}<ELSEDIRECTIVE>\n {  /* Ditto. */  sn_advance_line();  sn_reset_column();}^[ \t]*#.*$ {  /* Ignore all other C preprocessor directives. */  sn_advance_column(yyleng);}"<>" {  sn_advance_column(2);  BEGIN(PREDIRECTIVE);}<PREDIRECTIVE>[ \t]+ {  sn_advance_column(yyleng);}<PREDIRECTIVE>\n {  sn_advance_line();  sn_reset_column();} <PREDIRECTIVE>. {  unput(yytext[0]);  BEGIN(DIRECTIVE);}<DIRECTIVE>{known-directvs}[ \t]*[\'\"].*[\'\"] {  char *filename, *end;  /* Skip leading text. */   filename = strchr(yytext, '\'');  if (!filename)  {    filename = strchr(yytext, '"');  }  /* Skip the leading quote marker. */  filename++;    /* Lop off the trailing quote marker. */  end = strchr(filename, '\'');  if (!end)  {    end = strchr(filename, '"');  }  *end = 0;  include(filename);  emit_include(filename, sn_line(), sn_column() + (filename - yytext - 1), 			sn_line(), sn_column() + strlen(filename) + 1);  sn_advance_column(yyleng);  BEGIN(POSTDIRECTIVE);}<DIRECTIVE>[^\< \t\n]+ {  sn_advance_column(yyleng);  BEGIN(POSTDIRECTIVE);

⌨️ 快捷键说明

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