Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault when involing "lex" without specify the output "-o" and … #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mingodad
Copy link

…make it work as specified in the "lex.1" man page

…make it work as specified in the "lex.1" man page
main.c Outdated Show resolved Hide resolved
@rofl0r
Copy link
Member

rofl0r commented Jul 31, 2022

good job, let me know when you're done and this can be merged.

@mingodad
Copy link
Author

mingodad commented Aug 1, 2022

In several interesting grammars they use <<EOF>> that is a flex extension I saw that you also have add some flex extensions.
Have you thought about adding <<EOF>> ?
I'm basically looking at this project to try to generate Javascript/Typescript lexers to use on a online playground like https://meimporta.eu/TsccYaccLex/playground.html , https://mingodad.github.io/CocoR-Typescript/playground .

The idea is to somehow compile kmyacc and lex to webassembly to do the heavy lifting and then run the resulting lex/parser directly through the browser.

@rofl0r
Copy link
Member

rofl0r commented Aug 1, 2022

Have you thought about adding <<EOF>> ?

no, but feel free to add support for it.

my personal plan with this project was to completely replace flex[0] in sabotage linux, but it turned out that too many packages use advanced flex features like reentrancy.

[0]: flex is a giant unreadable hairball full of ifdefs and bugs and depends on GNU m4 and several external m4 files

@rofl0r
Copy link
Member

rofl0r commented Aug 1, 2022

btw, when evaluating parser generators for own lagnuage projects the most interesting candidate i found was http://repo.hu/projects/byaccic/

@mingodad
Copy link
Author

mingodad commented Aug 1, 2022

I have some patched/extended parser generators here too https://github.com/mingodad/lalr-parser-test , I'm looking now on byaccic.

@mingodad
Copy link
Author

mingodad commented Aug 1, 2022

About reentrancy I already have a working reentrant scanner manually modified from the one generated by lex that need to be transferred to the templates/forms, see attached just in case it can be of your interest.
lex-reentrant.zip

@rofl0r
Copy link
Member

rofl0r commented Aug 1, 2022

see attached just in case it can be of your interest

definitely interesting, i'd happily accept a PR

@rofl0r
Copy link
Member

rofl0r commented Aug 28, 2022

hello @mingodad, what are the preconditions to experience segfault you describe in ea6229d ? using just lex foo.l without -o parameter works as intended, a file called lex.yy.c is produced.

@mingodad
Copy link
Author

Just don't specify an output filename and the code generator would try to write to fout that is not initialized.

@rofl0r
Copy link
Member

rofl0r commented Aug 28, 2022

Just don't specify an output filename

so as i said above, lex foo.l ? works fine in my case, and sub1.c checks whether fout is NULL, else uses lex.yy.c (unlike in your patch yy.lex.c)

@mingodad
Copy link
Author

It was segfaulting for me with one of several lex files I was testing, but right now I don't remember which one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants