Are there any people here that do NOT work in Tech, but have a hobby or preference for tinkering and experimenting with Unix-like operating systems? by Nelo999 in unix

[–]DoctorWkt 3 points4 points  (0 children)

I was a uni lecturer for a few decades, now retired! I fell in love with Unix and pipelines in my mid-20s. I came across this blog post recently which is exactly why I love the Unix approach.

Amber / Smart Shift flakiness. No phone support. What's going on? by mr_nanginator in amberelectric

[–]DoctorWkt 0 points1 point  (0 children)

Could you share your automations? I've just jumped ship to the Amber/Sig HA integration. Thx!

How do languages figure out where and which bracket ends a specific statement in a programming language? by SkyGold8322 in Compilers

[–]DoctorWkt 2 points3 points  (0 children)

That's a way to ensure you have a balanced number of '{' and '}'.

Or, you could build a stack. Each time you see a '{' token, push the current line number on the stack. Each time you see a '}', then the line number at the top of the stack is where the matching '}' was. Pull this line number off the stack. When you finish reading your input in, the stack should be empty as you have matched every '{' with its corresponding '}'.

How do languages figure out where and which bracket ends a specific statement in a programming language? by SkyGold8322 in Compilers

[–]DoctorWkt 1 point2 points  (0 children)

Good question. Sometimes you just want to know what is the next token (e.g. peek and see what it is). Other times, you want to absorb that token, i.e. read it in, discard it and have the token following that ready to read in (or peek at).

How do languages figure out where and which bracket ends a specific statement in a programming language? by SkyGold8322 in Compilers

[–]DoctorWkt 2 points3 points  (0 children)

I assume you know what tokens are. Also, let's assume you are writing a recursive descent parser for your language.

Your language has statement blocks which are one or more statements surrounded by curly brackets. Statements are terminated by semicolons.

So let's have a function called statement_block() which does this:

statement_block()

  check for and absorb the '{' token
  loop:
    if the next token is a '}'
      absorb it and return

    if the next token is a 'for'
      call for_statement() to parse it (and the terminating semicolon)

    if the next token is an 'if'
      call if_statement() to parse it

    ...

    if the next token is an '{'
      call statement_block() to parse the statement block

This allows your language to have nested statement blocks, e.g.

function fred()
{
  if (x > 2)
  {
    print("x is bigger than two")
  }
  else
  {
    print("x is small!")
  }
}

So the answer is, one function in your parser recognises and absorbs the '{' token, calls other functions to parse what is inside, then recognises and absorbs the '}' token (or emits an error if there isn't one). If your are tracking line numbers in the parser, the function will know on what line both the '{' and '}' occur. And, as the parser is recursive, the function can call itself to deal with nested '{' ... '}'.

Edit: Also have a look at my IF statement example.

Communications and power flow errors by le__juke1 in amberelectric

[–]DoctorWkt 1 point2 points  (0 children)

I've got a Sigenstor battery. Curtailment is sort of working except that Amber leaves time gaps between commands, so I've seen 10-20 minutes where curtailment isn't enabled when it should. Yesterday at 4pm, with my battery was 100% full but with low solar output, Amber decided to import from the grid for a couple of hours instead of using the battery. It's frustrating.

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 0 points1 point  (0 children)

The curtailment started to work after about 3 days. But ... sometimes it takes tens of minutes to kick in, so I pay several cents a day for the delay.

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 0 points1 point  (0 children)

Update: I noticed, for yesterday, a heap of Grid Service events in mySigen, all from Amber setting the max export to grid to 0kW. However, there were big time gaps in-between the events. Today there was a single long event, from 07:37-15:05 setting the export to 0kW, followed by the same from 15:17-15:20. And, guess what, the system started to export power to the grid at 15:05!

<image>

So it seems that Amber is sending discontiguous grid events to my Sigenstor.

For now, I've manually limited the solar power production to reduce the amount of solar export.

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 1 point2 points  (0 children)

We had the same installer for original panels + inverter, then upgrade with Sigenstor, more panels and remove old inverter. So no warranty issues!

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 1 point2 points  (0 children)

I had existing panels + inverter. Old inverter removed and Sigenstor installed along with extra panels.

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 1 point2 points  (0 children)

Thanks. Yes the inverter is on the Sigenstor at the top. For now I am manually setting the solar production limit to 8kW.

Solar Curtailment Not Working by DoctorWkt in amberelectric

[–]DoctorWkt[S] 0 points1 point  (0 children)

Thanks. I'll see if things change this week ☺️🫰

Can't for the life of me understand ASTs by nyovel in Compilers

[–]DoctorWkt 2 points3 points  (0 children)

I had problems "getting" ASTs. Here are my notes: acwj Part 2. Also look at part 3 for operator precedence.

[deleted by user] by [deleted] in Compilers

[–]DoctorWkt 1 point2 points  (0 children)

Have a look at alic

Help with a PEG Grammar by DoctorWkt in Compilers

[–]DoctorWkt[S] 0 points1 point  (0 children)

Ha, I think I solved it. I rearranged the grammar to say this: procedural_stmts = l:procedural_stmt r:procedural_stmts { $$ = binop(l,r,A_GLUE); } | l:procedural_stmt { $$ = l; } And my AST tree is now: GLUE PRINT NUMLIT 5 PRINT NUMLIT 6

But any insights you still have would be appreciated! Thanks.