javascript parse parenthesis
I need parse a string inside a pare开发者_StackOverflow中文版nthesis, which looks like (A, B, C), where A, B, and C are string that can contain any legal JavaScript code. For example, B might be a very long string with nested structures similar to (A, B, C). What would be the best way to parse such a string?
An example of the string to parser is invoking a function:
func( parameter 1, parameter 2, parameter 3)
where all the three parameters could be other function definitions.
One of the simplest ways to create such a parser is to write a recursive descent parser. This type of parser is relatively easy to create and is certainly easier to understand than more complex parser generators (such as "yacc" and the like).
精彩评论