Ebnf2ps — Automatic Railroad Diagram Drawing Peter Thiemann, Michael Walter Wilhelm-Schickard-Institut, Universit¨at T¨ ubingen Sand 13, 72076 T¨ ubingen E-mail: {thiemann,walterm}@informatik.uni-tuebingen.de c

1996-2014, Peter Thiemann Maintained since 2014 by Franklin Chen [email protected] October 3, 2014 Ebnf2ps was written to fill an urgent need of the author: to produce lots of syntax diagrams (railroad diagrams) from a grammar in EBNF notation in short time. Over the time the program has acquired a couple of features in order to fulfill a variety of requirements. The current version produces highly readable railroad diagrams from grammars in various formats: Yacc, Happy and EBNF. The program may be freely used and distributed, you are however required not to remove the copyright notices from the source files. Please send any comments, bugs, etc. to the author(s).

1

How to build it

Ebnf2ps was written in Haskell, a non–strict, purely functional programming language. Older distributions of this software supported multiple Haskell compilers, but for maintenance, Ebnf2ps is now geared toward building and installing with GHC.

2

How to use it 1. Find out where your TEX installation stores .afm-files (Adobe font metric files). Then set the environment variable AFMPATH when running the program. The .afm-files are absolutely necessary. If you don’t find them

1

complain to your system administrator or get them yourself. One possible source is https://github.com/weiss/original-bsd/tree/master/local/transcript/lib. 2. Set the environment variable RGBPATH to contain the directory where your X installation stores its color data base (usually /usr/lib/X11). There are fallback color definitions for the 8 digital colors (black, white, blue, green, cyan, red, magenta, yellow), so nothing needs be done if that’s enough for you. Note: for Mac OS X, the default /opt/X11/share/X11 has been provided and will work automatically, if you have installed X using XQuartz at http://xquartz.macosforge.org/. The syntax is Ebnf2ps [options] Grammarfile Nonterminal ... [-- Nonterminal ...] where the options are described in Sec. 2.1, the syntax of the input file Grammarfile in Sec. 2.2, and Nonterminal describes the nonterminals, for which diagrams are to be generated, as regular expressions (see Sec. 2.3). The nonterminals after the symbol -- are used only with the option +unfold (see Sec. 2.1 and 2.4).

2.1

Options

The following list shows all options with their parameters and their (default values). All distances and sizes measured in 1/100 point (1 point is about 1/72 n inch). Changes with respect to the last version of Ebnf2ps: some ew features, extension of grammar transformations and bug fixes. -titleFont font (Times-Roman) PostScript font used for titles of diagrams, any font goes here that your printer knows and for which you have fetched n the AFM files. Figure 1 shows a sample list of font names. n -titleScale int (10) Pointsize of typeface for titles of diagrams. n -titleColor color (black) Color of typeface for titles of diagrams. -ntFont font (Times-Roman) PostScript font used for nonterminals. -ntScale int (10) Pointsize of typeface for nonterminals. -ntColor color (black) Color of typeface for nonterminals. n -ntBg color (white) Background color of typeface for nonterminals. n -ntBoxColor color (black) Color used for outlines of boxes (nonterminals). -tFont font (Times-Roman) PostScript font used for terminal strings. -tScale int (10) Pointsize of typeface for terminals. -tColor color (black) Color of typeface for terminals. n -tBg color (white) Background color of typeface for terminals. n -tBoxColor color (black) Color used for outlines of boxes (terminals). 2

-borderDistX int (500) Horizontal distance of objects from their container. -borderDistY int (500) Vertical distance of objects from their container. -lineWidth int (30) Width of lines used for connecting lines. -fatLineWidth int (100) Width of lines used for drawing boxes. -lineColor color (black) Color used for connecting lines. -arrowSize int (200) Size of (invisible) box containing an arrow. -rgbFileName filename (rgb.txt) File name for color definitions. -happy Accept happy format input files. Happy, written by Andy Gill and Simon Marlow, is a parser generator system (LALR(1)) for Haskell, similar to the tool yacc for C1 . n -yacc Accept yacc/bison format input files. +ps Produce encapsulated PostScript output (default). +fig Produce fig output (FORMAT 3.1). +ebnf Produce grammar in EBNF notation (file extension ”.BNF”) for yacc n or happy input format files. +simplify Simplify productions (experimental, default: don’t). +unfold Replace nonterminals in productions (experimental, default: don’t). n See Sec. 2.4. -verbose Prints some progress messages. -help Prints a brief description of the command line, the options with their defaults, and the environment variables.

2.2

Syntax of EBNF Files

The following grammar and diagrams describe the standard input format (e.g. without -yacc or -happy) as well as the output format with the +ebnf option. File Production Term Factor ExtAtom

Atom

1 The

= = = = = | | = | | | | ;

{Production}; Nonterminal [ String ] "=" Term ";" ; Factor / "|" ; # alternative ExtAtom + ; # sequence Atom Atom "/" Atom # repetition through Atom Atom "+"; # at least one repetition Nonterminal String # terminal string "(" Term ")" "[" Term "]" # an optional Term "{" Term "}" # zero or more repetitions

program Happy is available from https://github.com/simonmar/happy

3

AGaramond-Bold AGaramond-Italic AGaramond-Semibold AGaramondAlt-Italic AGaramondExp-Bold AGaramondExp-Italic AGaramondExp-SemiboldItalic AvantGarde-BookOblique AvantGarde-DemiOblique Bookman-DemiItalic Bookman-LightItalic Courier-BoldOblique Courier Helvetica-BoldOblique Helvetica-Narrow-BoldOblique Helvetica-Narrow Helvetica NewCenturySchlbk-BoldItalic NewCenturySchlbk-Roman Optima Palatino-BoldItalic Palatino-Oblique StoneInformal-Bold StoneInformal-Italic StoneInformal-SemiboldItalic StoneSans StoneSerif-BoldItalic StoneSerif-Semibold StoneSerif Times-Bold Times-Italic Times-Roman ZapfDingbats

AGaramond-BoldItalic AGaramond-Regular AGaramond-SemiboldItalic AGaramondAlt-Regular AGaramondExp-BoldItalic AGaramondExp-Semibold AvantGarde-Book AvantGarde-Demi Bookman-Demi Bookman-Light Courier-Bold Courier-Oblique Helvetica-Bold Helvetica-Narrow-Bold Helvetica-Narrow-Oblique Helvetica-Oblique NewCenturySchlbk-Bold NewCenturySchlbk-Italic Optima-Bold Palatino-Bold Palatino-Italic Palatino-Roman StoneInformal-BoldItalic StoneInformal-Semibold StoneInformal StoneSerif-Bold StoneSerif-Italic StoneSerif-SemiboldItalic Symbol Times-BoldItalic Times-Oblique ZapfChancery-MediumItalic

Figure 1: Sample list of font names

4

String Nonterminal Character

= = = |

"\"" { Character } "\"" ; letter { letter | digit | "_" | "." } ; character ["\\"] anycharacter ;

Or in terms of diagrams (what would you expect):

File Production

Production String Nonterminal

=

Term

Term | Factor

Factor ExtAtom

ExtAtom Atom Atom

/

Atom

+

Atom

Atom Nonterminal String (

Term

)

[

Term

]

{

Term

}

String Character "

"

5

;

Nonterminal letter digit _ . letter

Character character \ anycharacter

These diagrams have been produced with Ebnf2ps -tFont Courier-Bold -tBg Black -tColor White -fatLineWidth 50 ebnf.BNF ’.*’.

2.3

Syntax of regular expressions

The regular expressions used to select nonterminal symbols have the following syntax, which is similar to the regular expression syntax of grep. Regexp RFactor RExtAtom RAtom

= = = =

RFactor / "\\|" ["$"]; RExtAtom + ; RAtom ["*" | "+" | "?"] ; character | "\\" character | "." | "\\(" Regexp "\\)" ;

Regular expressions Regexp may be joined by the infix operator |. The resulting regular expression matches any string matching either subexpression. A subexpression may be enclosed in parenthesis \(, \) to override precedence rules. Repetition takes precedence over concatenation, which in turn takes precedence over alternation. A regular expression matching a single character may be followed by one of several repetition operators: ? The preceding item is optional and matched at most once. * The preceding item will be matched zero or more times. + The preceding item will be matched one or more times. The period . matches any single character, and the dollar sign $ match the empty string at the end of a line. Well, graphically, the syntax is2 : 2 The

diagrams have been produced with: Ebnf2ps -titleFont AvantGarde-Book -ntBoxColor White -fatLineWidth 50 regular.BNF ’.*’

6

Regexp \|

$

RFactor RFactor RExtAtom RExtAtom * + ? RAtom RAtom character \

character

. \(

2.4

Regexp

\)

Option +unfold

The option +unfold allows the replacement of nonterminal symbols in productions, through the ”right side” of the production of corresponding nonterminals. The nonterminals, which follows the symbol -- in a command line could be specified by their full names, or by regular expressions (see Sec. 2.3). An example: with the grammar regular.BNF for the regular expression syntax in section 2.3 should be generated a diagram for RAtom, with a replacement of nonterminal Regexp. The following diagram is been produced with Ebnf2ps +unfold regular.BNF RAtom -- Regexp.

7

RAtom character \

character

. \| \(

RFactor

$ \)

The following example illustrates the use of regular expressions with the option +unfold. In all productions of the grammar file ebnf.BNF — which describes the syntax of EBNF files (see Sec. 2.2) — the nonterminal String and all nonterminals that match the pattern .*\(t\|T\)erm.* should be replaced. The next lines shows the command to produce the railroad diagrams and the progress messages of Ebnf2ps. % Ebnf2ps -verbose -tScale 8 -ntScale 8 +unfold ebnf.BNF ’.*’ -- String ’.*\(t\|T\)erm.*’ 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", "/opt/X11/share/X11", "/usr/local/X11R5/lib/X11"] generating nonterminals: [".*"] from ebnf.BNF using input path ["."] using ebnfInput unfold nonterminals: Nonterminal String Term in the following productions Production Atom produce layout and output

Well, graphically that is:

8

Atom letter digit _ . letter Character "

" |

(

Factor

)

| [

Factor

]

| {

Factor

}

Production letter digit _ Character .

"

| "

letter

2.5

=

Factor

;

Environment variables

The format of search paths is a colon separated list of directories. The default path is inserted in place of an empty directory in the list. Any file name starting with / is taken as an absolute name and any file name starting with . is taken relative to the current working directory. AFMPATH search path for Adobe font metric files. EBNFINPUTS search path for grammar input files. RGBPATH search path for the color definitions.

9

Ebnf2ps — Automatic Railroad Diagram Drawing - GitHub

Oct 3, 2014 - Find out where your TEX installation stores .afm-files (Adobe font met- ric files). Then set the environment variable AFMPATH when running the.

230KB Sizes 8 Downloads 114 Views

Recommend Documents

Board Block Diagram & Schematics - GitHub
Jul 1, 2016 - Page 1 ... Designer : drawer : Print Area X:1550 Y:1110. 1 ..... R74. 4.7K. 2. 1. R75. 4.7K. +1.8V. SOIC8. CS. 1. SO. 2. WP. 3. GND. 4. VCC. 8.

Automatic Polynomial Expansions - GitHub
−0.2. 0.0. 0.2. 0.4. 0.6. 0.8. 1.0 relative error. Relative error vs time tradeoff linear quadratic cubic apple(0.125) apple(0.25) apple(0.5) apple(0.75) apple(1.0) ...

Technical Drawing - GitHub
Jan 19, 2017 - SD CARD DETAIL. (OMEGA2+ ONLY). D. C. B. A. A. B. C. D. 1. 2. 3. 4. 5. 6. 7. 8. 8. 7. 6. 5. 4. 3. 2. 1. OMEGA2. TITLE. DIMENSION IN MM.

Drawing - Case - Sheet1 - GitHub
Page 1. 6.000. 6.000. CALIBRATION. U. P. 9. 0 .0. 0. ° R .0. 2. IO SHIELD. CUTOUT. MB Outline 6.693" x 6.693". Keystone swage standoff 0.250". Case edge ...

Technical Drawing - GitHub
Page 1. Page 2. 38.67 ). 22.30. 26.37. Page 3. Page 4. 2.05 。.25. 4.92. 0.75. 「. 4.50. 「 2.85. P。RT AND SW_T〔H. DETA_L. PPPPP. Page 5.

Git Commit Integration Entity Relationship Diagram - GitHub
GithubUser email string ∗ id integer PK username string ∗. User current_sign_in_at datetime current_sign_in_ip string email string ∗ U github_app_token string.

Automatic Score Alignment of Recorded Music - GitHub
Bachelor of Software Engineering. November 2010 .... The latter attempts at finding the database entries that best mach the musical or symbolic .... However, the results of several alignment experiments have been made available online. The.

Automatic Bug-Finding for the Blockchain - GitHub
37. The Yellow Paper http://gavwood.com/paper.pdf ..... address=contract_account, data=seth.SByte(16), #Symbolic buffer value=seth.SValue #Symbolic value. ) print "[+] There are %d reverted states now"% .... EVM is a good fit for Symbolic Execution.

Automatic Model Construction with Gaussian Processes - GitHub
This chapter also presents a system that generates reports combining automatically generated ... in different circumstances, our system converts each kernel expression into a standard, simplified ..... (2013) developed an analytic method for ...

Automatic Model Construction with Gaussian Processes - GitHub
One can multiply any number of kernels together in this way to produce kernels combining several ... Figure 1.3 illustrates the SE-ARD kernel in two dimensions. ×. = → ...... We'll call a kernel which enforces these symmetries a Möbius kernel.

Sample use of automatic numbering - GitHub
Apr 11, 2015 - Exercise 1. This is the first exercise. Have also a look at the Theorem 1.1, the exercise 2 and the exercise 3. Theorem 1.1: Needed for the second exercise. This is a the first theorem. Look at the exercise. 1. Page 2. Exercise 2 (This

Automatic Model Construction with Gaussian Processes - GitHub
just an inference engine, but also a way to construct new models and a way to check ... 3. A model comparison procedure. Search strategies requires an objective to ... We call this system the automatic Bayesian covariance discovery (ABCD).

Union-Pacific-Railroad-MBI-Railroad-Color-History.pdf
There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Union-Pacific-Railroad-MBI-Railroad-Color-Histor

Automatic Generation of Efficient Codes from Mathematical ... - GitHub
Sep 22, 2016 - Programming language Formura. Domain specific language for stencil computaion. T. Muranushi et al. (RIKEN AICS). Formura. Sep 22, 2016.

Automatic Labeling for Entity Extraction in Cyber Security - GitHub
first crawling the web and training a decision clas- sifier to identify ... tailed comparisons of the results, and [10] for more specifics on ... because they are designed to do the best possible with very little ... To build a corpus with security-r

Venn Diagram - Scholastic
Page 1. Venn Diagram http://teacherscholastic.com.

ISD ETVX* Diagram Process ETVX Diagram -
Jul 30, 2004 - Asset Type: Template. Title: ETVX Diagram. PAL Number: 3.5.2.2. GUIDANCE: This template can be used to define an ETVX Diagram. ... Added alternative formats for data tables. Dropped ... This included addition of mapping.

Overview Diagram -
(SLR). Service Level. Targets. Contains everything that defines the service through each stage of the .... Service – A collection of IT systems, components, and.