Testing wiki grammar

edit

Testing "a\n :a\n:a"

a

:a
a

Testing ":a\na\n:a"

a

a

a

--Kanor

I consider this to be not context free, because the value of "***" is dependant on the exact prefix of the previous line(s).

a

  • a
    • a
      • a
    • a
  • a

a

I consider this to be context free because the value of " " is dependent only on whether the previous line was prefixed with " " or not.

a

a
 a
  a
 a
a

a

--Conrad.Irwin

EBNF rules for wiki lists

edit

It is actually context-free in both cases. Say we have this rule for a list:

list: list-item+
list-item:  level-mark+ , text-line

And this one for the fixed width lines:

pre-block: pre-line+
pre-line: " " , text-line

The two blocks can be generated by a set of context-free (type 2) grammar rules. The rules for the list items are actually defined as an undefined number of level marks, but actually this is valid in wiki code:

* a
*** b
** c
**** d
* e

Resulting in:

  • a
      • b
    • c
        • d
  • e

Which does not make sense in terms of a list, but it is a drawback of the fact that the wiki markup requires several level marks to achieve a certain depth in the list.

--Kanor 23:07, 24 November 2009 (UTC)Reply

Response to article in Meatball

edit

In response to http://www.usemod.com/cgi-bin/mb.pl?ConsumeParseRenderVsMatchTransform :

If I understood it well, you argue that Wiki markup is a context-sensitive grammar because the language is ambiguous. The fact that a language is inherently ambiguous has nothing to do with the type of grammar it is used to generate it (w:en:Ambiguous_grammar).

A context-free grammar is that having rules in wich the right part can only have nonterminal symbols. A context-free language is a language generated by a context-free grammar. (See w:en:Context-free_grammar)

On the other hand, a context-sensitive grammar allow nonterminal symbols in the right part of the rules, which means, among other things, that certain rules can only be applied when certain terminal symbols have been already generated. (A better explanation is given in w:en:Context-sensitive_grammar)

Ambiguity can be solved with rule precedence. Wiki markup can be asserted as context-sensitive just giving an example of string that cannot be generated with context-free rules, such as {a^n b^n c^n}. Otherwise the pumping lemma can be applied.

So far I haven't found a single string in Wiki markup that requires context-sensitive rules to be generated.

For more information, see Markup spec or my user page talk in MediaWiki User talk:Kanor

edit

Hi Francisco - Just tested version 0.7 and found an IE bug. Can you fix it and if so, by when? Thanks for mentioning me in the file comments! --Robinson weijman 08:51, 4 February 2011 (UTC)Reply