This commit is contained in:
swaits committed 2011-01-24 14:18:56 -08:00
1 parent 8b0bee50e6
commit 24a962ee4c
15 files changed
+14957

No files matched your search

+116
View File
@@ -0,0 +1,116 @@
\relax
\ifx\hyper@anchor\@undefined
\global \let \oldcontentsline\contentsline
\gdef \contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global \let \oldnewlabel\newlabel
\gdef \newlabel#1#2{\newlabelxx{#1}#2}
\gdef \newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\let \contentsline\oldcontentsline
\let \newlabel\oldnewlabel}
\else
\global \let \hyper@last\relax
\fi
\citation{harel:sta}
\@writefile{toc}{\contentsline {chapter}{\numberline {1}Introduction}{1}{chapter.1}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {1.1}Overview}{1}{section.1.1}}
\@writefile{toc}{\contentsline {section}{\numberline {1.2}Motivation}{1}{section.1.2}}
\@writefile{toc}{\contentsline {section}{\numberline {1.3}Hierarchical State Machines}{1}{section.1.3}}
\@writefile{toc}{\contentsline {chapter}{\numberline {2}Hierarchical State Machine Compiler}{2}{chapter.2}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {2.1}Overview}{2}{section.2.1}}
\@writefile{toc}{\contentsline {section}{\numberline {2.2}Running the Compiler}{2}{section.2.2}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.1}Compiler Options}{3}{subsection.2.2.1}}
\newlabel{hsmc:options}{{2.2.1}{3}{Compiler Options\relax }{subsection.2.2.1}{}}
\newlabel{opt:p}{{2.2.1}{3}{Compiler Options\relax }{subsection.2.2.1}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Compiler Output}{3}{section.2.3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.1}Header File}{3}{subsection.2.3.1}}
\@writefile{toc}{\contentsline {subsubsection}{Event Enumeration}{4}{section*.3}}
\newlabel{hsmc:events}{{2.3.1}{4}{Event Enumeration\relax }{section*.3}{}}
\@writefile{toc}{\contentsline {subsubsection}{State Enumeration}{4}{section*.4}}
\newlabel{hsmc:states}{{2.3.1}{4}{State Enumeration\relax }{section*.4}{}}
\@writefile{toc}{\contentsline {subsubsection}{Common Method Declaration}{5}{section*.5}}
\@writefile{toc}{\contentsline {subsubsection}{Action Method Declarations}{6}{section*.6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.2}Source File}{7}{subsection.2.3.2}}
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Compiler Errors}{7}{section.2.4}}
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Implementing a Machine}{8}{chapter.3}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {3.1}Design}{8}{section.3.1}}
\@writefile{toc}{\contentsline {section}{\numberline {3.2}Compile}{8}{section.3.2}}
\@writefile{toc}{\contentsline {section}{\numberline {3.3}Implement}{8}{section.3.3}}
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Examples}{9}{chapter.4}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Traffic Signal}{9}{section.4.1}}
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Soda Machine}{9}{section.4.2}}
\@writefile{toc}{\contentsline {chapter}{\numberline {A}Frequently Asked Questions}{10}{appendix.A}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {A.1}FAQ Category}{10}{section.A.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {A.1.1}Question number 1?}{10}{subsection.A.1.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {A.1.2}Question number 2?}{10}{subsection.A.1.2}}
\citation{harel:sta}
\@writefile{toc}{\contentsline {chapter}{\numberline {B}HSM Language Reference}{11}{appendix.B}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {B.1}General}{11}{section.B.1}}
\@writefile{toc}{\contentsline {section}{\numberline {B.2}Lexical Elements}{11}{section.B.2}}
\newlabel{hsm:lexical}{{B.2}{11}{Lexical Elements\relax }{section.B.2}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.1}Character Set}{11}{subsection.B.2.1}}
\newlabel{list:casesensitivity}{{B.1}{12}{Case Sensitivity\relax }{lstlisting.B.1}{}}
\@writefile{lol}{\contentsline {lstlisting}{\numberline {B.1}Case Sensitivity on Identifiers}{12}{lstlisting.B.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.2}Case Sensitivity}{12}{subsection.B.2.2}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.3}Line Format}{12}{subsection.B.2.3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.4}Source Layout}{12}{subsection.B.2.4}}
\newlabel{hsm:file}{{B.2.4}{12}{Source Layout\relax }{subsection.B.2.4}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.5}Keywords}{12}{subsection.B.2.5}}
\newlabel{hsm:keywords}{{B.2.5}{12}{Keywords\relax }{subsection.B.2.5}{}}
\newlabel{list:keywords}{{B.2}{13}{Keywords\relax }{lstlisting.B.2}{}}
\@writefile{lol}{\contentsline {lstlisting}{\numberline {B.2}Keywords}{13}{lstlisting.B.2}}
\newlabel{list:identifiers}{{B.3}{13}{Identifiers\relax }{lstlisting.B.3}{}}
\@writefile{lol}{\contentsline {lstlisting}{\numberline {B.3}Identifier Examples}{13}{lstlisting.B.3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.6}Identifiers}{13}{subsection.B.2.6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.7}Numeric Literals}{13}{subsection.B.2.7}}
\citation{harel:sta}
\citation{samek:psc}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.8}Reserved Words}{14}{subsection.B.2.8}}
\newlabel{hsm:reserved}{{B.2.8}{14}{Reserved Words\relax }{subsection.B.2.8}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.2.9}Comments}{14}{subsection.B.2.9}}
\@writefile{toc}{\contentsline {section}{\numberline {B.3}Scope}{14}{section.B.3}}
\@writefile{toc}{\contentsline {section}{\numberline {B.4}Machines}{14}{section.B.4}}
\newlabel{hsm:machines}{{B.4}{14}{Machines\relax }{section.B.4}{}}
\@writefile{toc}{\contentsline {section}{\numberline {B.5}States}{14}{section.B.5}}
\newlabel{hsm:states}{{B.5}{14}{States\relax }{section.B.5}{}}
\@writefile{toc}{\contentsline {section}{\numberline {B.6}Actions}{15}{section.B.6}}
\newlabel{hsm:actions}{{B.6}{15}{Actions\relax }{section.B.6}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.6.1}Normal}{15}{subsection.B.6.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.6.2}Timed}{15}{subsection.B.6.2}}
\newlabel{hsm:actionstimed}{{B.6.2}{15}{Timed\relax }{subsection.B.6.2}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.6.3}Special}{15}{subsection.B.6.3}}
\@writefile{toc}{\contentsline {section}{\numberline {B.7}Transitions}{15}{section.B.7}}
\newlabel{hsm:transitions}{{B.7}{15}{Transitions\relax }{section.B.7}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.7.1}Normal}{15}{subsection.B.7.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.7.2}Timed}{15}{subsection.B.7.2}}
\newlabel{hsm:transitionstimed}{{B.7.2}{15}{Timed\relax }{subsection.B.7.2}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.7.3}Default}{15}{subsection.B.7.3}}
\newlabel{hsm:default}{{B.7.3}{15}{Default\relax }{subsection.B.7.3}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {B.7.4}Termination}{15}{subsection.B.7.4}}
\newlabel{hsm:termination}{{B.7.4}{15}{Termination\relax }{subsection.B.7.4}{}}
\@writefile{toc}{\contentsline {chapter}{\numberline {C}HSMC lex and yacc Source}{16}{appendix.C}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {C.1}lex, lexical scanner}{16}{section.C.1}}
\@writefile{lol}{\contentsline {lstlisting}{\numberline {C.1}hsmc.l (lex source)}{16}{lstlisting.C.1}}
\@writefile{toc}{\contentsline {section}{\numberline {C.2}yacc, parser}{18}{section.C.2}}
\@writefile{lol}{\contentsline {lstlisting}{\numberline {C.2}hsmc.y (yacc source)}{18}{lstlisting.C.2}}
\@writefile{toc}{\contentsline {chapter}{Glossary}{21}{lstnumber.C.2.128}}
\bibstyle{alpha}
\bibdata{doc}
\bibcite{harel:sta}{Har87}
\bibcite{samek:psc}{Sam02}
\@writefile{toc}{\contentsline {chapter}{Bibliography}{22}{appendix*.7}}
\@writefile{toc}{\contentsline {chapter}{Index}{23}{appendix*.8}}
+14
View File
@@ -0,0 +1,14 @@
\begin{thebibliography}{Sam02}
\bibitem[Har87]{harel:sta}
David Harel.
\newblock Statecharts: {A} {V}isual {F}ormalism for {C}omplex {S}ystems.
\newblock {\em Science of Computer Programming}, 8(3):231--274, 1987.
\bibitem[Sam02]{samek:psc}
Miro Samek.
\newblock {\em Practical Statecharts in C/C++: Quantum Programming for Embedded
Systems}.
\newblock CMP Books, 2002.
\end{thebibliography}
+17
View File
@@ -0,0 +1,17 @@
@ARTICLE{harel:sta,
AUTHOR = "David Harel",
TITLE = "Statecharts: {A} {V}isual {F}ormalism for {C}omplex {S}ystems",
PAGES = "231--274",
JOURNAL = "Science of Computer Programming",
VOLUME = "8",
NUMBER = "3",
YEAR = "1987"
}
@BOOK{samek:psc,
AUTHOR = "Miro Samek",
TITLE = "Practical Statecharts in C/C++: Quantum Programming for Embedded Systems",
PUBLISHER = "CMP Books",
YEAR = "2002",
ISBN = "1578201101",
}
+45
View File
@@ -0,0 +1,45 @@
This is BibTeX, Version 0.99c (Web2c 7.5.2)
The top-level auxiliary file: doc.aux
The style file: alpha.bst
Database file #1: doc.bib
You've used 2 entries,
2543 wiz_defined-function locations,
568 strings with 4623 characters,
and the built_in function-call counts, 650 in all, are:
= -- 61
> -- 16
< -- 2
+ -- 4
- -- 4
* -- 42
:= -- 113
add.period$ -- 6
call.type$ -- 2
change.case$ -- 9
chr.to.int$ -- 2
cite$ -- 2
duplicate$ -- 31
empty$ -- 56
format.name$ -- 8
if$ -- 129
int.to.chr$ -- 1
int.to.str$ -- 0
missing$ -- 3
newline$ -- 13
num.names$ -- 6
pop$ -- 12
preamble$ -- 1
purify$ -- 12
quote$ -- 0
skip$ -- 22
stack$ -- 0
substring$ -- 39
swap$ -- 2
text.length$ -- 2
text.prefix$ -- 2
top$ -- 0
type$ -- 12
warning$ -- 0
while$ -- 6
width$ -- 3
write$ -- 27
BIN
View File
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
\indexentry{\ttfamily Machine|hyperpage}{3}
\indexentry{\ttfamily Action|hyperpage}{4}
\indexentry{\ttfamily Transition|hyperpage}{4}
\indexentry{\ttfamily Terminate|hyperpage}{4}
\indexentry{\ttfamily Machine|hyperpage}{4}
\indexentry{\ttfamily State|hyperpage}{4}
\indexentry{\ttfamily State|hyperpage}{4}
\indexentry{\ttfamily State|hyperpage}{4}
\indexentry{\ttfamily Entry|hyperpage}{6}
\indexentry{\ttfamily Idle|hyperpage}{6}
\indexentry{\ttfamily Exit|hyperpage}{6}
\indexentry{\ttfamily Action|hyperpage}{6}
\indexentry{\ttfamily Machine|hyperpage}{12}
\indexentry{\ttfamily Default|hyperpage}{12}
\indexentry{\ttfamily State|hyperpage}{12}
\indexentry{\ttfamily Transition|hyperpage}{12}
\indexentry{\ttfamily State|hyperpage}{12}
\indexentry{\ttfamily Transition|hyperpage}{12}
\indexentry{\ttfamily Machine|hyperpage}{13}
\indexentry{\ttfamily State|hyperpage}{13}
\indexentry{\ttfamily Default|hyperpage}{13}
\indexentry{\ttfamily Entry|hyperpage}{13}
\indexentry{\ttfamily Idle|hyperpage}{13}
\indexentry{\ttfamily Exit|hyperpage}{13}
\indexentry{\ttfamily Transition|hyperpage}{13}
\indexentry{\ttfamily Action|hyperpage}{13}
\indexentry{\ttfamily Terminate|hyperpage}{13}
\indexentry{blah|hyperpage}{21}
+6
View File
@@ -0,0 +1,6 @@
This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
Scanning input file doc.idx....done (28 entries accepted, 0 rejected).
Sorting entries....done (138 comparisons).
Generating output file doc.ind....done (17 lines written, 0 warnings).
Output written in doc.ind.
Transcript written in doc.ilg.
+17
View File
@@ -0,0 +1,17 @@
\begin{theindex}
\item \ttfamily Action, \hyperpage{4}, \hyperpage{6}, \hyperpage{13}
\item \ttfamily Default, \hyperpage{12, 13}
\item \ttfamily Entry, \hyperpage{6}, \hyperpage{13}
\item \ttfamily Exit, \hyperpage{6}, \hyperpage{13}
\item \ttfamily Idle, \hyperpage{6}, \hyperpage{13}
\item \ttfamily Machine, \hyperpage{3, 4}, \hyperpage{12, 13}
\item \ttfamily State, \hyperpage{4}, \hyperpage{12, 13}
\item \ttfamily Terminate, \hyperpage{4}, \hyperpage{13}
\item \ttfamily Transition, \hyperpage{4}, \hyperpage{12, 13}
\indexspace
\item blah, \hyperpage{21}
\end{theindex}
+338
View File
@@ -0,0 +1,338 @@
This is e-TeXk, Version 3.141592-2.1 (Web2c 7.5.2) (format=latex 2004.6.4) 24 JUN 2004 17:50
entering extended mode
%&-line parsing enabled.
(c:/Program Files/TeXLive/texmf/web2c/cp8bit.tcx)
**doc
(./doc.tex
LaTeX2e <2001/06/01>
Babel <v3.7o> and hyphenation patterns for english, dumylang, nohyphenation, ba
sque, czech, slovak, german, ngerman, spanish, catalan, french, ukenglish, ital
ian, dutch, polish, portuguese, loaded.
(c:/Program Files/TeXLive/texmf/tex/latex/base/report.cls
Document Class: report 2001/04/21 v1.4e Standard LaTeX document class
(c:/Program Files/TeXLive/texmf/tex/latex/base/size10.clo
File: size10.clo 2001/04/21 v1.4e Standard LaTeX file (size option)
)
\c@part=\count79
\c@chapter=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(c:/Program Files/TeXLive/texmf/tex/latex/base/makeidx.sty
Package: makeidx 2000/03/29 v1.0m Standard LaTeX package
)
(c:/Program Files/TeXLive/texmf/tex/latex/tools/verbatim.sty
Package: verbatim 2001/03/12 v1.5p LaTeX2e package for verbatim enhancements
\every@verbatim=\toks14
\verbatim@line=\toks15
\verbatim@in@stream=\read1
)
(c:/Program Files/TeXLive/texmf/tex/latex/listings/listings.sty
Package: listings 2004/02/13 1.2 (Carsten Heinz)
(c:/Program Files/TeXLive/texmf/tex/latex/graphics/keyval.sty
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks16
)
\lst@mode=\count88
\lst@gtempboxa=\box26
\lst@token=\toks17
\lst@length=\count89
\lst@currlwidth=\dimen103
\lst@column=\count90
\lst@pos=\count91
\lst@lostspace=\dimen104
\lst@width=\dimen105
\lst@newlines=\count92
\lst@lineno=\count93
\c@lstlisting=\count94
\lst@maxwidth=\dimen106
(c:/Program Files/TeXLive/texmf/tex/latex/listings/lstpatch.sty
File: lstpatch.sty 2004/02/18 1.2b (Carsten Heinz)
)
(c:/Program Files/TeXLive/texmf/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2004/02/13 1.2 (Carsten Heinz)
\c@lstnumber=\count95
\lst@skipnumbers=\count96
\lst@framebox=\box27
)
(c:/Program Files/TeXLive/texmf/tex/latex/listings/listings.cfg
File: listings.cfg 2004/02/13 1.2 listings configuration
))
(c:/Program Files/TeXLive/texmf/tex/latex/hyperref/hyperref.sty
Package: hyperref 2003/11/30 v6.74m Hypertext links for LaTeX
\@linkdim=\dimen107
\Hy@linkcounter=\count97
\Hy@pagecounter=\count98
(c:/Program Files/TeXLive/texmf/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2003/11/30 v6.74m Hyperref: PDFDocEncoding definition (HO)
)
(c:/Program Files/TeXLive/texmf/tex/latex/texlive/hyperref.cfg
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
)
Package hyperref Info: Option `hyperindex' set `true' on input line 1830.
Package hyperref Info: Option `bookmarksnumbered' set `true' on input line 1830
.
Package hyperref Info: Option `colorlinks' set `true' on input line 1830.
Package hyperref Info: Hyper figures OFF on input line 1880.
Package hyperref Info: Link nesting OFF on input line 1885.
Package hyperref Info: Hyper index ON on input line 1888.
Package hyperref Info: Plain pages ON on input line 1893.
Package hyperref Info: Backreferencing OFF on input line 1900.
Implicit mode ON; LaTeX internals redefined
Package hyperref Info: Bookmarks ON on input line 2004.
(c:/Program Files/TeXLive/texmf/tex/latex/ltxmisc/url.sty
\Urlmuskip=\muskip10
Package: url 2003/11/24 ver 3.0 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 2143.
\Fld@menulength=\count99
\Field@Width=\dimen108
\Fld@charsize=\dimen109
\Choice@toks=\toks18
\Field@toks=\toks19
Package hyperref Info: Hyper figures OFF on input line 2618.
Package hyperref Info: Link nesting OFF on input line 2623.
Package hyperref Info: Hyper index ON on input line 2626.
Package hyperref Info: backreferencing OFF on input line 2633.
Package hyperref Info: Link coloring ON on input line 2636.
\c@Item=\count100
\c@Hfootnote=\count101
)
*hyperref using driver hdvipdfm*
(c:/Program Files/TeXLive/texmf/tex/latex/hyperref/hdvipdfm.def
File: hdvipdfm.def 2003/11/30 v6.74m Hyperref driver for dvipdfm
\pdfm@box=\box28
\Fld@listcount=\count102
\@outlinefile=\write3
)
\@indexfile=\write4
\openout4 = `doc.idx'.
Writing index file doc.idx
(./doc.aux)
\openout1 = `doc.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
(c:/Program Files/TeXLive/texmf/tex/latex/graphics/color.sty
Package: color 1999/02/16 v1.0i Standard LaTeX Color (DPC)
(c:/Program Files/TeXLive/texmf/tex/latex/texlive/color.cfg
File: color.cfg 2001/08/31 v1.1 color configuration of teTeX/TeXLive
)
Package color Info: Driver file: dvips.def on input line 125.
(c:/Program Files/TeXLive/texmf/tex/latex/graphics/dvips.def
File: dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
)
(c:/Program Files/TeXLive/texmf/tex/latex/graphics/dvipsnam.def
File: dvipsnam.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
))
Package hyperref Info: Link coloring ON on input line 13.
(c:/Program Files/TeXLive/texmf/tex/latex/hyperref/nameref.sty
Package: nameref 2003/12/03 v2.21 Cross-referencing by name of section
\c@section@level=\count103
)
LaTeX Info: Redefining \ref on input line 13.
LaTeX Info: Redefining \pageref on input line 13.
(./doc.out)
(./doc.out)
\openout3 = `doc.out'.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <12> on input line 34.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <8> on input line 34.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line 34.
[1
] (./doc.toc
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 2.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 2.
[1
])
\tf@toc=\write5
\openout5 = `doc.toc'.
[2] (./doc.lol)
\tf@lol=\write6
\openout6 = `doc.lol'.
[3
]
Chapter 1.
[1
]
Chapter 2.
Overfull \hbox (17.24684pt too wide) in paragraph at lines 89--89
[] \OT1/cmtt/m/n/10 -o prefix specify prefix for output files [prefix.cpp,
prefix.h][]
[]
[2
]
LaTeX Font Info: Try loading font information for OMS+cmr on input line 157.
(c:/Program Files/TeXLive/texmf/tex/latex/base/omscmr.fd
File: omscmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <9> not available
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 157.
(c:/Program Files/TeXLive/texmf/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2004/02/13 1.2 listings language file
)
(c:/Program Files/TeXLive/texmf/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2004/02/13 1.2 listings language file
)
(c:/Program Files/TeXLive/texmf/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2004/02/13 1.2 (Carsten Heinz)
) [3] [4]
[5] [6]
Overfull \hbox (26.78555pt too wide) in paragraph at lines 377--379
[]
[]
Overfull \hbox (24.18411pt too wide) in paragraph at lines 386--387
[]
[]
Overfull \hbox (63.07977pt too wide) in paragraph at lines 390--391
[]
[]
Overfull \hbox (63.33536pt too wide) in paragraph at lines 394--395
[]
[]
[7]
Chapter 3.
[8
]
Chapter 4.
[9
]
Appendix A.
[10
]
Appendix B.
Overfull \hbox (111.74602pt too wide) in paragraph at lines 476--476
[]\OT1/cmtt/m/n/10 // * A state may contain Default, Entry, Idle, Exit, Transi
tion, Action, and Terminate[]
[]
Overfull \hbox (17.24684pt too wide) in paragraph at lines 481--481
[]\OT1/cmtt/m/n/10 // * Terminate() causes all states to exit, including the r
oot state[]
[]
Overfull \hbox (80.24629pt too wide) in paragraph at lines 482--482
[]\OT1/cmtt/m/n/10 // * nested states must be represented hierarchically in in
put file via {} pairs[]
[]
[11
] [12] [13]
LaTeX Font Info: Font shape `OMS/cmr/m/it' in size <10> not available
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 636.
LaTeX Font Info: Font shape `OMS/cmr/bx/n' in size <10> not available
(Font) Font shape `OMS/cmsy/b/n' tried instead on input line 647.
[14] [15]
Appendix C.
LaTeX Font Info: Try loading font information for OML+cmr on input line 710.
(c:/Program Files/TeXLive/texmf/tex/latex/base/omlcmr.fd
File: omlcmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: Font shape `OML/cmr/m/n' in size <9> not available
(Font) Font shape `OML/cmm/m/it' tried instead on input line 710.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <9> on input line 714.
LaTeX Font Info: Font shape `OMS/cmr/m/it' in size <9> not available
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 725.
Overfull \hbox (15.75119pt too wide) in paragraph at lines 727--731
[][][][][][][][][][][][][][][][][][][][][]
[]
Overfull \hbox (26.85123pt too wide) in paragraph at lines 733--736
[][][][][][][][][][][][][][][][][][][][][][][]
[]
[16
]
Overfull \hbox (10.20117pt too wide) in paragraph at lines 754--755
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
Overfull \hbox (4.65115pt too wide) in paragraph at lines 756--759
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
[17] [18] [19] [20] [21
] (./doc.bbl) [22
] (./doc.ind [23
]) (./doc.aux) )
Here is how much of TeX's memory you used:
4033 strings out of 95538
56407 string characters out of 1190382
120230 words of memory out of 1551190
7062 multiletter control sequences out of 10000+50000
11441 words of font info for 40 fonts, out of 1000000 for 2000
117 hyphenation exceptions out of 1000
33i,6n,70p,228b,869s stack positions out of 5000i,500n,6000p,200000b,40000s
Output written on doc.dvi (27 pages, 115212 bytes).
+5
View File
@@ -0,0 +1,5 @@
\contentsline {lstlisting}{\numberline {B.1}Case Sensitivity on Identifiers}{12}{lstlisting.B.1}
\contentsline {lstlisting}{\numberline {B.2}Keywords}{13}{lstlisting.B.2}
\contentsline {lstlisting}{\numberline {B.3}Identifier Examples}{13}{lstlisting.B.3}
\contentsline {lstlisting}{\numberline {C.1}hsmc.l (lex source)}{16}{lstlisting.C.1}
\contentsline {lstlisting}{\numberline {C.2}hsmc.y (yacc source)}{18}{lstlisting.C.2}
+4241
View File
File diff suppressed because it is too large. Load diff
+53
View File
@@ -0,0 +1,53 @@
\BOOKMARK [0][-]{chapter.1}{1 Introduction}{}
\BOOKMARK [1][-]{section.1.1}{1.1 Overview}{chapter.1}
\BOOKMARK [1][-]{section.1.2}{1.2 Motivation}{chapter.1}
\BOOKMARK [1][-]{section.1.3}{1.3 Hierarchical State Machines}{chapter.1}
\BOOKMARK [0][-]{chapter.2}{2 Hierarchical State Machine Compiler}{}
\BOOKMARK [1][-]{section.2.1}{2.1 Overview}{chapter.2}
\BOOKMARK [1][-]{section.2.2}{2.2 Running the Compiler}{chapter.2}
\BOOKMARK [2][-]{subsection.2.2.1}{2.2.1 Compiler Options}{section.2.2}
\BOOKMARK [1][-]{section.2.3}{2.3 Compiler Output}{chapter.2}
\BOOKMARK [2][-]{subsection.2.3.1}{2.3.1 Header File}{section.2.3}
\BOOKMARK [2][-]{subsection.2.3.2}{2.3.2 Source File}{section.2.3}
\BOOKMARK [1][-]{section.2.4}{2.4 Compiler Errors}{chapter.2}
\BOOKMARK [0][-]{chapter.3}{3 Implementing a Machine}{}
\BOOKMARK [1][-]{section.3.1}{3.1 Design}{chapter.3}
\BOOKMARK [1][-]{section.3.2}{3.2 Compile}{chapter.3}
\BOOKMARK [1][-]{section.3.3}{3.3 Implement}{chapter.3}
\BOOKMARK [0][-]{chapter.4}{4 Examples}{}
\BOOKMARK [1][-]{section.4.1}{4.1 Traffic Signal}{chapter.4}
\BOOKMARK [1][-]{section.4.2}{4.2 Soda Machine}{chapter.4}
\BOOKMARK [0][-]{appendix.A}{A Frequently Asked Questions}{}
\BOOKMARK [1][-]{section.A.1}{A.1 FAQ Category}{appendix.A}
\BOOKMARK [2][-]{subsection.A.1.1}{A.1.1 Question number 1?}{section.A.1}
\BOOKMARK [2][-]{subsection.A.1.2}{A.1.2 Question number 2?}{section.A.1}
\BOOKMARK [0][-]{appendix.B}{B HSM Language Reference}{}
\BOOKMARK [1][-]{section.B.1}{B.1 General}{appendix.B}
\BOOKMARK [1][-]{section.B.2}{B.2 Lexical Elements}{appendix.B}
\BOOKMARK [2][-]{subsection.B.2.1}{B.2.1 Character Set}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.2}{B.2.2 Case Sensitivity}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.3}{B.2.3 Line Format}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.4}{B.2.4 Source Layout}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.5}{B.2.5 Keywords}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.6}{B.2.6 Identifiers}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.7}{B.2.7 Numeric Literals}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.8}{B.2.8 Reserved Words}{section.B.2}
\BOOKMARK [2][-]{subsection.B.2.9}{B.2.9 Comments}{section.B.2}
\BOOKMARK [1][-]{section.B.3}{B.3 Scope}{appendix.B}
\BOOKMARK [1][-]{section.B.4}{B.4 Machines}{appendix.B}
\BOOKMARK [1][-]{section.B.5}{B.5 States}{appendix.B}
\BOOKMARK [1][-]{section.B.6}{B.6 Actions}{appendix.B}
\BOOKMARK [2][-]{subsection.B.6.1}{B.6.1 Normal}{section.B.6}
\BOOKMARK [2][-]{subsection.B.6.2}{B.6.2 Timed}{section.B.6}
\BOOKMARK [2][-]{subsection.B.6.3}{B.6.3 Special}{section.B.6}
\BOOKMARK [1][-]{section.B.7}{B.7 Transitions}{appendix.B}
\BOOKMARK [2][-]{subsection.B.7.1}{B.7.1 Normal}{section.B.7}
\BOOKMARK [2][-]{subsection.B.7.2}{B.7.2 Timed}{section.B.7}
\BOOKMARK [2][-]{subsection.B.7.3}{B.7.3 Default}{section.B.7}
\BOOKMARK [2][-]{subsection.B.7.4}{B.7.4 Termination}{section.B.7}
\BOOKMARK [0][-]{appendix.C}{C HSMC lex and yacc Source}{}
\BOOKMARK [1][-]{section.C.1}{C.1 lex, lexical scanner}{appendix.C}
\BOOKMARK [1][-]{section.C.2}{C.2 yacc, parser}{appendix.C}
\BOOKMARK [0][-]{lstnumber.C.2.128}{Glossary}{}
\BOOKMARK [0][-]{appendix*.7}{Bibliography}{}
\BOOKMARK [0][-]{appendix*.8}{Index}{}
+9068
View File
File diff suppressed because it is too large. Load diff
+952
View File
@@ -0,0 +1,952 @@
\documentclass[titlepage,letterpaper]{report}
\usepackage{makeidx}
\usepackage{verbatim}
\usepackage{listings}
\usepackage[hyperindex,dvipdfm,bookmarksnumbered,colorlinks]{hyperref}
\makeindex
\title{HSM Compiler User Guide}
\author{Stephen Waits}
\begin{document}
% Define State language for listings package
%
\lstdefinelanguage{State}
{morekeywords={Machine,State,Default,Entry,Idle,Exit,Transition,Action,Terminate},
sensitive=false,
morecomment=[l]{//}
}
\lstset{% Configure listings defaults
language=State,
captionpos=b,
tabsize=2,
columns=flexible,
basicstyle=\small,
numberstyle=\tiny,
index={Machine,State,Default,Entry,Idle,Exit,Transition,Action,Terminate}
}
\maketitle
\pagenumbering{roman}
\tableofcontents
\newpage
\lstlistoflistings
\newpage
\pagenumbering{arabic}
\chapter{Introduction}
\section{Overview}
here's an overview of the this document.
\section{Motivation}
why create an HSM language and compiler?
\section{Hierarchical State Machines}
brief description on how hsm's work \cite{harel:sta}.
\chapter{Hierarchical State Machine Compiler}
\section{Overview}
\emph{hsmc} is a command line based compiler, named \emph{hsmc.exe}. It reads an HSM
source input file, compiles it, and outputs two files (\emph{.cpp} and \emph{.h}). Each HSM source
input file must define at least one valid Machine. Only one input file can be compiled
at a time; however, that file may contain multiple Machine definitions (see \ref{hsm:file}).
\section{Running the Compiler}
Invoking \emph{hsmc} from the command line should print a usage statement:
\begin{verbatim}
HSMC - Hierarchical State Machine Compiler
Usage: hsmc [-hdpq] [-o prefix] source_file
-h this help
-d include debugging information
-p actions declared as pure virtual
-q quiet mode (only output errors)
-o prefix specify prefix for output files [prefix.cpp,prefix.h]
source_file HSM source file
\end{verbatim}
To compile your HSM file using all defaults, you need only specify your source
filename. For example:
\begin{verbatim}
hsmc myfile.hsm
\end{verbatim}
outputs two files upon successful compilation: \emph{myfile.cpp} and \emph{myfile.h}.
\subsection{Compiler Options}
\label{hsmc:options}
\begin{description}
\item[-h] Prints the usage statement. This is equivalent to running \emph{hsmc} with no parameters.
\item[-d] Include debugging information in the generated machine. This includes considerably more
calls to HSMDebug. The debug strings are also available via HSMGetLastDebugMessage.
The debug strings consist of descriptions of the current state, current transitions, or
diagnostic messages.
\item[-p] Actions, by default, are declared virtual member methods and defined to be empty. This flag
causes these methods to be declared pure virtual and remain undefined. \label{opt:p}
\item[-q] By default, \emph{hsmc} will output status messages during parsing, compilation, and code
generation. Specifying this flag causes the output to be quieted such that only errors
are emitted.
\item[-o prefix] Specifies the output filename prefix. By default this is set to the input filename
after it's been stripped of its extension. So, for \emph{input.hsm}, the default
output prefix is \emph{input}.
To generate \emph{output.cpp} and \emph{output.h} from the input file \emph{input.hsm},
you should specify the prefix explicitly:
\begin{verbatim}
hsmc -o output input.hsm
\end{verbatim}
The output prefix may include a prepended directory path as well.
\end{description}
\section{Compiler Output}
The \emph{hsmc} compiler outputs a C++ header file and a C++ source file.
\subsection{Header File}
The header file declares one class for each machine defined in the HSM source input
file.
Each machine class enumerates events, enumerates states, declares several methods
common to all machines, and declares all actions (virtual) which should be overriden
before the machine is instanced.
For example, a machine declaration of:
\begin{lstlisting}
Machine(MyMachine,16)
{
...
}
\end{lstlisting}
generates a class declaration of:
\begin{lstlisting}[language=C++]
class MyMachine
{
public:
...
};
\end{lstlisting}
\subsubsection{Event Enumeration}
\label{hsmc:events}
A single \emph{enum} entry is generated for each event identifier referenced in
the HSM source input file. This enumeration is within the scope of the machine
class.
For example, the following HSM source fragment:
\begin{lstlisting}
Action(MOUSE_INPUT,BeepSound);
Transition(KEYBOARD_INPUT,NextState);
Terminate(CRITICAL_EVENT);
\end{lstlisting}
compiles to the following event enumeration:
\begin{lstlisting}[language=C++]
// events
enum
{
MOUSE_INPUT = 0,
KEYBOARD_INPUT,
CRITICAL_EVENT
___HSM_NUM_EVENTS___
};
\end{lstlisting}
\subsubsection{State Enumeration}
\label{hsmc:states}
A single \emph{enum} entry is generated for each state defined for a given machine in
the HSM source input file. This enumeration is within the scope of the machine
class.
For example, the following HSM source fragment:
\begin{lstlisting}
Machine(MyMachine,16)
{
State(BootUp) { ... }
State(AwaitInput) { ... }
State(ProcessInput) { ... }
...
}
\end{lstlisting}
compiles to the following state enumeration:
\begin{lstlisting}[language=C++]
// states
enum
{
TOPSTATE = 0,
BootUp,
AwaitInput,
ProcessInput,
___HSM_NUM_STATES___
};
\end{lstlisting}
The logical name of the root state is \emph{TOPSTATE}, as described in section \ref{hsm:machines}.
\subsubsection{Common Method Declaration}
These method declarations are common to every machine.
\begin{lstlisting}[language=C++]
public:
int HSMGetCurrentState() const;
bool HSMIsRunning() const;
void HSMConstruct();
void HSMDestruct();
bool HSMUpdate(float dt = 0.0f);
void HSMTrigger(int event);
char* HSMGetLastDebugMessage();
protected:
// debug hook (override this to trap debug messages)
virtual void HSMDebug(char* msg);
\end{lstlisting}
\begin{description}
\item[int HSMGetCurrentState() const;]
returns an integer, the enumeration id number of the current state as enumerated
in the event numeration (\ref{hsmc:events}). A negative integer (<0) is returned if
the machine is not running.
\item[bool HSMIsRunning() const;]
returns \emph{true} if the machine has been constructed and is presently in a valid state.
returns \emph{false} if \emph{TOPSTATE} has exited, or the machine has not been constucted,
or the machine has been destroyed.
\item[void HSMConstruct();]
Called on a non-running machine to initialize the HSM, and cause a transition into \emph{TOPSTATE}.
This does nothing if the machine is already running.
\item[void HSMDestruct();]
Called on a running machine to cause an immediate transition to \emph{TOPSTATE}, followed by
the exit of \emph{TOPSTATE}. This does nothing if the machine is not running.
\item[bool HSMUpdate(float dt = 0.0f);]
Updates any timers according to \emph{dt}, adds an \emph{IDLE} event to the end of the event
queue, and then processes all events up to that \emph{IDLE} event.
\item[void HSMTrigger(int event);]
Adds event to the event queue. If event is invalid, it's ignored. The event queue is processed
on the next call to HSMUpdate().
\item[char* HSMGetLastDebugMessage();]
Returns a private character pointer to the last debug message. This debug string is a textual
description of the last operation the machine performed, such as a transition, entry into a
state, or idling in a state.
See \ref{hsmc:options} for information on how to enable debugging information.
\item[virtual void HSMDebug(char* msg);]
This function is empty by default and has no effect. It is called throughout the machine internals
with debug messages; therefore, if you prefer immediate access to these messages, you should override
this function with your own. This allows you to trap debug messages as they happen.
These debug messages are the same as are accessible via HSMGetLastDebugMessage().
See \ref{hsmc:options} for information on how to enable debugging information.
\end{description}
\subsubsection{Action Method Declarations}
Action methods are user defined functions which need to be called by the HSM. These actions
are defined by Entry, Idle, Exit, and Action statements (see \ref{hsm:actions}).
For example, the source input fragment:
\begin{lstlisting}
Entry(MyEntryFunc);
Idle(MyIdleFunc);
Exit(MyExitFunc);
Action(SomeEvent, MySomeEventFunc);
\end{lstlisting}
is compiled to:
\begin{lstlisting}[language=C++]
protected:
// actions
virtual void MyEntryFunc();
virtual void MyIdleFunc();
virtual void MyExitFunc();
virtual void MySomeEventFunc();
\end{lstlisting}
Note that if the pure virtual option is specified (see \ref{hsmc:options}) then these methods
would instead be declared as follows:
\begin{lstlisting}[language=C++]
protected:
// actions
virtual void MyEntryFunc() = 0;
virtual void MyIdleFunc() = 0;
virtual void MyExitFunc() = 0;
virtual void MySomeEventFunc() = 0;
\end{lstlisting}
\subsection{Source File}
The source file contains all of the inner workings of the HSM. In general, you need
know nothing about this file to use \emph{hsmc}. You may wish to browse through it
in case you're curious about how the machines are implemented or if you're debugging
your machine behavior.
\section{Compiler Errors}
You may encounter one or more of the following diagnostic error messages while
compiling with \emph{hsmc}. No output files are generated in the case of any error.
\begin{description}
\item[source line number: Invalid event queue size for Machine 'machinename']
The parser was not able to determine a valid queue size in the
declaration of 'machinename'. See \ref{hsm:machines}.
\item[source line number: State 'statename' was previously defined]
A state named 'statename' was already found in this machine. See \ref{hsm:states}.
\item[source line number: multiple Default states defined in State 'statename']
More than one state defined with the same name, 'statename'. See \ref{hsm:states}.
\item[source line number: multiple Transition's on 'eventname' defined in 'statename']
More than one transition defined for a single event (i.e. ambiguous transition). See \ref{hsm:transitions}.
\item[source line number: multiple Terminate's on 'eventname' defined in 'statename']
More than one terminate defined for a single event. See \ref{hsm:termination}.
\item[ERROR: parser failed]
The parser discovered an unrecoverable syntax error. See \ref{hsm:lexical}.
\item[ERROR: unable to open 'filename']
The compiler was unable to open an input file for reading or an
output file for writing. Make sure the input file exists and is readable and
that the output file either doesn't exist, or is writable.
\item[ERROR: compilation aborted due to errors]
The compiler aborted compilation because of errors. These are most likely
semantic errors and will probably have been printed in addition to this
terminal diagnostic.
\end{description}
\chapter{Implementing a Machine}
Step by step instructions on creating a machine, compiling it,
inheriting it, and running it.
\section{Design}
\section{Compile}
\section{Implement}
\chapter{Examples}
\section{Traffic Signal}
\section{Soda Machine}
\appendix
\chapter{Frequently Asked Questions}
\section{FAQ Category}
\subsection{Question number 1?}
Answer number 1.
\subsection{Question number 2?}
Answer number 2.
\chapter{HSM Language Reference}
\begin{verbatim}
// * A state may contain other states
// * A state may contain Default, Entry, Idle, Exit, Transition, Action, and Terminate
// * A single Default is allowed per state
// * There may only be one transition per event
// * Multiple actions are allowed per event
// * Multiple Entry, Idle, and Exit function calls are allowed
// * Terminate() causes all states to exit, including the root state
// * nested states must be represented hierarchically in input file via {} pairs
// * no empty states
\end{verbatim}
\section{General}
The HSM language attempts to embody the most used, most important features
of hierarchical state machines (as described by \cite{harel:sta}). Some features
from Harel's statecharts are missing from the HSM language, such as historic
transitions.
The language is designed to be easy to edit and manipulate, while remaining
syntactically similar to C++.
\section{Lexical Elements}
\label{hsm:lexical}
\subsection{Character Set}
The HSM source character set consists of 74 characters: the space character, the control characters
representing the horizontal tab, and new-line, plus the following 71 graphical characters:
\begin{verbatim}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9
{ } ( ) , ; . _ /
\end{verbatim}
\subsection{Case Sensitivity}
Keywords are not case sensitive. Therefore, \emph{state}, \emph{STATE}, \emph{State}, and
\emph{StAtE} are all equivalent.
However, identifiers are case sensitive. For example, the HSM in listing \ref{list:casesensitivity} defines two states,
named \emph{S} and \emph{s}; as well as two events, named \emph{E} and \emph{e}.
\begin{lstlisting}[caption={Case Sensitivity on Identifiers},label={list:casesensitivity},float,frame=lines,numbers=left]
Machine(m,16)
{
// s is a default transition
Default(s);
// define state 's'
State(s)
{
// on event 'E', transition to state 'S'
Transition(E,S);
}
// define state 'S'
State(S)
{
// on event 'e', transition to state 's'
Transition(e,s);
}
}
\end{lstlisting}
\subsection{Line Format}
Whitespace is completely ignored; therefore, lines do not require separation by new-line
characters, nor any special formatting with space characters.
All keywords other than \emph{Machine} and \emph{State} require a semicolon.
\subsection{Source Layout}
\label{hsm:file}
Each single HSM source input file must define at least one syntactically correct
Machine (see \ref{hsm:machines}). There is no limit to the number of machines allowed
in a single input file.
\subsection{Keywords}
\label{hsm:keywords}
Exactly nine keywords are defined. They are listed in listing \ref{list:keywords} and
described in detail in sections
\ref{hsm:machines},
\ref{hsm:states},
\ref{hsm:actions},
and
\ref{hsm:transitions},
\begin{lstlisting}[caption={Keywords},label={list:keywords},float,frame=lines]
Machine
State
Default
Entry
Idle
Exit
Transition
Action
Terminate
\end{lstlisting}
\subsection{Identifiers}
Identifiers are used to name Machines, States, and Events. The first character of
an identifier must be one of the 53 graphical characters in the set:
\begin{verbatim}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
_
\end{verbatim}
and any characters after the first may be any of the 63 graphical characters in the set:
\begin{verbatim}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
_
0 1 2 3 4 5 6 7 8 9
\end{verbatim}
Identifiers longer than 256 characters are not permitted.
Examples of valid and invalid identifiers may be found in listing \ref{list:identifiers}.
\begin{lstlisting}[caption={Identifier Examples},label={list:identifiers},float,frame=lines]
IDENTIFIER
Identifier
identifier
iDeNtifier
_identifier
_000000
_id0
id100
0id // invalid
100id // invalid
\end{lstlisting}
\subsection{Numeric Literals}
Numeric literals are used in the HSM language to specify event queue size (\ref{hsm:machines}) as well as
time values used in timed actions (\ref{hsm:actionstimed})
and timed transitions (\ref{hsm:transitionstimed}).
They may be whole integers or floating point numbers, and must be positive. They must be composed of the digits
0 through 9, and may include a single decimal point denoted by the period character.
\subsection{Reserved Words}
\label{hsm:reserved}
Ten reserved words are defined. They include the word \emph{TOPSTATE} plus the nine keywords defined in \ref{hsm:keywords}.
These words are all reserved and cannot be used as identifiers.
\subsection{Comments}
The characters \emph{//} start a comment, which terminates with the next new-line character.
\section{Scope}
Scope is controlled with the curly brace characters, \emph{\{} and \emph{\}}. These apply
to Machine and State definitions (see \ref{hsm:machines} and \ref{hsm:states}).
This scoping mechanism is what allows for the nesting of states, making these state
machines hierarchical \cite{harel:sta}.
\section{Machines}
\label{hsm:machines}
\begin{description}
\item[Machine(name,queuesize) \{ ... \}] \emph{name} is the unique identifier for this machine; \emph{queuesize}
is the static size of the event queue and must be a
whole integer greater than 0; \emph{...} is the machine definition
which must qualify as a valid state definition (see \ref{hsm:states}).
\end{description}
Machine is declaration and definition of the root state of a Hierarchical State Machine.
Machine is nearly synonymous with State, with the addition of requiring an event queue size
specification. Therefore, everything valid in the definition of a State is also valid in the definition of
a Machine. As such, a Machine definition may contain zero or more substates; however, it may not be empty.
See \ref{hsm:states}.
The state defined by Machine is the root state
in the state hierarchy. It is identified by the reserved identifier \emph{TOPSTATE} (see \ref{hsm:reserved}),
a convention set forth in \cite{samek:psc}.
This automatic identification is necessary to allow explicit transitions to the root state.
It is the first state entered upon machine construction.
\section{States}
\label{hsm:states}
May contain any number of substates.
\section{Actions}
\label{hsm:actions}
\subsection{Normal}
\subsection{Timed}
\label{hsm:actionstimed}
\subsection{Special}
\section{Transitions}
\label{hsm:transitions}
\subsection{Normal}
\subsection{Timed}
\label{hsm:transitionstimed}
\subsection{Default}
\label{hsm:default}
\subsection{Termination}
\label{hsm:termination}
\chapter{HSMC lex and yacc Source}
\section{lex, lexical scanner}
\begin{lstlisting}[language=C,caption={hsmc.l (lex source)},numbers=left,columns=fixed]
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hsm-parser.tab.h"
int lineno = 1;
void yyerror(char* s);
%}
%%
/* whitespace */
[ \t]+ ; /* skip whitespace */
/* comments */
"//".* ; /* skip C++ comments */
/* punctuation */
"," { return ','; }
";" { return ';'; }
"{" { return '{'; }
"}" { return '}'; }
"(" { return '('; }
")" { return ')'; }
/* keywords */
[Mm][Aa][Cc][Hh][Ii][Nn][Ee] { return MACHINE; }
[Ss][Tt][Aa][Tt][Ee] { return STATE; }
[Dd][Ee][Ff][Aa][Uu][Ll][Tt] { return DEFAULT; }
[Ee][Nn][Tt][Rr][Yy] { return ENTRY; }
[Ii][Dd][Ll][Ee] { return IDLE; }
[Ee][Xx][Ii][Tt] { return EXIT; }
[Tt][Rr][Aa][Nn][Ss][Ii][Tt][Ii][Oo][Nn] { return TRANSITION; }
[Aa][Cc][Tt][Ii][Oo][Nn] { return ACTION; }
[Tt][Ee][Rr][Mm][Ii][Nn][Aa][Tt][Ee] { return TERMINATE; }
/* identifiers */
[a-zA-Z_][a-zA-Z_0-9]* {
if ( strlen(yytext) > 256 )
printf(
"%d: truncating symbol '%s' to 256 characters\n",
lineno,yytext);
strncpy(yylval.string,yytext,256);
return IDENTIFIER;
}
/* constants */
[0-9]+\.?[0-9]* {
yylval.constant = (float)atof(yytext);
return CONSTANT;
}
/* newlines, etc. */
\n { lineno++; }
. ; /* ignore */
%%
int yywrap()
{
return 1;
}
void yyerror(char* s)
{
printf("\n%d: %s at %s\n", lineno, s, yytext);
}
\end{lstlisting}
\section{yacc, parser}
\begin{lstlisting}[language=C,deleteemph={default},caption={hsmc.y (yacc source)},numbers=left,columns=fixed]
%{
extern int yylex();
extern void yyerror(char* s);
#include "main.h"
%}
%union
{
char string[258];
float constant;
}
%token MACHINE
%token STATE
%token DEFAULT
%token ENTRY
%token IDLE
%token EXIT
%token TRANSITION
%token ACTION
%token TERMINATE
%token <string> IDENTIFIER
%token <constant> CONSTANT
%%
machines: machine
| machines machine
;
machine: machine_decl '{' state_items '}'
{
parseEndMachine();
}
;
state_items: state_item
| state_items state_item
;
state_item: state
| statement
;
state: state_decl '{' state_items '}'
{
parseEndState();
}
;
statement: default ';'
| entry ';'
| idle ';'
| exit ';'
| transition ';'
| action ';'
| timetransition ';'
| timeaction ';'
| terminate ';'
;
machine_decl: MACHINE '(' IDENTIFIER ',' CONSTANT ')'
{
parseBeginMachine($3,(int)$5);
}
;
state_decl: STATE '(' IDENTIFIER ')'
{
parseBeginState($3);
}
;
default: DEFAULT '(' IDENTIFIER ')'
{
parseDefault($3);
}
;
entry: ENTRY '(' IDENTIFIER ')'
{
parseEntry($3);
}
;
idle: IDLE '(' IDENTIFIER ')'
{
parseIdle($3);
}
;
exit: EXIT '(' IDENTIFIER ')'
{
parseExit($3);
}
;
transition: TRANSITION '(' IDENTIFIER ',' IDENTIFIER ')'
{
parseTransition($3,$5);
}
;
action: ACTION '(' IDENTIFIER ',' IDENTIFIER ')'
{
parseAction($3,$5);
}
;
timetransition: TRANSITION '(' CONSTANT ',' IDENTIFIER ')'
{
parseTimeTransition($3,$5);
}
;
timeaction: ACTION '(' CONSTANT ',' IDENTIFIER ')'
{
parseTimeAction($3,$5);
}
;
terminate: TERMINATE '(' IDENTIFIER ')'
{
parseTerminate($3);
}
;
\end{lstlisting}
\newpage
\addcontentsline{toc}{chapter}{Glossary}
\chapter*{Glossary}
\begin{description}
\item[blah] A blah is a blah blah blah!\index{blah}
\end{description}
\cleardoublepage
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{alpha}
\bibliography{doc}
\cleardoublepage
\addcontentsline{toc}{chapter}{Index}
\printindex
\end{document}
+57
View File
@@ -0,0 +1,57 @@
\contentsline {chapter}{\numberline {1}Introduction}{1}{chapter.1}
\contentsline {section}{\numberline {1.1}Overview}{1}{section.1.1}
\contentsline {section}{\numberline {1.2}Motivation}{1}{section.1.2}
\contentsline {section}{\numberline {1.3}Hierarchical State Machines}{1}{section.1.3}
\contentsline {chapter}{\numberline {2}Hierarchical State Machine Compiler}{2}{chapter.2}
\contentsline {section}{\numberline {2.1}Overview}{2}{section.2.1}
\contentsline {section}{\numberline {2.2}Running the Compiler}{2}{section.2.2}
\contentsline {subsection}{\numberline {2.2.1}Compiler Options}{3}{subsection.2.2.1}
\contentsline {section}{\numberline {2.3}Compiler Output}{3}{section.2.3}
\contentsline {subsection}{\numberline {2.3.1}Header File}{3}{subsection.2.3.1}
\contentsline {subsubsection}{Event Enumeration}{4}{section*.3}
\contentsline {subsubsection}{State Enumeration}{4}{section*.4}
\contentsline {subsubsection}{Common Method Declaration}{5}{section*.5}
\contentsline {subsubsection}{Action Method Declarations}{6}{section*.6}
\contentsline {subsection}{\numberline {2.3.2}Source File}{7}{subsection.2.3.2}
\contentsline {section}{\numberline {2.4}Compiler Errors}{7}{section.2.4}
\contentsline {chapter}{\numberline {3}Implementing a Machine}{8}{chapter.3}
\contentsline {section}{\numberline {3.1}Design}{8}{section.3.1}
\contentsline {section}{\numberline {3.2}Compile}{8}{section.3.2}
\contentsline {section}{\numberline {3.3}Implement}{8}{section.3.3}
\contentsline {chapter}{\numberline {4}Examples}{9}{chapter.4}
\contentsline {section}{\numberline {4.1}Traffic Signal}{9}{section.4.1}
\contentsline {section}{\numberline {4.2}Soda Machine}{9}{section.4.2}
\contentsline {chapter}{\numberline {A}Frequently Asked Questions}{10}{appendix.A}
\contentsline {section}{\numberline {A.1}FAQ Category}{10}{section.A.1}
\contentsline {subsection}{\numberline {A.1.1}Question number 1?}{10}{subsection.A.1.1}
\contentsline {subsection}{\numberline {A.1.2}Question number 2?}{10}{subsection.A.1.2}
\contentsline {chapter}{\numberline {B}HSM Language Reference}{11}{appendix.B}
\contentsline {section}{\numberline {B.1}General}{11}{section.B.1}
\contentsline {section}{\numberline {B.2}Lexical Elements}{11}{section.B.2}
\contentsline {subsection}{\numberline {B.2.1}Character Set}{11}{subsection.B.2.1}
\contentsline {subsection}{\numberline {B.2.2}Case Sensitivity}{12}{subsection.B.2.2}
\contentsline {subsection}{\numberline {B.2.3}Line Format}{12}{subsection.B.2.3}
\contentsline {subsection}{\numberline {B.2.4}Source Layout}{12}{subsection.B.2.4}
\contentsline {subsection}{\numberline {B.2.5}Keywords}{12}{subsection.B.2.5}
\contentsline {subsection}{\numberline {B.2.6}Identifiers}{13}{subsection.B.2.6}
\contentsline {subsection}{\numberline {B.2.7}Numeric Literals}{13}{subsection.B.2.7}
\contentsline {subsection}{\numberline {B.2.8}Reserved Words}{14}{subsection.B.2.8}
\contentsline {subsection}{\numberline {B.2.9}Comments}{14}{subsection.B.2.9}
\contentsline {section}{\numberline {B.3}Scope}{14}{section.B.3}
\contentsline {section}{\numberline {B.4}Machines}{14}{section.B.4}
\contentsline {section}{\numberline {B.5}States}{14}{section.B.5}
\contentsline {section}{\numberline {B.6}Actions}{15}{section.B.6}
\contentsline {subsection}{\numberline {B.6.1}Normal}{15}{subsection.B.6.1}
\contentsline {subsection}{\numberline {B.6.2}Timed}{15}{subsection.B.6.2}
\contentsline {subsection}{\numberline {B.6.3}Special}{15}{subsection.B.6.3}
\contentsline {section}{\numberline {B.7}Transitions}{15}{section.B.7}
\contentsline {subsection}{\numberline {B.7.1}Normal}{15}{subsection.B.7.1}
\contentsline {subsection}{\numberline {B.7.2}Timed}{15}{subsection.B.7.2}
\contentsline {subsection}{\numberline {B.7.3}Default}{15}{subsection.B.7.3}
\contentsline {subsection}{\numberline {B.7.4}Termination}{15}{subsection.B.7.4}
\contentsline {chapter}{\numberline {C}HSMC lex and yacc Source}{16}{appendix.C}
\contentsline {section}{\numberline {C.1}lex, lexical scanner}{16}{section.C.1}
\contentsline {section}{\numberline {C.2}yacc, parser}{18}{section.C.2}
\contentsline {chapter}{Glossary}{21}{lstnumber.C.2.128}
\contentsline {chapter}{Bibliography}{22}{appendix*.7}
\contentsline {chapter}{Index}{23}{appendix*.8}