====== EBNF Parser & Syntax Diagram Renderer ====== The //EBNF Parser & Syntax Diagram Renderer// can be used stand-alone or as Dokuwiki-Plugin. ===== Download and Install===== * https://www.dokuwiki.org/plugin:ebnf * Requirements: Make sure to have the [[http://www.php.net/manual/en/image.requirements.php|GD library]] ready :!: ===== How to use ===== "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 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 } '"' . } 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 ===== * See examples: [[examples]] * [[wp>EBNF]] * [[wp>Wirth_syntax_notation]] ===== 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 ''? ... ?'' * http://www.cs.man.ac.uk/~pjj/bnf/ebnf.html * replace antialias function