summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJohn Millaway <john43@users.sourceforge.net>2006-03-24 18:57:57 +0000
committerJohn Millaway <john43@users.sourceforge.net>2006-03-24 18:57:57 +0000
commitc69e0ec6e6fd5e7018ab78026625c5c04dbf5d54 (patch)
treef28bad7143bda07295fa6b0e47d03c6a29909eca /doc
parentfb6e15fddbfa6a5258c963c881d3aee539c1b1b5 (diff)
Added appendix of patterns to manual.
Diffstat (limited to 'doc')
-rw-r--r--doc/flex.texi98
1 files changed, 85 insertions, 13 deletions
diff --git a/doc/flex.texi b/doc/flex.texi
index 0a9be3e..9a0ac04 100644
--- a/doc/flex.texi
+++ b/doc/flex.texi
@@ -8339,28 +8339,100 @@ scanner is ordinary C or C++, and does @emph{not} require @code{m4}.
This appendix provides examples of common regular expressions you might use
in your scanner.
-Numbers
+@menu
+* Numbers::
+* Quoted Constructs::
+* Addresses::
+@end menu
+
+
+@node Numbers, Quoted Constructs, ,Common Patterns
+@subsection Numbers
@table @asis
-@item an signed integer
-@code{[+-]?([[:digit:]]@{-@}[0])[[:digit:]]*}
+@item C99 decimal constant
+@code{([[:digit:]]@{-@}[0])[[:digit:]]*}
+
+@item C99 hexadecimal constant
+@code{0[xX][[:xdigit:]]+}
+
+@item C99 octal constant
+@code{0[0123456]*}
+
+@item C99 floating point constant
+@verbatim
+ {dseq} ([[:digit:]]+)
+ {dseq_opt} ([[:digit:]]*)
+ {frac} (({dseq_opt}"."{dseq})|{dseq}".")
+ {exp} ([eE][+-]?{dseq})
+ {exp_opt} ({exp}?)
+ {fsuff} [flFL]
+ {fsuff_opt} ({fsuff}?)
+ {hpref} (0[xX])
+ {hdseq} ([[:xdigit:]]+)
+ {hdseq_opt} ([[:xdigit:]]*)
+ {hfrac} (({hdseq_opt}"."{hdseq})|({hdseq}"."))
+ {bexp} ([pP][+-]?{dseq})
+ {dfc} (({frac}{exp_opt}{fsuff_opt})|({dseq}{exp}{fsuff_opt}))
+ {hfc} (({hpref}{hfrac}{bexp}{fsuff_opt})|({hpref}{hdseq}{bexp}{fsuff_opt}))
-@item a hexadecimal constant
-@code{0x[[:xdigit:]]+}
+ {c99_floating_point_constant} ({dfc}|{hfc})
+@end verbatim
+
+See C99 section 6.4.4.2 for the gory details.
+
+@end table
+
+@node Quoted Constructs, Addresses, Numbers, Common Patterns
+@subsection Quoted Constructs
+
+@table @asis
+@item C99 String Literal
+@code{L?\"([^\"\\\n]|(\\['\"?\\abfnrtv])|(\\([0123456]@{1,3@}))|(\\x[[:xdigit:]]+)|(\\[uU]([[:xdigit:]]@{4@})))*\"}
-@item an octal constant
-@code{0[0123456]+}
+@item C99 Comment
+@code{("/*"([^*]|"*"[^/])*"*/")|(/(\\\n)*/[^\n]*)}
-@item a decimal constant
-@code{[+-]([[:digit:]]@{-@}[0])[[:digit:]]*("."[[:digit:]]+)?}
+Note that in C99, a @samp{//}-style comment may be split across lines, and, contrary to popular belief,
+does not include the trailing @samp{\n} character.
-@c TODO
-@item a C99 floating point constant
-@code{[+-] ([[:digit:]]*"."[[:digit:]]+|[[:digit:]]+\.) ([E]?[[:digit:]]+) [FL]? |INF|INFINITY|(NAN("("")")?)}
+A better way to scan @samp{/* */} comments is by line, rather than matching
+possibly huge comments all at once. This will allow you to scan comments of
+unlimited length, as long as line breaks appear at sane intervals. This is also
+more efficient when used with automatic line number processing. @xref{option-yylineno}.
-(See C99 section 6.4.4.2.)
+@verbatim
+<INITIAL>{
+ "/*" BEGIN(COMMENT);
+}
+<COMMENT>{
+ "*/" BEGIN(0);
+ [^*\n]+ ;
+ "*"[^/] ;
+ \n ;
+}
+@end verbatim
+
+@end table
+
+@node Addresses, ,Quoted Constructs, Common Patterns
+@subsection Addresses
+
+@table @asis
+
+@item IPv4 Address
+@code{(([[:digit:]]@{1,3@}".")@{3@}([[:digit:]]@{1,3@}))}
+
+@item IPv6 Address
+@verbatim
+hex4 ([[:xdigit:]]{1,4})
+hexseq ({hex4}(:{hex4}*))
+hexpart ({hexseq}|({hexseq}::({hexseq}?))|::{hexseq})
+IPv6address ({hexpart}(":"{IPv4address})?)
+@end verbatim
+See RFC 2373 for details.
@end table