English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm looking for a context free grammar for the set of all matching curly braces ( '{' '}' ).

Does anyone have a clue? I'm having a terrible time understanding this grammar stuff...

2006-10-25 06:57:05 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

It's only a guess but...

S -> {S}

would generate {}, {{}}, {{{}}}, etc

or

S -> S{}

would generate {}, {}{}, {}{}{}, etc

I'm not sure what you are asking exactly, but I reckon it's one of those ;)

Rawlyn.

2006-10-25 07:22:19 · answer #1 · answered by Anonymous · 0 1

In Timbuktu does not matter which it is. Both don't make since to me. So come to Timbuktu where there is none of your regular grammar and a context-free grammar. Mmmmmmmmk by by!

2016-05-22 13:10:48 · answer #2 · answered by Anonymous · 0 0

Rules for balancing braces are:

if w is balanced then you can surround them with braces, that is, { w } is balanced

if w1 and w2 are balanced then you can join them, that is, w1 w2 is balanced

The empty string, e is balanced.

Example: {{{}{}}{}}{{}{{}}} is balanced

Here is the grammar
B --> BB | { B } | e

2006-10-25 10:36:53 · answer #3 · answered by p_ne_np 3 · 1 0

I thought they were only used in math or computer programming. What does it have to do with grammar?

2006-10-25 07:00:20 · answer #4 · answered by martin h 6 · 0 1

fedest.com, questions and answers