Ask coding questions

← Back to all posts
How to install Bison on Replit
ANDREWVOSS (187)

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 (50) [earned 5 cycles]
View Answer
Comments
hotnewtop
programmeruser (604)

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

programmeruser (604)

@ANDREWVOSS I edited my answer, try again

ANDREWVOSS (187)

@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.

programmeruser (604)

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

ANDREWVOSS (187)

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

programmeruser (604)

@ANDREWVOSS what error message does it show exactly?

ANDREWVOSS (187)

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

RowanFromBJC (50)

@ANDREWVOSS Use BISON_PKGDATADIR instead of BISON_PKGDIR

frissyn (367)

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)

ANDREWVOSS (187)

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

CodeMaster007 (109)

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

frissyn (367)

@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

frissyn (367)

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

CodeMaster007 (109)

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

ANDREWVOSS (187)

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

mollthecoder (37)

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

CodeMaster007 (109)

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

xxpertHacker (934)

@CodeMaster007 OP is already using C++ :/

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

ANDREWVOSS (187)

@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.