Code Monkey home page Code Monkey logo

arma-class-parser's People

Contributors

dahlgren avatar fusselwurm avatar overfl0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

arma-class-parser's Issues

parseMathExpression doesn't separate expressions well

Is this code even needed, since it currently only handles addition and parses it wrong.

The code is:

                return expression.split('+').map(parseNumber).reduce(function (prev, cur) {
                    return prev + cur;
                }, 0);

In our missions.sqm, we have:

position[]={12365.242,2.1711425e+020,8484.4668};

So parseArray will call parseMathExpression for the second value in the array.
This in turn will split it to: 2.1711425e and 020, parse them separately and then sum the result, which is wrong.

The value above is supposed to evaluate to 2.1711425 * 2^20 = 217114250000000000000 and parseFloat does this out of the box.
I don't know if parseMathExpression has ever been needed here. Maybe it was put here because the author thought this was a real mathematical addition?

How is this code licensed?

Hey!

What is the license of the code fot arma-class-parser?
You don't have any information about it on github (neither in the project settings nor in a LICENSE file so I need to ask here).

I'm a Python programmer and I was using your code in my python programs coupled with PyExecJS first and js2py later to allow its execution from Python. The first one is tricky to set up in Windows and the second one is quite slow because it's like emulation of Javascript code.

Because your code is quite small, I thought about porting it to Python to for greater simplicity, ability to install it with a python package manager and for greater speed, of course. That's why the license choice is important for me (since I'd probably be reusing some of your code or at least part of the constructs).

I would like to release my code on Github under the MIT license (TL;DR: you can use this code wherever you want but you need to keep the information about the author in the source) but for that to happen your code would also have to be licensed as MIT. Are you okay with this?
Otherwise, I'll probably quickly hack a simple parser in python from scratch just for my needs that I'll be ashamed of showing to the world so I'd prefer you to agree on that license, tbh ;)

I was reading your code yesterday and I plan on reporting a few issues that I've noticed there in the next few days.

Unclear purpose of weHaveAStringLineBreak

            weHaveAStringLineBreak = function () {
                return raw.substr(currentPosition, 6).indexOf('" \\n "') === 0;
            },

What is the purpose of this part of the code?
It seems to check for the presence of " \n " (including the quotes!). I haven't seen any occurrence of such a string in our sqm files anywhere so I suspect there is some kind of mistake here.

I would have to double-check this but I think that only one \ is needed if you mean splitting the string onto several lines. If that's the case, then the spaces around the \nare wrong because there could be an arbitrary number of whitespace characters on both sides of the newline character (including tabs, etc...). Also \r\n should be handled too probably.

Can't parse linebreaks from init fields

1.58 added the ability to make linebreaks in editor fields, could look like this

init="[this, ""Platoon""] call FP_fnc_setVehicleName; " \n "if (isServer) then { " \n "  [this] call FP_fnc_clearVehicle; this addWeaponCargoGlobal [""CUP_launch_M136"", 1]; " \n "  this addMagazineCargoGlobal [""1Rnd_HE_Grenade_shell"", 10]; " \n "this addMagazineCargoGlobal [""ATMine_Range_Mag"", 6]" \n "};";

This is not supported and errors out

Assert for not -1 instead of not infinity in parseMathExpression

In parseMathExpression, you have:

                var
                    posOfExpressionEnd = Math.min(
                        indexOfOrMaxInt.call(raw, chars.SEMICOLON, currentPosition),
                        indexOfOrMaxInt.call(raw, chars.CURLY_CLOSE, currentPosition),
                        indexOfOrMaxInt.call(raw, chars.COMMA, currentPosition)
                    ),
                    expression = raw.substr(currentPosition, posOfExpressionEnd - currentPosition);
                assert(posOfExpressionEnd !== -1);

I'm not a JavaScript developer but you probably meant to assert if posOfExpressionEnd is not infinity instead of -1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.