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

adjunct/removecomments should be replaced #54

Open
hackerb9 opened this issue Dec 5, 2022 · 2 comments · May be fixed by #55
Open

adjunct/removecomments should be replaced #54

hackerb9 opened this issue Dec 5, 2022 · 2 comments · May be fixed by #55

Comments

@hackerb9
Copy link
Contributor

hackerb9 commented Dec 5, 2022

The code I have for handling comments is getting hairy because I forgot about single-ticks within double-quotes. For example,

6015 IF WA=0 THEN PRINT "Error: File '";WF$;"' File not found.": END           

That line was getting cut off at the first single tick after the word "File". In the meantime, I've kludged the script to simply pass through any lines with double quotes.

The proper solution would be to write a lexer using flex. Technically, a Context-Free Grammar is equivalent to a regular expression, however, it should be a lot easier to understand and debug.

@hackerb9
Copy link
Contributor Author

I did the "proper solution", mentioned above. Or at least, I think I did. It was back in 2022 so I've forgotten if there were severe hiccups. It should work on MacOS with a simple make install.

The current version of https://github.com/hackerb9/tokenize contains a program called "tandy-decomment" which, while not complete, does remove most the comments. Typically one would use the frontend "tokenize -d" to decomment and tokenize at the same time.

@hackerb9
Copy link
Contributor Author

I replaced adjunct/removecomments in the linked pull request with adjunct/tandy-decomment which should run fine on any system with a C compiler (MacOS, Linux, Whathaveyou...) Merging #55 will close this issue.

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 a pull request may close this issue.

1 participant