scripting / Scripting-News

I'm starting to use GitHub for work on my blog. Why not? It's got good communication and collaboration tools. Why not hook it up to a blog?
121 stars 10 forks source link

I want to get a UserTalk parser running in C #310

Open scripting opened 2 months ago

scripting commented 2 months ago

A project I'm interested in, and may attempt reasonably soon --

A UserTalk parser, built from the YACC source code in langparser.y in the Frontier source package.

The YACC source can be converted to some other automatic parser generator, from querying ChatGPT on the state of compiler compilers, it seems YACC is no longer in favor.

Here's the ChatGPT conversation.

If you're interested in helping think this through, or want to attempt it yourself, ask questions here. I may post notes as I explore it.

scripting commented 2 months ago

To get started, I wanted to see about compiling C on the Mac, where I work, and that's going to be a new experience for me.

It's possible to do that because we already have code that's been generated by YACC, which is what's in langparser.y -- so we can get a UserTalk parser running even if we can't compile the YACC source, though it will be impossible to improve the language. There are some missing piece, the most egregious is the += operator which I never got around to in 1988.

I miss THINK C. I wish there was something like it for the Mac.

scripting commented 2 months ago

Note: I'm not worried at this time about getting a UserTalk parser that could run unmodified in a port of Frontier.

I have a project that I want to have built-in scripting, and use this parser as a way to get started on bootstrapping a Frontier-compatible environment built to run in Node.js and really any environment that can run C code.

In Drummer, we used a modified JavaScript -- that made async functions synchronous, but it has limits, and I didn't want to stop there. I want Frontier's object database and its integration with the language. I have many of the UserTalk verbs already ported to run in Drummer's scripting language and a lot more, for example HTTP and WordPress, neither of which existed when Frontier was built.

scripting commented 2 months ago

Mucho progress!

I have BISON and BYACC running on my Mac.

I've got an example app that ChatGPT gave me, a syntax for a calculator and a lexical analyzer.

I was able to build it and run it and I'm totally jazzed. I haven't worked at this level since 1990 or so.

According to the calculator app, that's 34 freaking years ago.

Anyway in my next session I will try to compile langparser.y or a modification of it (probably) and see if I can get it to parse some UserTalk syntax.

BTW, the output of the parser is a tree that then has to be executed by the runtime.

This is where it builds the tree and runs it.

scripting commented 2 months ago

I did a couple of hours work this morning, and after getting a calculator.y example working, easily -- with the help of ChatGPT, I decided to give langparser.y a try, and it worked. I guess YACC is still YACC.

But -- I hand-coded the lexical scanner, so there is no lexer source in the package. That's okay my 1988 scanner is written in straight C and that should still work today. So that's fine.

So the job is doable. If I do some more work on this I'll try to start a separate project, but I'm also going to look in another direction.

I started a new ChatGPT thread -- "suppose i wanted to write a simple scripting language, using c-like syntax. i have bison and lexer. can you suggest a starting kit, just for generating a parser, for a c-like language"

Then I asked: "what about the next step. an interpreter that hooks into the trees this parser generates? does that exist as exampleware?"

Then I asked to see some exampleware.

Then "are any of these implemented in javascript and run in node.js?"

And "i'm only interested in parsers that can actually run the code"

I think that's where I'm going to pick it up from next session. I of course have other projects that I'm doing in parallel, but this is one of the most interesting. I think it may be time to try another approach at Frontier, 30+ years later.

Here's the transcript of the ChatGPT session above.