Code Monkey home page Code Monkey logo

kspsyntaxparser's Introduction

Hi there

⏱️ Work histroy

  • Software Engineer at Activ8 Inc. 🇯🇵 (2023-2024)
  • Software Engineer at Synamon Inc. 🇯🇵 (2018-2023)
  • Software Engineer at CODE Co., Ltd. 🇯🇵 (2013-2018)
  • Software Engineer at G-mode Corporation 🇯🇵 (2002-2013)

🌱 Skills

my skills


👀 Interest

my skills


🏃‍♀️ Activities

Top Langs github stats

kspsyntaxparser's People

Contributors

r-koubou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kspsyntaxparser's Issues

BUG - Variable initializer expression (using with brackets)

Sorry, written in Japanese and this bug is very difficult to solve..

本来KSPの言語仕様上問題がないが、以下の場合、初期化処理で誤検出をする

EXPECT/期待する動作

declare $num := ( 2 * 3 ) + 1  {OK}

NOW/現状

declare $num := (2 * 3 ) + 1  {NG:Syntax Error}

Workaround/回避方法

代入式の最初で括弧を使わない方法を検討してください。

declare $num := 7
or
declare $num := 2 * 3 + 1

Cause/原因

最初の式の括弧が【配列初期化子】なのか、【数学的な意味での括弧】なのかの判別が出来ない

declare $num := (2 * 3 ) + 1
{ この場合、(2*3)が配列初期化として誤検出されてしまう }

eBNFで初期化式を厳密に定義出来ていないため、構文解析フェーズでエラーになる。

強引にASTで表現すると、以下のようになる。KSPの仕様から逸脱した、支離滅裂な状況である。

                           < := >
                             +
                             |
                           < + >
                             |
                +------------+-----------+
                |                        |
       <Array Initializer>               1
                |
                + 
              < * > index[ 0 ]
                +
                |
            +--------+
            |        |
            2        3

Why difficult to solve / 修正困難な理由

最初の式の括弧が配列初期化子なのか、数学的な意味での括弧なのかの判別が出来ない。
解決するには、eBNFを書き直し、各種フェーズの処理を根本的に見直さなければならない

修正に伴う影響範囲を考えると、長時間の時間確保が必要であると考えている。

BUG - Array variable declaration

EXPECT

declare const $size := 1*2+1  { operator includes }
declare %array[$size]         { OK }

or

declare const $size := 3      { Literal }
declare %array[$size]         { OK }

NOW

Built-in to VScode Extention v0.3.14(current version)

declare const $size := 1*2+1  { operator includes }
declare %array[$size]         { Parser Error: "%array: Invalid array size" }

or

declare const $size := 3      { Literal }
declare %array[$size]         { OK }

NOTE

This bug has been fixed on stable-20180315

However, Not applied to VSCode Extension yet.
It is going to be applied in a few days. (Work in progress)

KSP Built-in variable (Array) access

Compiler cannot recognize KSP Built-In array variables at Semantic analysis phase.

[EXPECTED]

on init
    message( %CC[0] ) {OK}
end on

[NOW]

on init
    message( %CC[0] ) {Error: Index Out of bounds}
end on

Real variables can't be assigned the result of abs function

I am using a real variable and I am experiencing the following error at save:

[KSP] ":=" : not compatible type (Real := Void)

I tried stripping down the code as much as I could to find my mistake and indeed I get this error even in toy examples as this:

on init
  declare ~real_test
  ~real_test := abs(1.0)
end on

Love this extension btw, I hope this can be fixed soon :)

initialization by non constant value at declaration of variable statement

[EXPECT]

on init
    declare $i := 0 {OK: 0 is constant value}
    declare $k := get_engine_par( $ENGINE_PAR_VOLUME,-1,-1,-1 )
    {NG: Command may returns non constant value}
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end on

2018-04-07 17 36 27

[NOW]

on init
    declare $i := 0 {OK: 0 is constant value}
    declare $k := get_engine_par( $ENGINE_PAR_VOLUME,-1,-1,-1 )   {OK: Allowed}
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end on

BUG - Parser false detection in message() command

When integer or real value as message() command argument, parser is false detection.

messageコマンドに整数、浮動小数を指定した場合にパーサーが誤検出をしてしまう

EXPECT

message( "Hello" )              {OK}
message( $variable )            {OK}
message( "Hello" & $variable )  {OK}
message( 100 )                  {OK}
message( 1.0 )                  {OK}
message( %array )               {NG:It is correct}

NOW

message( "Hello" )              {OK}
message( $variable )            {NG->BUG}
message( "Hello" & $variable )  {OK}
message( 100 )                  {NG->BUG}
message( 1.0 )                  {NG->BUG}
message( %array )               {NG:It is correct}

BUG - Operator "&" / 文字列連結演算子 "&"

Sorry, written in Japanese and this bug is very difficult to solve..

本来KSPの言語仕様上問題がないが、以下の場合、文字列連結を正しく検知できない

EXPECT/期待する動作

@str := "value: " & 1 + 2 + 3  {OK: @str is "value6" }

NOW/現状

@str := "value: " & 1 + 2 + 3 {NG: 型の不一致として検出している}

Workaround/回避方法

四則演算子部分を明確に括弧で括ってください

@str := "value: " & (1 + 2 + 3) 
{他のプログラミング言語の多くはこのように記述しないと論理的な理由でエラーになります}
{変な癖(?)がついてしまうとKSP以外の言語で苦労します。強要はしませんが、習慣化されることを推奨します}

Cause/原因

&演算子を他の演算子と同等と概念として扱っているため、右項と左項の評価時に方の不一致が発生している。

@str := "Value: " & 1 + 2

この場合、現状ASTでは以下のように扱っている。

               < := >
                 +
                 |
         +-------+------+
         |              |
        @str            |
                      < + >  Left node: String, Right node: Integer
                        |
                +-------+--------+
                |                |
                +                2
              < & >
                +
                |
            +----+----+
            |         |
        "Value: "     1

Why difficult to solve / 修正困難な理由

現状、演算子として扱っているが、KONTAKTの挙動を見ると、暗黙の型変換の実態が不明確である。

KSPの言語仕様的に、&はもはや演算子ではなく、文字列連結命令であると考えている。

(JavaやC#のように+演算子で定義し、括弧で文字列と数値の連結の評価が厳密であるべきはずだったが、NIの継ぎ接ぎの追加でカオスになっていると思われる)

解決するには、eBNFから各種フェーズの処理を根本的に見直さなければならない

修正に伴う影響範囲を考えると、長時間の時間確保が必要であると考えている。

BUG - Value assign to string variable

EXPECT

@str := "Hello" {OK}
@str := 0       {OK}
@str := 0.0     {OK}

NOW

@str := "Hello" {OK}
@str := 0       {NG: integer value is Invalid type}
@str := 0.0     {NG: real value is Invalid type}

Now, work in progress.

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.