[kwlug-disc] Modern way of doing Lex/Yacc
Doug Moen
doug at moens.org
Thu Jun 23 08:17:12 EDT 2022
So you want to embed some kind of user-facing programming language in your app that at least supports "conditional, loop, function". Building a new language from scratch is too much work, you should just use an existing one.
But what are your specific requirements? You mention TCL and Lua, then you say "But, these bring their own baggages." So what is the baggage that you want to avoid? What is the specific problem with Lua?
There are some programmable configuration languages that are similar to JSON, except that they extend JSON with "conditional, loop, function". An example is Jsonnet: https://jsonnet.org/
Is this the kind of thing you are looking for?
On Wed, Jun 22, 2022, at 10:26 PM, William Park via kwlug-disc wrote:
> I'm not tied to C. Yes, "domain specific language". Input data would
> come from users. If the data is "passive", then I can require well
> known format (eg. JSON). I run the parser library, then do the business
> logic.
> Eg.
> - read from sensor and append it to file or upload to URL.
> - post amount to this account and that account.
>
> In reality, data doesn't stay "passive" for long. Soon, they want
> conditional, loop, function, etc.
> Eg.
> - if this, then do something.
> - do job #10 to job #20.
>
> How do you express these in JSON format? Maybe
> "cooling": {
> "temperature_set_to" : 25,
> "exec" : "air_conditioner.exe"
> },
> "heating": {
> "temperature_set_to" : 15,
> "exec" : "furnace.exe"
> }
>
> I don't want to write, test, and debug parsers. I want to concentrate
> on business logic. That's why I asked.
>
> I mean, this kind of thing is everywhere:
> - Every printer run its own command interpreter.
> - Awk, Sed, Shell are specific interpreters for line texts.
> - bc, dc are calculator interpreter.
> - Even systemd unit file is descriptive script, which systemd
> parses and executes.
>
> They all have their own business logic, but also they all run parser at
> the front.
>
>
> On 2022-06-22 07:45, Doug Moen wrote:
>> Since you mention Lex/Yacc/Flex/Bison, do you specifically require this to work in the C language, or are you open to using a more modern/expressive programming language?
>>
>> It sounds like you want to create a "domain specific language" (DSL). Is this DSL going to be used only by the developer (inside the application code), or is it supposed to be used by users (to configure/customize the application)?
>>
>> Doug.
>>
>> On Tue, Jun 21, 2022, at 11:37 PM, William Park via kwlug-disc wrote:
>>> To Computer Science guys,
>>>
>>> You come across a situation that calls for little "embedded interpreter"
>>> solution.
>>> - You can use already existing embedded interpreter like Tcl or
>>> Lua. But, these bring their own baggages.
>>> - Or, you can use Lex/Yacc (or Flex/Bison) solution which you
>>> studied in school. For simple situation, this may be the way to go.
>>>
>>> But, I'm curious. Is there something more modern? Something that
>>> leverages 40 years of collective experience in software development.
>>> Something more than "state machine", but less than full "interpreter".
>>>
>>> _______________________________________________
>>> kwlug-disc mailing list
>>> kwlug-disc at kwlug.org
>>> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>>
>> _______________________________________________
>> kwlug-disc mailing list
>> kwlug-disc at kwlug.org
>> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
More information about the kwlug-disc
mailing list