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

CBA_fnc_parseYAML fails to parse several YAML components #1395

Open
Freddo3000 opened this issue Nov 22, 2020 · 0 comments
Open

CBA_fnc_parseYAML fails to parse several YAML components #1395

Freddo3000 opened this issue Nov 22, 2020 · 0 comments
Labels

Comments

@Freddo3000
Copy link
Contributor

Mods (complete and add to the following information):

  • Arma 3: 2.00 stable
  • CBA: 3.15.2 stable

Description:
As the title says, the function fails to parse:

Numbers
- 2

// parses to ["2"] (incorrect, should be number)

| and > multiline strings
data: |
   There once was a tall man from Ealing
   Who got on a bus to Darjeeling
       It said on the door
       "Please don't sit on the floor"
   So he carefully sat on the ceiling
data: >
   Wrapped text
   will be folded
   into a single
   paragraph

   Blank lines denote
   paragraph breaks

// Both fail

{} hashmaps
name: John Smith
age: 33

// parses to ["#CBA_HASH#",["name","age"],["John Smith","33"],any]

{name: John Smith, age: 33}

// parses to ["#CBA_HASH#",["{name"],["John Smith, age: 33}"],any] (incorrect)

--- document headers and ... terminators Used to separate multiple documents within a single stream. Ideally the function would either create an array containing all the hashes (documents) when one is encountered, or parse the selected document by index (default first).
--- # Favorite movies
- Casablanca
- North by Northwest
- The Man Who Wasn't There

// Fails

Without the above, ... used to indicate end of document fails.

Inline arrays
key1:
  - value1
  - value2
  - value3
  - value4
  - value5

// parses to ["#CBA_HASH#",["key1"],[["value1","value2","value3","value4","value5"]],any]

key1: [value1,value2,value3,value4,value5]

// parses to ["#CBA_HASH#",["key1"],["[value1,value2,value3,value4,value5]"],any] (incorrect)

key1: [value1,value2
  value3,value4,value5]

// fails

" and ' alternative string syntax
Employee:
  id: 1
  name: "Franc"
  department:
    name: "Sales"
    depid: "11"

// parses to ["#CBA_HASH#",["Employee"],[["#CBA_HASH#",["id","name","department"],["1","""Franc""",["#CBA_HASH#",["name","depid"],["""Sales""","""11"""],any]],any]],any] (Incorrect)

Note the """

Hashes within arrays
- name: Mary Smith
  age: 27

// fails

And other things that are more of a request than anything else:

  • !!type used to explicitly define the type, and local datatypes !type
  • & anchors and * references
  • Language independent scalar types (See https://yaml.org/refcard.html near bottom)

Examples taken (in part or full) from:

Steps to reproduce:

  • Go to editor, save empty mission
  • Go to mission directory and create a file, paste any of the above examples into the file
  • Execute the parseYAML function on the created file, output should be the same as written
  • Double check across to https://yaml-online-parser.appspot.com/ or similar

Expected behavior:
The above examples to be correctly parse, though with some of the examples I might be stretching it a bit.
Ideally the function should be able to parse:

Extreme example
---
receipt:     Oz-Ware Purchase Invoice
date:        2012-08-06
customer:
    first_name:   Dorothy
    family_name:  Gale

items:
    - part_no:   A4786
      descrip:   Water Bucket (Filled)
      price:     1.47
      quantity:  4

    - part_no:   E1628
      descrip:   High Heeled "Ruby" Slippers
      size:      8
      price:     133.7
      quantity:  1

bill-to:  &id001
    street: |
            123 Tornado Alley
            Suite 16
    city:   East Centerville
    state:  KS

ship-to:  *id001

specialDelivery:  >
    Follow the Yellow Brick
    Road to the Emerald City.
    Pay no attention to the
    man behind the curtain.
...

Where did the issue occur?

  • Editor (Singleplayer) / Editor (Multiplayer)

Log Files:

Details
20:39:40 [CBA] (hashes) ERROR: CBA YAML parser error x\cba\addons\hashes\fnc_parseYAML.sqf:72
20:39:40             Unexpected new-line, when expecting ':', in "test.yaml" at line 2:
20:39:40             
20:39:40             001: ...
20:39:40             002: |#|
20:39:40 Error in expression <es) - 1);
private _lastChar = _lastLine select ((count _lastLine) - 1);

_lastLi>
20:39:40   Error position: <select ((count _lastLine) - 1);

_lastLi>
20:39:40   Error Zero divisor
20:39:40 File \x\cba\addons\hashes\fnc_parseYAML.sqf [CBA_fnc_parseYAML]..., line 1887
20:39:52 [CBA] (hashes) ERROR: CBA YAML parser error x\cba\addons\hashes\fnc_parseYAML.sqf:72
20:39:52             Unexpected new-line, when expecting ':', in "test.yaml" at line 4:
20:39:52             
20:39:52             001: test: 1
20:39:52             002: 
20:39:52             003: ...
20:39:52             004: |#|
20:39:52 Error in expression <es) - 1);
private _lastChar = _lastLine select ((count _lastLine) - 1);

_lastLi>
20:39:52   Error position: <select ((count _lastLine) - 1);

_lastLi>
20:39:52   Error Zero divisor
20:39:52 File \x\cba\addons\hashes\fnc_parseYAML.sqf [CBA_fnc_parseYAML]..., line 1887
20:41:01 [CBA] (hashes) ERROR: CBA YAML parser error x\cba\addons\hashes\fnc_parseYAML.sqf:72
20:41:01             Unexpected new-line, when expecting ':', in "test.yaml" at line 2:
20:41:01             
20:41:01             001: [milk, groceries, eggs, juice, fruits]
20:41:01             002: |#|
20:41:01 Error in expression <es) - 1);
private _lastChar = _lastLine select ((count _lastLine) - 1);

_lastLi>
20:41:01   Error position: <select ((count _lastLine) - 1);

_lastLi>
20:41:01   Error Zero divisor
20:41:01 File \x\cba\addons\hashes\fnc_parseYAML.sqf [CBA_fnc_parseYAML]..., line 1887
20:41:17 [CBA] (hashes) ERROR: CBA YAML parser error x\cba\addons\hashes\fnc_parseYAML.sqf:72
20:41:17             Unexpected new-line, when expecting ':', in "test.yaml" at line 2:
20:41:17             
20:41:17             001:     [milk, groceries, eggs, juice, fruits]
20:41:17             002: |#|
20:41:17 Error in expression <es) - 1);
private _lastChar = _lastLine select ((count _lastLine) - 1);

_lastLi>
20:41:17   Error position: <select ((count _lastLine) - 1);

_lastLi>
20:41:17   Error Zero divisor
20:41:17 File \x\cba\addons\hashes\fnc_parseYAML.sqf [CBA_fnc_parseYAML]..., line 1887

Additional context:
I'm not really expecting this to be solved, but I'm just throwing it out here. Might be nice for someone who wants a challenge.

@Freddo3000 Freddo3000 added the Bug label Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant