Regular expression for a string literal in flex/lex

I’m experimenting to learn flex and would like to match string literals. My code currently looks like: “\””([^\n\”\\]*(\\[.\n])*)*”\”” {/*matches string-literal*/;} I’ve been struggling with variations for an hour or so and can’t get it working the way it should. I’m essentially hoping to match a string literal that can’t contain a new-line (unless it’s escaped) … Read more

EXIT_FAILURE vs exit(1)?

What’s the difference? Which is preferred, or when should I use each one respectively? Answer exit(1) (usually) indicates unsuccessful termination. However, its usage is non-portable. For example, on OpenVMS, exit(1) actually indicates success. Only EXIT_FAILURE is the standard value for returning unsuccessful termination, but 1 is used for the same in many implementations. So to … Read more

How to compile LEX/YACC files on Windows?

I’m having Lex and YACC files to parse my files (.l file and .y file). How to compile those files and how to make equivalent .c file for them in windows platform? Answer As for today (2011-04-05, updated 2017-11-29) you will need the lastest versions of: flex-2.5.4a-1.exe bison-2.4.1-setup.exe After that, do a full install in … Read more

What is the difference between using _exit() & exit() in a conventional Linux fork-exec?

I’ve been trying to figure out how the fork-exec mechanism is used inside Linux. Everything was going on according to the plan until some web pages started to confuse me. It is said that a child process should strictly use _exit() instead of a simple exit() or a normal return from main(). As I know, … Read more

Resources for lexing, tokenising and parsing in python

Can people point me to resources on lexing, parsing and tokenising with Python? I’m doing a little hacking on an open source project (hotwire) and wanted to do a few changes to the code that lexes, parses and tokenises the commands entered into it. As it is real working code it is fairly complex and … Read more

Python subprocess: callback when cmd exits

I’m currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I’m fairly new to Python, but it ‘feels’ like there ought to be some api that lets me do something similar to: subprocess.Popen(cmd, shell=TRUE, postexec_fn=function_to_call_on_exit) I am doing this so that function_to_call_on_exit can do something based on knowing that the cmd has exited (for example keeping count … Read more