pattern matching - Detect and match function opening and end brace in source code -


i know if there algorithms detect function declaration, function content, opening brace , closing one. development, debug , testing bugs, nice in cases need add lot of code in functions.

example source code:

test.onload=function(event){     test.initialize(); }; 

result:

  • function name: test.onload
  • content: test.initialize();
  • opening brace found @ line: 1.
  • closing brace found @ line 3.

we example, information above, add line @ beginning of functions , @ end of them, log parameters:

test.onload=function(event){     log("loginit","function:test.onload","openbraceline:1","content: test.initialize();");     test.initialize();     log("logend ","function:test.onload","endbraceline :5","content: test.initialize();"); }; 

i know functionality made simple global log , call stack, there still lot of examples usefull.


making simple algorithm detect , match braces , function information easy there lot of exceptions complicated, , thats why im asking if there known ways of detecting it.
i dont mind if examples algorithms or tips in language, wanted see best ways of doing it.

notepad++ example because has plugin detects lot of different source code languages , parses code colors each part , matches braces.

using real parser solution work in cases.

this seems javascript, suggestion use rhino, easy use, tool java tool in end, of course.

if solution needs in javascript, too, can take @ this question parsers in javascript


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -