I have read TONS of articles about context free grammars and Pushdown Automata but I think there are things that I dont seem to understand. I am not studying computer science but I am really interested in many of the topics and I hope you can help me realign my knowledge about the CFG and PDA.
So my question is: could you tell me if what im writing here is correct? If not could you tell me what is wrong in my interpretation?
What I think I understood:
A state of a pushdown automata is equivalent to a set of production rules (or is it a production rule?) and these production rules contain replacement rules.
Depending on what character we read from our input we add an appropiate stack character or replace a character in the stack which is defined by one of the replacement rules.
So lets say we have defined the following production rule: a^n b^m : m != n
the replacement rules looks like:
production rule {
input ; Stack Symbol -> To Do On Stack
a ; nothing -> A
a ; A -> AA
b ; A -> nothing
emtpy -> #
}
for every "a" we read we add an A and for every "b" we remove an A. The stuff what happens in my PDA stack is therefore defined in the replacement rule of my production rule?
Now if I wanted to parse a nested input like: "{hello world {fooBar is cool + 5}}"
I assume I need two production rules each with different replacement rules for our stack:
RULE 1:
{ ; nothing -> O
[a-zA-Z] ; O -> L
ok seriously I have to stop here because I have no idea what im doing. I would appreciate it if you could tell if my interpretation is wrong and how to handle the last example.
I am sorry if I couldnt be more concise. Im currently a bit confused with this.