Author Topic: [FIXED] Y-Script fails to parse hexadecimal numbers since 8.0.4  (Read 526 times)

Offline zRrr

  • Sergeant
  • **
  • Posts: 37
    • View Profile
[FIXED] Y-Script fails to parse hexadecimal numbers since 8.0.4
« on: February 11, 2025, 04:16:09 pm »
Since 8.0.4 y-script refuses to parse hexadecimal numbers with 'A'-'F' in them. Hex numbers with just decimal digits are fine.

Code: [Select]
extended:
  scripts:
    newTurnItem:
      - new: INT_0x111
        offset: 10
        code: |
          debug_log "test 0x111" 0x111;
          return;
         
      - new: INT_0x1A
        offset: 10
        code: |
          debug_log "test 0x1A" 0x1A;
          return;

      - new: INT_0xAA
        offset: 10
        code: |
          debug_log "test 0xAA" 0xAA;
          return;
         
      - new: INT_0xA000
        offset: 10
        code: |
          debug_log "test 0xA000" 0xA000;
          return;
         
      - new: INT__0x1a
        offset: 10
        code: |
          debug_log "test 0x1a" 0x1a;
          return;

logs:

Code: [Select]
[11-02-2025_17-08-14] [ERROR] Error in parsing script 'newTurnItem' for 'Global:INT_0x1A': invalid argument '0x1A' in line: 'debug_log "test 0x1A" 0x1A;' (at 1)
[11-02-2025_17-08-14] [ERROR]     for node with code at line 42 in D:/games/_openxcom-extended/user/mods/__int-literals-test/int-literals-test.rul
[11-02-2025_17-08-14] [ERROR]
[11-02-2025_17-08-14] [ERROR] Error in parsing script 'newTurnItem' for 'Global:INT_0xAA': invalid argument '0xA' in line: 'debug_log "test 0xAA" 0xAA;' (at 1)
[11-02-2025_17-08-14] [ERROR]     for node with code at line 48 in D:/games/_openxcom-extended/user/mods/__int-literals-test/int-literals-test.rul
[11-02-2025_17-08-14] [ERROR]
[11-02-2025_17-08-14] [ERROR] Error in parsing script 'newTurnItem' for 'Global:INT_0xA000': invalid argument '0xA' in line: 'debug_log "test 0xA000" 0xA000;' (at 1)
[11-02-2025_17-08-14] [ERROR]     for node with code at line 54 in D:/games/_openxcom-extended/user/mods/__int-literals-test/int-literals-test.rul
[11-02-2025_17-08-14] [ERROR]
[11-02-2025_17-08-14] [ERROR] Error in parsing script 'newTurnItem' for 'Global:INT__0x1a': invalid argument '0x1a' in line: 'debug_log "test 0x1a" 0x1a;' (at 1)
[11-02-2025_17-08-14] [ERROR]     for node with code at line 60 in D:/games/_openxcom-extended/user/mods/__int-literals-test/int-literals-test.rul

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3425
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #1 on: February 11, 2025, 04:27:18 pm »
Ok, I will fix it

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9393
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #2 on: February 11, 2025, 05:51:17 pm »
Just out of curiosity, why do we need the hexadecimal numbers?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3425
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #3 on: February 11, 2025, 06:05:02 pm »
This is script code, and sometimes if you want squeeze more data into `int` bit mask are useful.
Overall similar like C++, in 99% cases you can live without them, but sometimes are very valuable.

Offline Delian

  • Commander
  • *****
  • Posts: 645
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #4 on: February 11, 2025, 06:12:45 pm »
Should've used my solution :P

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3425
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #5 on: February 11, 2025, 07:14:47 pm »
I prefer to not strongly couple script engine with yaml lib (as it should only be used to load data) but probably need use your version then.

[ps]

I check gotbolt and its show that code should accept upper cases hex, problem could be else where.
« Last Edit: February 11, 2025, 07:22:03 pm by Yankes »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3425
    • View Profile
Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
« Reply #6 on: February 14, 2025, 01:21:15 am »
ok, Its look by bug was elsewhere, my conclusion is that implicit conversion are root of all evil :D
In my tokenizer I miss one check because of typo and implicit conversion still allowing bugged code to compile.