Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not parse negated #2

Open
hiperiondev opened this issue Feb 14, 2022 · 9 comments
Open

not parse negated #2

hiperiondev opened this issue Feb 14, 2022 · 9 comments

Comments

@hiperiondev
Copy link

hiperiondev commented Feb 14, 2022

Hello,
I have tried to compile the project on Fedora 35 without success.
I have isolated the VM and did a test of the LD parser. It works fine but it doesn't seem to recognize negated states.
Does it also happen in the original project?

The test is the following:

 i0/1--+--+-!i0/5---+---i0/6--+--+--+---(Q0/0 
       |  |         |         |  |  |         
 i0/2--+  |         +---i0/7--+  |  |         
       |  |         |         |  |  |         
 i0/3--+  |         +---i1/0--+  |  |         
          +-----i1/2------------+   |         
 i0/4-------------------------------+         

And the result:

0.LD  i0/4
1.OR (i1/2
2.AND (i0/3
3.OR (i0/2
4.OR (i0/1
5.) 
6.) 
7.OR (i0/6
8.AND (i1/0
9.OR (i0/7
10.OR (i0/5
11.AND (i0/3
12.OR (i0/2
13.OR (i0/1
14.) 
15.) 
16.) 
17.) 
18.) 
19.) 
20.ST  Q0/0

this is the project:
https://github.com/hiperiondev/plc-ladder

@hiperiondev
Copy link
Author

but parse_ld_line works ok:

memset(&line, 0, sizeof(line));
line.buf = " ---!i0/5--(Q0/3 ";
result = parse_ld_line(&line);

printf("test: %d\n",result == PLC_OK);
printf("test: %d\n",line.cursor == strlen(line.buf) - 4);
printf("test: %d\n",line.status == STATUS_RESOLVED);
printf("test: %d\n",line.stmt->tag == TAG_ASSIGNMENT);
printf("test: %d\n",line.stmt->v.ass.type == LD_COIL);

printf("test: %d\n",line.stmt->v.ass.right->v.exp.op == IL_AND);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.mod == IL_NEG);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.a->tag == TAG_IDENTIFIER);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.a->v.id.operand == OP_INPUT);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.a->v.id.byte == 0);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.a->v.id.bit == 5);
printf("test: %d\n",line.stmt->v.ass.right->v.exp.b == NULL);

result all 1;

@kalamara
Copy link
Owner

kalamara commented Feb 15, 2022 via email

@hiperiondev
Copy link
Author

Thanks for the reply,
I work with ESP32 and my idea is to port the VM to this processor.
Apparently the negated state is "lost" when you compile the entire program because when you compile just the line it does so correctly.

@kalamara
Copy link
Owner

kalamara commented Feb 16, 2022 via email

@hiperiondev
Copy link
Author

Yes, is needed a HAL, but isn't a complex task. I use IDF, then freertos

@hiperiondev
Copy link
Author

Have you seen the mentioned error? I really don't see where the denied status disappears ... very strange!
This week I want to finish a task of another of my projects (hpsdr-p1-rpitx) but next week I want to work in this port
The compiler is a must for this project!

@kalamara
Copy link
Owner

I believe this is a printing issue rather than a parsing issue, from the look of it its probably a problem in dump_instruction().
I will confirm it with a unit test and get back to you.
ps. it will take a while as this is a very low priority project for me.
ps2. we can also continue the discussion directly via email to kalamara AT users.sourceforge.net
thanks

@hiperiondev
Copy link
Author

Txs,
I have delete all references to VM and isolated compiler.
Compiler, VM and editor are three separate projects.
Probably tomorrow I will write an email to you.

@hiperiondev
Copy link
Author

I have send an email to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants