Building a parser (not solved)

Started by
12 comments, last by Nice Coder 18 years, 9 months ago
Ok, i'll have a look at that. (hopefully i'm 1337 enough to make it).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Advertisement
Since it looks like you might be considering using languages other than VB I also suggest that you take a look at ANTLR ( www.antlr.org ). It's basically Yacc/Bison and Flex/Lex on steroids and crack (respectively). It generates the lexer, parser, AND tree walker. Creation of abstract syntax tress is built in and it generates source for C++, Java, and C# (all from a single grammar file). It's written in Java, is open source, and has lots of existing grammar files.

Typically creating a grammar and associated support code for AST's is a time consuming task. I started my current grammar file almost two weeks ago (on friday) and it's almost complete - with full AST.
There are regular expressions in VB6. Go to Project->References. The regular expression library is in there. If it's not, then go to microsoft's website and search for windows scripting host. Download and install.

If you want to extract a specific string from another string with regular expressions, you'll have to group the specific part of the expression with parentheses.

For example (all from memory, so some class names could be wrong):

Dim re as RegExpDim matches as MatchCollectionSet re = New RegExpre.Pattern = "Do you like ([^$]+)$matches = re.Execute(stringToParse)print "You like " & matches.item(0).submatches(0)
Ok. I could do regexps before, but i didn't know how to find what the *'s are.

:-)

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

This topic is closed to new replies.

Advertisement