Benutzer-Werkzeuge

Webseiten-Werkzeuge


ebnf:index

EBNF Parser & Syntax Diagram Renderer

The EBNF Parser & Syntax Diagram Renderer can be used stand-alone or as Dokuwiki-Plugin.

Download and Install

How to use

<ebnf> "EBNF defined in itself" {
syntax     = [ title ] "{" { production } "}" [ comment ].
production = identifier "=" expression ( "." | ";" ) .
expression = term { "|" term } .
term       = factor { factor } .
factor     = identifier
           | literal
           | "[" expression "]"
           | "(" expression ")"
           | "{" expression "}" .
identifier = character { character } .
title      = literal .
comment    = literal .
literal    = "'" character { character } "'"
           | '"' character { character } '"' .
}</ebnf>

syntax=%22EBNF+defined+in+itself%22+%7B+syntax+%3D+%5B+title+%5D+%22%7B%22+%7B+production+%7D+%22%7D%22+%5B+comment+%5D.+production+%3D+identifier+%22%3D%22+expression+%28+%22.%22+%7C+%22%3B%22+%29+.+expression+%3D+term+%7B+%22%7C%22+term+%7D+.+term+%3D+factor+%7B+factor+%7D+.+factor+%3D+identifier+%7C+literal+%7C+%22%5B%22+expression+%22%5D%22+%7C+%22%28%22+expression+%22%29%22+%7C+%22%7B%22+expression+%22%7D%22+.+identifier+%3D+character+%7B+character+%7D+.+title+%3D+literal+.+comment+%3D+literal+.+literal+%3D+%22%27%22+character+%7B+character+%7D+%22%27%22+%7C+%27%22%27+character+%7B+character+%7D+%27%22%27+.+%7D

The script is also available as stand-alone version under: your_dokuwiki/lib/plugins/ebnf/ebnf.php

.../ebnf.php?syntax="EBNF"{ hello = "Hello World". }"Some additional Comments"

Note: The stand-alone script supports also XML output

.../ebnf.php?syntax={ hello = "EBNF Hello World in XML". }&format=xml

Syntax

Todo & Ideas

  • Ellipse … for enumerations. E.g. digits:
    • temp hack in v0.2: function render_node($node, $lefttoright)
       ...
          else {
            if ($text!="...")
      	      rr($im, UNIT, 0, $w-UNIT-1, $h-1, UNIT/2, $black);
            imagestring($im, FONT, 2*UNIT, ($h-imagefontheight(FONT))/2, 
              $text, $text!="..."?$blue:$black);
          } ...
  • Other fonts
  • Configurable dimensions
  • escape-chars and or unicode in terminals
  • Adding Regexp beside terminal and identifiers
  • using a lightweight syntaxtree instead DOM
  • using some standard parsing mechanism
  • support for comments & special-sequences ? … ?
  • replace antialias function
ebnf/index.txt · Zuletzt geändert: von Vincent Tscherter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki