String input to flex lexer

The following routines are available for setting up input buffers for scanning in-memory strings instead of files (as yy_create_buffer does): YY_BUFFER_STATE yy_scan_string(const char *str): scans a NUL-terminated string` YY_BUFFER_STATE yy_scan_bytes(const char *bytes, int len): scans len bytes (including possibly NULs) starting at location bytes Note that both of these functions create, return a corresponding YY_BUFFER_STATE … Read more

How to compile LEX/YACC files on Windows?

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 a directory of your preference without spaces in the name. I suggest C:\GnuWin32. Do not install it in the default (C:\Program Files (x86)\GnuWin32) because bison has problems with spaces in directory names, not … Read more

Thread-safe / reentrant bison + flex

1. Sample code A kind of explanation of how reentrancy is configured into bison and flex is provided in section 2 of this answer. Other annotations of the sample code are in section 3. 1.1 eval.l %option noinput nounput noyywrap 8bit nodefault %option yylineno %option reentrant bison-bridge bison-locations %{ #include <stdlib.h> #include <string.h> #include “eval.tab.h” … Read more