How can I split a rule with Lark EBNF? - ebnf

I'm writing a grammar for parsing PlantUML State diagrams and have the following doubt:
I had:
transition: STATE arrow STATE (":" event? guard? action?)? "\n"
arrow: ("->" | "-->" | "-left->" | "-right->" | "-up->" | "-down->")
But had to change to:
transition: STATE ("->" | "-->" | "-left->" | "-right->" | "-up->" | "-down->") STATE (":" event? GUARD? action?)? "\n"
Because, for my application, I don't need nor care which type of arrow is used; it is sufficient to know that an arrow was there to form the transition.
The question is: Is there a way to split the transition rule in other more manageable rules without the arrow type appearing in the parsed tree?
Full file at https://github.com/thomedes/PlantUML-Lark-EBNF. Feel free to comment / criticize. Trying to learn here 🤓

After RTFM, I've found that terminals whose name begins with underscore are not output to the tree, so I've changed it to:
transition: STATE _ARROW STATE (":" event? GUARD? ACTION?)? "\n"
_ARROW: "->" | "-->" | "-left->" | "-right->" | "-up->" | "-down->"
And now it works fine.
Not marking this as an accepted answer because I'm sure someone with more experience could give a better answer.

Related

what is syntax in ucf file for IOBDELAY for virtex 5?

# Sets the attributes to an input differential pin pair (din)
NET <din_p> LOC=<AE7> | IOSTANDARD=<LVDS_25> |IOBDELAY=<NONE/BOTH/IBUF/IFD> | DIFF_TERM=<TRUE>;
NET <din_n> LOC=<AF7> | IOSTANDARD=<LVDS_25> | IOBDELAY=<NONE/BOTH/IBUF/IFD> | DIFF_TERM=<TRUE>;
even when I give IOBDELAY=NONE, the error persists
Could someone tell me where I am going wrong ?
This syntax was taken from Language templates for IBUFDS
yea it had to do with syntax .
NET "din_p" LOC="AG6" | IOSTANDARD="LVDS_25" | IOBDELAY=NONE | DIFF_TERM=TRUE;
it works this way

Print and update multiple lines in fixed position

I would like to print an output like the following in a fixed position while the numbers in the block keep updating every couple of seconds. It is similar to what top does.
Jobs monitor:
+-----------------------------------------+
| Waiting | Launched | Running | Finished |
+-----------------------------------------+
| 319 | 364 | 94 | 201 |
+-----------------------------------------+
Elapsed time: 21s
Is there a way to do that?
With only one line, I could do it with STDOUT.flush and "\r", but it does not work for multiple lines since the carriage will put the cursor at the beginning of the new line only.
The curses library is one way to make this work. It allows you to write to locations on a 2-d screen so you're not constrained to the current line. This question has some good resources for learning curses.

InDesign - how do I know if an image already placed?

I am working on a book with many images, and I want to ensure that I place each picture only once. Is there a way to tell indesign to to check if image exist before placing it? Or a way to define a preflight profile for it?
Thank you,
Omer
You should be able to see a list in the links panel.
It shows the number of times and the page number it appears on.
example:
Name | ! | Pg |
--------------------|---|----|
my-image.psd (2) | | |
my-image.psd | | 1 |
my-image.psd | | 4 |

What do FLAGS register components mean in VS 2013?

When debugging x86 assembly code in VS2013, I needed to check the contents of the FLAGS register. However, when I've enabled "Flags" in Register Window, I got:
OV = 0 UP = 0 EI = 1 PL = 1 ZR = 0 AC = 1 PE = 0 CY = 1
Those don't correspond to typical ODITSZAPC flags of x86; can anyone explain to me what's going on? Are those just weird names for the same flags?
I have a 64-bit Core i7; can it affect the displayed names?
| Overflow | OV |
| Direction | UP |
| Interrupt | EI |
| Sign | PL |
| Zero | ZR |
| Auxiliary | AC |
| Parity | PE |
| Carry | CY |
MSDN reference
Yes of course they are the same flags, what else?
But those really are misleading. When UP=1 it's actually reverse back direction (STD), also when PL=1 it's actually sign/negative. Why did VS designer tried to break ASM-thing that ain't broken for ages was beyond my comprehension though.
The same way in GNU's gdb, they called instruction pointer (IP) as $pc, DWORD/DD as word (w), WORD/DW as half-word (h), and QUADWORD/DQ as (g) from GIANT??
C++ Programmers are really weird, they liked to break convention for the sake of it.

Cucumber <reference> in Background?

Here is a tricky one regarding Cucumber:
Feature: Some feature
Background:
Given I am on the root page
Scenario Outline: Relevant flash messages should appear
When I fill in some_field with: <name>
Then I should see the text: <relevant_flash>
Examples:
| name | relevant_flash |
| Some name | Some message |
Scenario Outline: Irrelevant flash messages should not appear
When I fill in some_field with: <name>
Then I should not see the text: <irrelevant_flash>
Examples:
| name | irrelevant_flash |
| Some name | Some message |
I hate having to repeat:
When I fill in some_field with: <name>
But for obvious reasons it can not just be moved into background. Or can it? Let me know if you have a workaround...
Well, I can simplify your cucumber with something like this:
Feature: Some feature
Scenario Outline: Relevant flash messages should appear
Given I am on the root page
When I fill in some_field with: <name>
Then I should see <message>
Examples:
| name | message |
| Some name | Relevant message |
| Some other name | Irrelevant message |
| Some another name | another flash message |
You notice that I take out the Background: since we got it cover on Scenario Outline:
I think this steps will run and simple with out too much repeatation
Your Scenario outline could be better organized to avoid duplicate, by combining both successful and failed messages together.
Feature: Some feature
Background:
Given I am on the root page
Scenario Outline: Relevant flash messages should appear
When I fill in some_field with: <name>
Then I should see <relevant_message>
Examples:
| name | relevant_flash |
| Some name | Some message |
| Some irrelevant name | Irrelevant message |
| Name for blank msg | |

Resources