Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/src/graphviz_lex.ll @ 47

Last change on this file since 47 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.4 KB
Line 
1%{
2//=======================================================================
3// Copyright 2001 University of Notre Dame.
4// Author: Lie-Quan Lee
5//
6// Distributed under the Boost Software License, Version 1.0. (See
7// accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//=======================================================================
10
11// Include this first, since it declares YYSTYPE which will
12// be defined in "*parser.h" if not previosly declared here.
13
14
15#include "yystype.h"
16#define YY_DECL   int yylex(YYSTYPE* lvalp)
17
18// When GRAPHVIZ_DIRECTED is declared it means Boost.Build is used.
19// Headers for directed and undirected graphs are both generated, and
20// have different names.
21#ifdef GRAPHVIZ_DIRECTED
22    #if GRAPHVIZ_DIRECTED == 0
23        #define yyerror bgl_undir_error
24        #include "graphviz_graph_parser.hpp"
25    #else
26        #define yyerror bgl_dir_error
27        #include "graphviz_digraph_parser.hpp"
28    #endif
29#else
30    #error Need to define the GRAPHVIZ_DIRECTED macro to either 0 or 1
31#endif
32
33
34#include <string>
35#include <iostream>
36
37static std::string literal;
38static void begin_literal();
39static void add_string(const char* str);
40static void end_literal();
41
42%}
43
44%option noyywrap
45%x Comment
46%x Literal
47
48DIGIT     [0-9]
49ALPHABET  [a-zA-Z_]
50NUMBER    [-+]?({DIGIT}+(\.{DIGIT}*)?|\.{DIGIT}+)([eE][-+]?{DIGIT}+)?
51VARIABLE  {ALPHABET}+({DIGIT}|{ALPHABET})*
52ID        {VARIABLE}|{NUMBER}
53
54%%
55
56"/*"            { BEGIN Comment; }
57<Comment>"*/"   { BEGIN INITIAL; }
58<Comment>.*     ;
59"//".*$         ;
60"#".*$          ;
61"digraph"       { return DIGRAPH_T; }
62"graph"         { return GRAPH_T; }
63"node"          { return NODE_T; }
64"edge"          { return EDGE_T; }
65"strict"        ;
66"subgraph"      { return SUBGRAPH_T; }
67"->"|"--"       { return EDGEOP_T; }
68{ID}            { lvalp->ptr = (void*)(new std::string(yytext)); return ID_T; }
69["]             { BEGIN Literal; begin_literal();  }
70<Literal>["]     { BEGIN INITIAL; end_literal(); lvalp->ptr = (void*)(new std::string(literal)); return ID_T; }
71<Literal>[\\][\n]     ;
72<Literal>([^"\\]*|[\\].)  { add_string(yytext); }
73[ \t]           ;
74\n              ;
75\r              ;
76.               { return yytext[0]; }
77%%
78
79
80void begin_literal() {
81   literal = "";
82}
83
84void add_string(const char* str) {
85   literal += str;
86}
87
88void end_literal() {
89}
90
91void yyerror(char *str)
92{
93  std::cout << str << std::endl;
94}
Note: See TracBrowser for help on using the repository browser.