Re: [dev] Preprocessor

From: Adrian Grigore <adrian.emil.grigore_AT_gmail.com>
Date: Tue, 23 Apr 2019 23:36:45 +0300

Ignore the shell stuff, I know it's bad (I also usually use find(1)
for these cases), good comments however.
It's good you mentioned it so anybody reading this would know it's
bad, thank you!

On Tue, Apr 23, 2019 at 11:07 PM Peter Nagy <petern_AT_riseup.net> wrote:
>
> This was a question about the preprocessor, please take your sh (off-)topic to a different thread.
>
> That main, mostly the switch part, is huge! Having more than 3 levels of nesting of loops+conditionals (if, for, while, switch) is a code smell; it is hard to read, hard to reason about and easy to get wrong.
>
> Bonus points for not using lex/yacc etc, writing a parser by hand needn't be hard. Still, some refactoring to create smaller, readable and maintainable functions would go a long way. Maybe trying out to write out the states the parser can be in as a table would help to see if the parser can be simplified or the token choices changed. Toying with an FSM implementation might be fun too :)
>

I'm VERY aware of that, I'm still toying with it, I'll probably
abstract those just not sure about the abstractions yet so I
kept them there in my face.

I'd rather not change the token as "#!" reminds me of the shell.
Changing the token however would remove some code.

>
> Why are you building this tool? Fun, education, prototype? What is the end goal? Who is the audience?
>

Generating static web sites would be an idea or could be embedded in
Markdown files.

My doubts are mostly about error handling and undefined behaviour.

I updated it, still no refactoring tho.

Speeds are comparable to PHP for simple IO code.

http://adi.tilde.institute/tmp/pp.c

Thanks for the feedback!

> Good luck with your project!
> --
> Peter Nagy
>
> - To reach a goal one has to enjoy the journey
>
> On April 23, 2019 7:44:57 PM UTC, Evan Gates <evan.gates_AT_gmail.com> wrote:
> >On Tue, Apr 23, 2019 at 12:42 PM Hadrien Lacour
> ><hadrien.lacour_AT_posteo.net> wrote:
> >> That was just shitposting. I use `find` to avoid most of the UNIX
> >braindamage
> >> in this case.
> >
> >Which is good as long as you use -exec correctly. Or if you're going
> >to use xargs make sure to use nul separated lists. Xargs without the
> >nul option is broken by design.
>


-- 
Thank you,
Adi
Received on Tue Apr 23 2019 - 22:36:45 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 23 2019 - 22:48:08 CEST