java - Creating a derivation tree from a set of Grammar rules -


i have 2 arrays, defining set of rules in context free grammar. array 1 being left side of rule , array 2 being right side of rule, example :

a = b | c translate array1[0] = a, array2[0] = b c 

from this, want construct possible derivation given integer defines how many steps can occur. example, ---> c constitute 1 step. if integer 3, program print out possible derivations occur in 3 steps.

any advice on how tackle program appreciated, i've been trying think way around problem hours no success. i'm using java.

thanks.

since using string objects express derivations use starting symbol , split derivation using delimiter " ". search derivations non-terminals in right order , try recursively derive them. if there terminals left, print out complete derivation have stored in structure, e. g. list, contains every derivation. last point still other options available derive.

but think modelling not since not efficient. problem dealing typically solved parser implementations used e. g. compiler implementation. have @ resource (wikipedia): parsing. there 2 main approaches: top-down- , bottom-up-parsing.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -