From: Matthias T. <mt...@we...> - 2012-07-05 17:56:43
|
> > Actually, my motivation was a lot simpler. I wasn't sure if the regular > expression I use to match an error being indicated by the amforth > interpreter really covered all cases. That expression (without the > delimiting double quotes included below) is: > > " \?\? -\d+ \d+ \r\n> $" > > Is it correct? Yes it is. > I spent some time looking at the main interpreter trying > to verify it but I don't read assembly and forth fluently enough yet to > be sure without investing more time than I had available. It a bit difficult indeed. The messages get printed by the words in the prompts.asm file, coordinated in quit.asm. The first " ?? " comes from PROMPTERROR which prints the two numbers too. After that quit calls the PROMPTRDY which generates the line feed and the "> ". The two numbers are printed using . (DOT) which makes it possible to get both positive and negative numbers. The not-so-obvious code in quit makes sure, that the first number is always negative and the second number is always positive. (THROW Code resp the value of >IN). That means that a THROW with a positive code number does not print anything, THROWs with a negative number trigger the error prompt as described above. The second consequence is that the size of the input buffer into which >IN points should never exceed 32KB. > If the above regular expression will catch all errors explicitly > indicated by the interpreter, then I think it would be reasonable to > change the default behavior to *not* generate an error on output as it > *will still generate an error* if the error regular expression matches. As long as nobody changes QUIT and the prompt words, the regex will work. > Matthias> http://amforth.svn.sourceforge.net/viewvc/amforth/trunk/tools/amforth-term.py?view=log > > Wonderful. I don't really see any need for this to live outside the > amforth repository, so if I get a chance to make further improvements > I'll prepare patches against the code there. Great. Matthias |