Hi,
first of all, I would like to congratulate OA on their great product. I am looking forward to Dolphin 6.0! Now the problem I am dealing with. I installed the regex package (ported from Chris Uppal) on Dolphin Pro 5.1.4 and getting a stack overflow while evaluating the following expression: | theMatcher | theMatcher := '^([a-zA-Z0-9_]([a-zA-Z0-9_*: ]|\t)*)(\s*)\((\([^()]*\)|[^()])*\)(( |\n|\t)|(//.*\n)|(/\*([^*]|(\*+[^*/]))*\*+/))*(\s*){' "^^^^^^ remove any line break in the string ^^^^^^" asRegex. theMatcher matches: 'void testFunc( sint16 *rHWE , uint8 stPwrStgDiaDis , sint16 facBattCorr , uint8 Pwmoutpin1 , uint8 Pwmoutpin2 , uint16 PwrStgSCB , uint16 PwrStgSCG , uint16 PwrStgOL , uint16 FanCtlrOT , uint16 FanCtlrEE , uint16 Fan1CtlrErr1 , uint16 Fan1CtlrErr2 , uint16 Fan2CtlrErr1 , uint16 Fan2CtlrErr2 , uint16 *ErrIntFanCtlrOT , uint16 *ErrIntFanCtlrEE , uint16 *ErrIntFan1CtlrErr1 , uint16 *ErrIntFan1CtlrErr2 , uint16 *ErrIntFan2CtlrErr1 , uint16 *ErrIntFan2CtlrErr2 , uint16 *TmrFanCtlrErr , uint16 *TmrFanCtlrNoErr , sint16 tiErrInt , const uint16 *PwmOutCorrStruct , uint16 *stPwrStgErr , uint16 *stPwrStgTested , uint32 tiDiffDSM ) {' The regex is used to detect c function in source files. To avoid the error just remove some function parameters. Is it possible to tweak the stack size so i can stay with my regex? Thanks Pierre |
Pierre Schwarz wrote:
> Now the problem I am dealing with. I installed the regex package > (ported from Chris Uppal) on Dolphin Pro 5.1.4 and getting a stack > overflow while evaluating the following expression: > > > theMatcher | > theMatcher := '^([a-zA-Z0-9_]([a-zA-Z0-9_*: > ]|\t)*)(\s*)\((\([^()]*\)|[^()])*\)(( > > \n|\t)|(//.*\n)|(/\*([^*]|(\*+[^*/]))*\*+/))*(\s*){' > "^^^^^^ remove any line break in the string ^^^^^^" > asRegex. I can't help with the stack problem, I'm afraid. I think that your example should have a space (or \s) at the end of the third line of the regexp ? Without that the regexp parser won't accept it. Assuming that change, I find that the test you posted works fine (#matches: answers false). I'm using 5.1.4 on WinXP Pro, so I don't know what the difference between our systems is. BTW, as an aside, I don't think you'll have much luck creating a regexp that can reliably recognise C or C++ declarations. It's just too complicated for classic regexps, you need something much more like a full parser. E.g. I don't /think/ that your expression would work with extern void set_callback( void (*callback)() ) ; (or whatever the damnable syntax is !) Of course, you may not need that level of generality. -- chris |
In reply to this post by Pierre Schwarz
"Pierre Schwarz" <[hidden email]> wrote in message
news:izpi5iqj9cwk$.epm7vhdivhea$.[hidden email]... > Hi, > > first of all, I would like to congratulate OA on their great product. > I am looking forward to Dolphin 6.0! Thanks. > Now the problem I am dealing with. I installed the regex package > (ported from Chris Uppal) on Dolphin Pro 5.1.4 and getting a stack overflow > while evaluating the following expression: > ... [snip] ... > The regex is used to detect c function in source files. To avoid the error > just remove some function parameters. Is it possible to tweak the stack > size so i can stay with my regex? > I wouldn't want to denigrate Chris' package, but as a port of Vassili Bykov's regex implementation it was originally designed on the assumption of an unbounded stack. Although you can increase the stack size in Dolphin (see the comment in the Process class>>initialize method), I suspect you may find that this will provide only temporary relief, and that you will still manage to blow the stack with more larger or more complex inputs, or with a different regex. At OA we use a wrapper around the Windows Scripting regexp component (used to implement regexp in Microsoft's JScript and VBScript). This doesn't suffer from such issues, and is also considerably faster. The component will be installed on any machine which meets Dolphin's own prerequisite requirements. The package (extracted from Dolphin 6) can be downloaded from: http://www.object-arts.com/Lib/Downloads/RegExp.zip I tested it out with your example... theMatcher := IRegExp2 new. theMatcher pattern: ^([a-zA-Z0-9_]([a-zA-Z0-9_*: ..... etc... theMatcher test: ...etc... And it returned false. This is either due to differences in the regexp syntax (see first link below) or perhaps an error in your regexp. I've pasted some other useful links below. Regards Blair ---------------- 1) "Regular Expression Syntax" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsgrpRegExpSyntax.asp 2) "Introduction to Regular Expressions" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56reconIntroductionToRegularExpressions.asp 3) "Microsoft Beefs Up VBScript with Regular Expressions" http://msdn.microsoft.com/library/en-us/dnclinic/html/scripting051099.asp. 4) KB818802 "HOW TO: Use Regular Expressions in Microsoft Visual Basic 6.0" http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B818802 5) Microsoft Windows Script Downloads http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp |
> I wouldn't want to denigrate Chris' package, but as a port of Vassili
> Bykov's regex implementation it was originally designed on the assumption of > an unbounded stack. Although you can increase the stack size in Dolphin > (see the comment in the Process class>>initialize method), I suspect you may > find that this will provide only temporary relief, and that you will still > manage to blow the stack with more larger or more complex inputs, or with a > different regex. > > At OA we use a wrapper around the Windows Scripting regexp component (used > to implement regexp in Microsoft's JScript and VBScript). This doesn't > suffer from such issues, and is also considerably faster. The component will > be installed on any machine which meets Dolphin's own prerequisite > requirements. The package (extracted from Dolphin 6) can be downloaded from: > > http://www.object-arts.com/Lib/Downloads/RegExp.zip > Thanks for the package. I generated also an interface with the ActiveX Wizard on the "Microsoft VBScript Regular Expressions 5.5" component (Thanks to Andy for the hint). > I tested it out with your example... > > theMatcher := IRegExp2 new. > theMatcher pattern: ^([a-zA-Z0-9_]([a-zA-Z0-9_*: ..... etc... > theMatcher test: ...etc... > > And it returned false. This is either due to differences in the regexp > syntax (see first link below) or perhaps an error in your regexp. > Yes, the syntax divers from the ActiveX control and the regex package. > I've pasted some other useful links below. > > Regards > > Blair > ---------------- > > 1) "Regular Expression Syntax" > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsgrpRegExpSyntax.asp > 2) "Introduction to Regular Expressions" > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56reconIntroductionToRegularExpressions.asp > 3) "Microsoft Beefs Up VBScript with Regular Expressions" > http://msdn.microsoft.com/library/en-us/dnclinic/html/scripting051099.asp. > 4) KB818802 "HOW TO: Use Regular Expressions in Microsoft Visual Basic 6.0" > http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B818802 > 5) Microsoft Windows Script Downloads > http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp Thanks for the links. At last, thanks to the regulars in this newsgroup. I appreciate the work and time they put into this newsgroup. With DSDN from Ian it is a prefect source of wisdom. Pierre |
In reply to this post by Chris Uppal-3
<snip>
Chris Uppal wrote: > BTW, as an aside, I don't think you'll have much luck creating a regexp that > can reliably recognise C or C++ declarations. It's just too complicated for > classic regexps, you need something much more like a full parser. E.g. I don't > /think/ that your expression would work with > > extern void set_callback( void (*callback)() ) ; > > (or whatever the damnable syntax is !) Of course, you may not need that level > of generality. > > -- chris Yes, i know, it not possible to use a regex to detect every C declarations. In my case i need to detect only very simple function calls e.g. "void functionName(void) {..." With a litte rework on the regex and the use of the ActiveX component Blair mentioned, i can parse 900 source files in 10 seconds. So, at the moment i can stay with the ActiveX solution. But for further requirements, has anybody a full c parser running in smalltalk (e.g. /SmaCC/)? Pierre |
Free forum by Nabble | Edit this page |