Professional Documents
Culture Documents
Examples For Ebnf2ps Automatic Railroad Diagram Drawing
Examples For Ebnf2ps Automatic Railroad Diagram Drawing
Diagram Drawing
Peter Thiemann, Michael Walter
Wilhelm-Schickard-Institut, Universität Tübingen
Sand 13, 72076 Tübingen
E-mail: {thiemann,walterm}@informatik.uni-tuebingen.de
c 1996, Peter Thiemann
May 18, 1996
Contents
1 gofer.BNF
This section gives a summary of the grammar for the language used by Gofer.
Gofer's BNF is originally taken from Mark Jones's Gofer distribution. The
diagrams have been produced with:
> Ebnf2ps -verbose
-titleFont Palatino-BoldItalic
-ntFont Palatino-Bold
-ntBoxColor RoyalBlue
-tFont Courier
-tColor White
-tBg RoyalBlue
-fatLineWidth 50
+simplify
gofer.BNF '.*'
using colors:
ntColor (0,0,0)
tColor (255,255,255)
lineColor (0,0,0)
ntBoxColor (65,105,225)
tBoxColor (0,0,0)
ntBg (255,255,255)
tBg (65,105,225)
titleColor (0,0,0)
1
1 GOFER.BNF 2
module
{ topdecls }
interp
whereClause
exp
topdecls
topdecls ; topdecls
dataDecl
typeDecl
infixDecl
primDecl
class
inst
decls
dataDecl
|
varid
data conid = constr
typeDecl
varid
type conid = type
1 GOFER.BNF 3
infixDecl
infixl ,
digit
infixr op
infix
constrs
constrs | constrs
type
conid
constr
type
conid
primDecl
prims
var string
sigType
context =>
type
1 GOFER.BNF 4
context
pred
( )
pred
pred
conid type
type
–> type
ctype
ctype
atype
conid
atype
atype
varid
,
(
, type
type )
[ type ]
class
cbody
where { cdecls }
cdecls
cdecls ; cdecls
var :: type
whereClause
fun rhs
inst
ibody
where { idecls }
idecls
idecls ; idecls
whereClause
fun rhs
decls
decls ; decls
var :: sigType
fun whereClause
rhs
lhsPat
1 GOFER.BNF 6
rhs
= exp
gdRhs
gdRhs
| exp = exp
whereClause
where { decls }
fun
var
pat varop
( )
varop pat
fun apat
( fun )
exp
\ apat –>
:: sigType
opExp
1 GOFER.BNF 7
opExp
opExp op opExp
pfxExp
pfxExp
–
appExp
appExp
appExp
atomic
atomic
var
con
integer
float
char
string
op
(
exp )
op exp )
[ list ]
( exp , exp )
1 GOFER.BNF 8
list
exp
| quals
, exp
exp ..
, exp
.. exp
quals
quals , quals
let { decls }
exp
alts
alts ; alts
gdAlt
pat
var
+ integer
_
apat
1 GOFER.BNF 9
lhsPat
apat
apat
@ pat
var
~ pat
con
integer
char
string
conop
(
pat )
conop pat )
pat
[ ]
( pat , pat )
var
varid
–
( )
varsym
1 GOFER.BNF 10
op
varop
conop
varop
varsym
‘ varid ‘
con
conid
( consym )
conop
consym
‘ conid ‘
integer
digit
float
e –
integer
E
integer . integer
1 GOFER.BNF 11
varsym
symbol
symbol :
preSymbol
consym
symbol
:
:
varid
letter
digit
’
small
conid
letter
digit
’
large
string
character
" "
char
’ character ’
1 GOFER.BNF 12
character
letter
digit
symbol
preSymbol
integer
\ b
"
letter
small
large
1 GOFER.BNF 13
small
z
1 GOFER.BNF 14
large
Z
1 GOFER.BNF 15
digit
octit
7
1 GOFER.BNF 16
hexit
digit
cntrl
large
_
1 GOFER.BNF 17
charesc
"
&
1 GOFER.BNF 18
symbol
&
<
>
preSymbol
~
2 EBNF2PSPARSER.LY 19
2 Ebnf2psParser.ly
Ebnf2psParser.ly is the Happy parser for Ebnf2ps. The diagrams have been
produced with
> Ebnf2ps -verbose
-titleFont AGaramondExp-Bold
-tFont Courier
-borderDistX 650
+simplify
+ebnf
-happy
Ebnf2psParser.ly '.*'
using colors:
ntColor (0,0,0)
tColor (0,0,0)
lineColor (0,0,0)
ntBoxColor (0,0,0)
tBoxColor (0,0,0)
ntBg (255,255,255)
tBg (255,255,255)
titleColor (0,0,0)
from rgbPathDefault: ["/usr/lib/X11", "/usr/local/X11R5/lib/X11"]
generating nonterminals: [".*"]
from Ebnf2psParser.ly
using input path ["/home/walterm/tests/"]
using happyInput
empty productions
produce EBNF file for happyInput
Ebnf2psParser.ly.BNF
produce layout and output
>
ebnf2psparse
EBNF ebnfInput
HAPPY happyInput
YACC yaccInput
ebnfFactors
ebnfFactor
2 EBNF2PSPARSER.LY 20
ebnfInput
ebnfProductions
ebnfNonterminal
id_tok
ebnfOptString
any_string
ebnfProductions
ebnfProduction
ebnfProduction
happyInput
happyCode
{ happyCodeBody }
happyCodeBody
happyCodeItem
happyOptCode
happyCode
2 EBNF2PSPARSER.LY 21
happyProds
happyProd
happyProd
;
happyProdItems happyCode
happyProdItems
happyProdItem
happyProdItem
any_string
id_tok
happyRules
happyRule
happyRule
:: happyCode id_tok
id_tok : happyProds
happyTokInfos
happyTokInfo
happyTokInfo
% id_tok happyTokInfoRest
2 EBNF2PSPARSER.LY 22
happyTokInfoRest
happyCode
id_tok
happyTokenList
happyTokenList
id_tok
happyCode
any_string
yaccInput
%% yaccRules yaccEnd
yaccAction
{ }
yaccEnd
%%
yaccIdent
id_tok
any_string
yaccPrec
yaccAction
% id_tok yaccIdent ;
2 EBNF2PSPARSER.LY 23
yaccRbody
yaccIdent
yaccAction
yaccRhs
yaccRules
yaccRule
yaccRhs
yaccRule
yaccRhs
| yaccRbody yaccPrec
3 HSPARSER.Y 24
3 hsparser.y
This section gives a summary of the LALR(1) syntax for Haskell 1.2. The
yacc le hsparser.y by Maria M. Gutierrez is originally taken from a Glas-
gow Haskell Compiler distribution (The AQUA Team, Departement of Com-
puter Science, University of Glasgow, Scotland: Glasgow FP group page URL
http://www.dcs.gla.ac.uk/fp/). The diagrams have been produced with:
using colors:
ntColor (255,255,255)
tColor (0,0,0)
lineColor (0,0,0)
ntBoxColor (0,0,0)
tBoxColor (0,0,0)
ntBg (0,0,0)
tBg (255,255,255)
titleColor (0,0,0)
from rgbPathDefault: ["/usr/lib/X11", "/usr/local/X11R5/lib/X11"]
generating nonterminals: [".*"]
from hsparser.y
using input path ["/home/walterm/tests/"]
using yaccInput
empty productions
layout
unfold nonterminals
classkey
datakey
defaultkey
importkey
instkey
lazykey
minuskey
modulekey
obrackkey
3 HSPARSER.Y 25
oparenkey
typekey
in the following productions
conk
vark
aapatk
dpatk
iinstd
iclassd
idatad
ityped
defaultd
instd
classd
datad
typed
iimport
module
produce layout and output
>
pmodule
readpreludecore readprelude module
module
MODULE modid maybeexports WHERE
body
body
ocurly maybeimpdecls maybefixes topdecls ccurly
maybeexports
OPAREN export_list CPAREN
export_list
COMMA
export
export
var
DOTDOT
cons
vars
OPAREN CPAREN
DOTDOT
tycon
impspec
HIDING
OPAREN import_list
CPAREN
OPAREN
maybeimpspec
impspec
import_list
COMMA
import
3 HSPARSER.Y 27
import
var
DOTDOT
cons
vars
OPAREN CPAREN
tycon
idata_pragma
GHC_PRAGMA constrs END_PRAGMA
itype_pragma
GHC_PRAGMA ABSTRACT_PRAGMA END_PRAGMA
iclas_pragma
GHC_PRAGMA gen_pragma_list END_PRAGMA
iclasop_pragma
GHC_PRAGMA gen_pragma gen_pragma END_PRAGMA
modname_pragma
MODNAME_PRAGMA modid
restof_iinst_spec
SPECIALISE_PRAGMA type_instpragma_pairs
ival_pragma
GHC_PRAGMA gen_pragma END_PRAGMA
3 HSPARSER.Y 28
gen_pragma
NOINFO_PRAGMA
arity_pragma
NO_PRAGMA
ARITY_PRAGMA INTEGER
update_pragma
NO_PRAGMA
UPDATE_PRAGMA INTEGER
strictness_pragma
NO_PRAGMA
worker_info
OCURLY gen_pragma CCURLY
unfolding_pragma
NO_PRAGMA
MAGIC_UNFOLDING_PRAGMA vark
UNFOLDING_PRAGMA unfolding_guidance core_expr
unfolding_guidance
UNFOLD_ALWAYS
gen_pragma_list
COMMA
gen_pragma
type_pragma_pairs_maybe
NO_PRAGMA
SPECIALISE_PRAGMA type_pragma_pairs
type_pragma_pairs
COMMA
type_pragma_pair
type_pragma_pair
OBRACK type_maybes CBRACK INTEGER worker_info
type_instpragma_pairs
COMMA
type_instpragma_pair
type_instpragma_pair
OBRACK type_maybes CBRACK INTEGER worker_info maybe_name_pragma_pairs
type_maybes
COMMA
type_maybe
type_maybe
NO_PRAGMA
type
3 HSPARSER.Y 30
maybe_name_pragma_pairs
name_pragma_pairs
name_pragma_pairs
COMMA
name_pragma_pair
name_pragma_pair
var EQUAL gen_pragma
core_case_alts
CO_ALG_ALTS core_alg_alts
core_default
CO_PRIM_ALTS core_prim_alts
core_alg_alts
core_alg_alt
core_alg_alt
core_id core_binders RARROW core_expr SEMI
core_prim_alts
core_prim_alt
core_prim_alt
lit_constant RARROW core_expr SEMI
core_default
CO_NO_DEFAULT
corec_binds
SEMI
corec_bind
corec_bind
core_binder EQUAL core_expr
co_scc
CO_PRELUDE_DICTS_CC
co_dupd
CO_ALL_DICTS_CC STRING STRING
CO_USER_CC STRING
STRING STRING co_dupd
CO_AUTO_CC core_id
co_caf
CO_DICT_CC core_id STRING STRING co_dupd
co_caf
NO_PRAGMA
CO_CAF_CC
co_dupd
NO_PRAGMA
CO_DUPD_CC
core_binders
core_binder
core_binder
OPAREN VARID DCOLON core_type CPAREN
3 HSPARSER.Y 32
core_atoms
core_atom_list
OBRACK CBRACK
core_atom_list
COMMA
core_atom
core_atom
lit_constant
core_id
core_tyvars
VARID
core_tv_templates
COMMA
TYVAR_TEMPLATE_ID
core_types
core_type_list
OBRACK CBRACK
core_type_list
COMMA
core_type
core_type
type
3 HSPARSER.Y 33
core_type_maybes
COMMA
core_type_maybe
core_type_maybe
NO_PRAGMA
core_type
readpreludecore
readinterface
readprelude
readinterface
maybeimpdecls
impdecls SEMI
impdecls
SEMI
impdecl
impdecl
IMPORT modid impdecl_rest
impdecl_rest
RENAMING renamings
readinterface maybeimpspec
readinterface
interface LEOF
3 HSPARSER.Y 34
renamings
OPAREN renaming_list CPAREN
renaming_list
COMMA
renaming
renaming
var TO var
con TO con
maybeiimports
iimports SEMI
iimports
SEMI
iimport
iimport
RENAMING renamings
IMPORT modid OPAREN import_list CPAREN
interface
INTERFACE modid WHERE ibody
3 HSPARSER.Y 35
ibody
maybeiimports maybefixes itopdecls
ocurly ccurly
iimports
maybefixes
fixes SEMI
fixes
SEMI
fix
fix
INFIXL
INTEGER
INFIXR
INFIX INTEGER
INFIXL ops
INFIXR
INFIX
ops
COMMA
op
topdecls
SEMI
topdecl
3 HSPARSER.Y 36
topdecl
typed
datad
classd
instd
defaultd
decl
typed
TYPE simple EQUAL type
datad
context DARROW
simple EQUAL constrs
DATA
context DARROW
simple EQUAL constrs DERIVING tyclses
classd
context DARROW
CLASS class cbody
cbody
ocurly decls ccurly
WHERE
vocurly decls vccurly
instd
context DARROW
INSTANCE tycls inst rinst
3 HSPARSER.Y 37
rinst
ocurly instdefs ccurly
WHERE
vocurly instdefs vccurly
inst
tycon
simple_long
atype_list
OPAREN CPAREN
defaultd
DEFAULT dtypes
dtypes
OPAREN type COMMA types CPAREN
ttype
decls
SEMI
decl
3 HSPARSER.Y 38
decl
DARROW type
vars DCOLON type iclasop_pragma
ABSTRACT_UPRAGMA tycon
valdef
howto_inline_maybe
CONID
itopdecls
SEMI
itopdecl
itopdecl
ityped
idatad
iclassd
iinstd
ivarsd
ivarsd
DARROW type
vars DCOLON type ival_pragma
3 HSPARSER.Y 39
ityped
TYPE simple EQUAL type itype_pragma
idatad
iclassd
context DARROW
CLASS class iclas_pragma cbody
iinstd
context DARROW
INSTANCE tycls inst iinst_pragma
class
tycon tyvar
types
COMMA
type
btype
atype
tycon atypes
atypes
atype
3 HSPARSER.Y 40
ttype
ntatype
tycon atypes
atype
ntatype
OPAREN type COMMA types CPAREN
ntatype
tyvar
tycon
type
OPAREN CPAREN
TYVAR_TEMPLATE_ID
simple
tyvars
tycon
simple_long
tycon atypes
constrs
VBAR
constr
3 HSPARSER.Y 41
constr
tycon
atypes
OPAREN CONSYM CPAREN
tycon
OPAREN CONSYM CPAREN
tyclses
tycls_list
OPAREN CPAREN
tycls
tycls_list
COMMA
tycls
context
OPAREN context_list CPAREN
class
context_list
COMMA
class
instdefs
instdef instdef SEMI
3 HSPARSER.Y 42
instdef
INLINE_UPRAGMA vark howto_inline_maybe
END_UPRAGMA
MAGIC_UNFOLDING_UPRAGMA vark vark
valdef
vars
COMMA varsrest
vark
varsrest
COMMA
var
cons
COMMA
con
valdef
opatk valrhs
valrhs
valrhs1 maybe_where
valrhs1
gdrhs
EQUAL exp
gdrhs
gd EQUAL exp
3 HSPARSER.Y 43
maybe_where
ocurly decls ccurly
WHERE
vocurly decls vccurly
gd
VBAR oexp
lampats
apat
exp
DARROW type
DCOLON type
oexp
oexp
oexp op
dexp
dexp
MINUS
kexp
3 HSPARSER.Y 44
kexp
LAMBDA lampats RARROW exp
CCALL cexp
ccallid
CCALL_GC
CASM cexp
CLITLIT
CASM_GC
fexp
fexp
aexp
cexp
aexp
3 HSPARSER.Y 45
aexp
var
con
lit_constant
exp
AT var
OPAREN oexp op CPAREN
LAZY
op1 oexp
tuple
list
sequence
comprehension
WILDCARD
opatk
opat op
dpatk
opat
opat op
dpat
dpat
MINUS
fpat
fpat
aapat
3 HSPARSER.Y 46
dpatk
MINUS fpat
fpatk
fpatk
aapat
aapatk
aapat
con
AT apat
var
lit_constant
WILDCARD
pats
OBRACK CBRACK
LAZY apat
3 HSPARSER.Y 47
aapatk
conk
AT apat
vark
lit_constant
WILDCARD
CPAREN
WILDCARD PLUS INTEGER
OPAREN
COMMA pats
opat CPAREN
pats
OBRACK CBRACK
LAZY apat
tuple
exp COMMA texps
OPAREN CPAREN
texps
COMMA
exp
list
list_exps
OBRACK CBRACK
list_exps
COMMA
exp
3 HSPARSER.Y 48
sequence
COMMA exp
OBRACK exp DOTDOT upto CBRACK
comprehension
OBRACK exp VBAR quals CBRACK
quals
COMMA
qual
qual
exp qualrest
qualrest
LARROW exp
alts
SEMI
alt
alt
pat altrest
altrest
gdpat
maybe_where
RARROW exp
3 HSPARSER.Y 49
gdpat
gd RARROW exp
upto
exp
pats
COMMA
pat
pat
conop
bpat
bpat
apatc
conpat
INTEGER
MINUS
FLOAT
conpat
apat
con
apat
con
apatc
3 HSPARSER.Y 50
apatc
AT apat
var
lit_constant
WILDCARD
CPAREN
WILDCARD PLUS INTEGER
OPAREN
COMMA pats
pat CPAREN
pats
OBRACK CBRACK
LAZY apat
lit_constant
INTEGER
FLOAT
CHAR
STRING
CHARPRIM
STRINGPRIM
INTPRIM
FLOATPRIM
DOUBLEPRIM
CLITLIT
NOREP_INTEGER
INTEGER
NOREP_RATIONAL INTEGER
NOREP_STRING STRING
3 HSPARSER.Y 51
op1
conop
varop1
varop
varsym
BQUOTE VARID BQUOTE
op
conop
varop
varop1
VARSYM
plus
BQUOTE VARID BQUOTE
conop
CONSYM
varsym
VARSYM
plus
minus
minus
MINUS
3 HSPARSER.Y 52
plus
PLUS
var
VARID
vark
VARID
con
tycon
OPAREN CONSYM CPAREN
conk
tycon
OPAREN CONSYM CPAREN
ccallid
VARID
CONID
atype_list
COMMA atype
atype COMMA atype
tyvars
tyvar
3 HSPARSER.Y 53
tyvar
VARID
tycls
tycon
tycon
CONID
modid
CONID
ocurly
layout OCURLY
vocurly
layout
layout<empty production>
ccurly
CCURLY
vccurly
vccurly1
vccurly1
VCCURLY
error
3 HSPARSER.Y
co_primop
CCALL
ccallid OCURLY core_types core_type CCURLY
CCALL_GC
OPAREN CPAREN
CASM
lit_constant OCURLY core_types core_type CCURLY
CASM_GC
VARID
54
3 HSPARSER.Y
core_id
CO_SDSEL_ID tycon tycon
CO_METH_ID
tycon var
CO_DEFM_ID
CO_DFUN_ID tycon
OPAREN core_type CPAREN
CO_WRKR_ID CO_CONSTM_ID tycon var
CO_SPEC_ID core_id OBRACK core_type_maybes CBRACK
var
CO_ORIG_NM modid
con
var
con
iinst_pragma
name_pragma_pairs
GHC_PRAGMA modname_pragma gen_pragma END_PRAGMA
restof_iinst_spec
55