OpenXcom Forum

OpenXcom Forks => OXCE Bugs => OpenXcom Extended (OXCE) => OXCE Bugs FIXED => Topic started by: zRrr on February 11, 2025, 04:16:09 pm

Title: [FIXED] Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: zRrr 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
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Yankes on February 11, 2025, 04:27:18 pm
Ok, I will fix it
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Meridian on February 11, 2025, 05:51:17 pm
Just out of curiosity, why do we need the hexadecimal numbers?
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Yankes 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.
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Delian on February 11, 2025, 06:12:45 pm
Should've used my (https://github.com/Delian0/OpenXcom/commit/da606e21062e31a857a4680119635a35f898a14a) solution :P
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Yankes 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.
Title: Re: Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Yankes 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.
Title: Re: [FIXED] Y-Script fails to parse hexadecimal numbers since 8.0.4
Post by: Meridian on February 14, 2025, 05:57:24 pm
Fixed.

https://github.com/MeridianOXC/OpenXcom/commit/08ee0ec32042c626e751d8763563590bea0c5a27