Skip to content
← Back to Community
How to install Bison on Replit
Profile icon
ANDREWVOSS

I've been following a tutorial online on how to create a simple compiler using Lex, Bison, and LLVM, but I've been unable to get Bison working. I was able to install it through install-pkg bison, but when I try to run it with bison -d -o parser.cpp parser.y, it gives my an error saying bison: /usr/share/bison/m4sugar/m4sugar.m4: cannot open: No such file or directory. Does anyone know a way to get bison working on Replit?

Answered by RowanFromBJC [earned 5 cycles]
View Answer
Voters
Profile icon
figglediggle
Profile icon
frissyn
Profile icon
lsikora
Profile icon
ANDREWVOSS
Comments
hotnewtop
Profile icon
programmeruser

Try this after installing: export BISON_PKGDIR=$HOME/.apt/usr/share/bison

Profile icon
ANDREWVOSS

@programmeruser The file doesn't exist

Profile icon
programmeruser

@ANDREWVOSS I edited my answer, try again

Profile icon
ANDREWVOSS

@programmeruser I was wrong. The file exists in the path you put in your answer, but Bison still looks in the default path even after I export the environment variable.

Profile icon
programmeruser

@ANDREWVOSS what are you doing after exporting the environment variable?

Profile icon
ANDREWVOSS

@programmeruser Running Bison. The exact command is bison -d -o parser.cpp parser.y.

Profile icon
programmeruser

@ANDREWVOSS what error message does it show exactly?

Profile icon
ANDREWVOSS

@programmeruser bison: /usr/share/bison/m4sugar/m4sugar.m4: cannot open: No such file or directory, same as in the original post.

Profile icon
RowanFromBJC

@ANDREWVOSS Use BISON_PKGDATADIR instead of BISON_PKGDIR

Profile icon
ANDREWVOSS

@RowanFromBJC Ok, I'll give that a shot

Profile icon
ANDREWVOSS

@RowanFromBJC It worked! Thanks

Profile icon
frissyn

What a coincidence, I was working on a parser the other day as well!

In order to get Bison on Replit, you need to use install-pkg in the shell tab. The following commands let me use flex, yacc, and bison commands, they should work for you too.

install-pkg bison install-pkg flex install-pkg byacc

NOTE: flex is a mirror of lex, you can't get lex on Replit right now. (If you can I don't know how)

Profile icon
ANDREWVOSS

@frissyn I'm still getting the same error when I try to use Bison. Are you able to use it?

Profile icon
lsikora

Is this just for python or for c++ as well? @frissyn

Profile icon
frissyn

@ANDREWVOSS Apparently this is an issue with Bison itself and not Replit. I got this issue today but it was working before, so I don't know what's wrong

Profile icon
frissyn

@CodeMaster007 This is for installing Bison and related packages. These are language-independent tools you run in the shell tab

Profile icon
lsikora

Oh, that makes sense. In that case, which programing language has the fastest IDE? I installed a package and used it in bash although it was kinda slow. If it works in any other language, that would be amazing. @frissyn

Profile icon
ANDREWVOSS

@frissyn Oh. Well tell me if you figure out a fix.

Profile icon
KoltonBrittain

sewgfuiahowif]e
]\

Profile icon
mollthecoder

Clone it from github and play around with the build files. Build it, and make a custom configuration that works on replit.

Profile icon
lsikora

Hey, so after reading some about bison, I found that bison is supposed to run on C, C++, or java. There are a bunch of cool features and abilities but I didn't see anything regarding python. I think your problem is that it doesn't run on python. I may be wrong, but from my research, theres little work done on python. On repl, I didn't find anything at all about bison so the chances of making it work is pretty low. I may be wrong, but I just suggest using java of c++. They are relatively easy programs to learn and there are millions of tutorials on it.
Good Luck,

CodeMaster007

Profile icon
xxpertHacker

@CodeMaster007 OP is already using C++ :/

Python's bison isn't the same thing as the bison parsing tool.

Profile icon
lsikora
Profile icon
ANDREWVOSS

@CodeMaster007 I think that's something completely different, the Bison I'm looking for is for generating parsers, but that is for reading config files.