Code Monkey home page Code Monkey logo

Comments (12)

ice1000 avatar ice1000 commented on June 28, 2024

Cmc.Ast.Dump

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024
statement list:
  variable declaration [recurFunc]:
    type:
      lambda type [(i8)->i8]
    initialize expression:
      lambda:
        type:                                               
          lambda type [(i8)->i8]     
        parameters:                   
          variable declaration [a]:   
            type:                  
              primary type [i8]         
            initialize expression:  
              null expression           
        body:                             
          statement list:                     
            return statement:                                       
              function call expression:                    
                receiver:                  
                  variable expression [recur]:    
                    type:                   
                      lambda type [(i8)->i8]  
                parameters:                     
                  variable expression [a]:              
                    type:
                      primary type [i8] 
                type:
                  i8 
  variable declaration [gg]:    
    type:                               
      primary type [i8]             
    initialize expression:                   
      null expression                    
  assignment statemnt:        
    lhs:  
      variable expression [gg]:   
        type:                
          primary type [i8]   
    rhs:                      
      function call expression:      
        receiver:                     
          variable expression [recurFunc]:    
            type:            
              lambda type [(i8)->i8]     
        parameters:            
          literal expression [233]:   
            primary type [i8]         
        type:                  
          primary type [i8]  

  assignment statemnt:        
    lhs:  
      variable expression [gg]:   
        type:                
          primary type [i8]   
    rhs:                      
      function call expression:      
        receiver:                     
          variable expression [recurFunc]:    
            type:            
              lambda type [(i8)->i8]     
        parameters:            
          literal expression [233]:   
            primary type [i8]         
        type:                  
          primary type [i8]  

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024

debug 我都是直接上调试器的,用的很爽

from cm-document.

AkimotoAkari avatar AkimotoAkari commented on June 28, 2024

不是啊,字符位置什么的,参考sourcemap的实例

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024

字符位置啥意思?行号什么的都有好好保留的

from cm-document.

AkimotoAkari avatar AkimotoAkari commented on June 28, 2024

/- -/不仅仅行号啊,例如说
(stacktrace from Node.js REPL)
> global.resfjdorgjdiojdjrgnklsdjghuisdhdofer() TypeError: global.resfjdorgjdiojdjrgnklsdjghuisdhdofer is not a function at repl:1:8 /- HERE !-/ at ContextifyScript.Script.runInThisContext (vm.js:44:33)

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024

哦,我刚刚在吃火锅的时候在廖雪峰的博客里面看了下source map是啥。这个可能得做一会去了,我最近写代码的时间比较少。

可以考虑 @thautwarm

from cm-document.

thautwarm avatar thautwarm commented on June 28, 2024

字符位置也需要确定?token那步可能直接丢弃一些字符的。
我个人觉得metainfo就足够了。toJS是指toJSON吗?if so, 并不困难,Parser那步就能完成,比如我这边这个

Stmt[Expr[BinOp[Factor[Atom[Literal[Name [' f ']]
             LP [' ( '] Expr[BinOp[Factor[Atom[Literal[Name [' a ']]
                     LP [' ( '] Expr[BinOp[Factor[Atom[Literal[Name [' b ']]
                            ]
                          ]
                        ]
                      ]
                     RP [' ) ']]
                  ]
                ]
              ]
             RP [' ) ']]
          ]
        ]
      ]
    ]

转JSON就是

{"stmt":{"expr":
            "<以下省略...字>"
           }
}

然后debug我也是直接用这个,加上parser步骤的一些过程信息,例如解析上述代码的部分过程信息:

Name <= Name [' a ']
RET

RET

Literal <= Literal[Name [' a ']]
  
RET

RET

(Closure | Literal) <= (Closure | Literal)[Literal[Name [' a ']]
    ]
  
(Closure | Literal) <= (Closure | Literal)[Literal[Name [' a ']]
    ]
  
Trailer WITH [(0, 'AWAIT'), (0, 'LINESPLIT'), (0, 'Expr'), (0, 'BinOp'), (0, 'Factor'), (0, '(Op)*'), (0, 'Atom'), (0, '(Closure | Literal)'), (0, 'Literal'), (0, 'Name'), (1, 'Trailer'), (1, 'LP'), (2, '(Expr)*'), (2, 'Expr'), (2, 'BinOp'), (2, 'Factor'), (2, '(Op)*'), (2, 'Atom'), (2, '(Closure | Literal)'), (2, 'Literal'), (2, 'Name'), (3, 'Trailer')]
Trailer WITH [(0, 'AWAIT'), (0, 'LINESPLIT'), (0, 'Expr'), (0, 'BinOp'), (0, 'Factor'), (0, '(Op)*'), (0, 'Atom'), (0, '(Closure | Literal)'), (0, 'Literal'), (0, 'Name'), (1, 'Trailer'), (1, 'LP'), (2, '(Expr)*'), (2, 'Expr'), (2, 'BinOp'), (2, 'Factor'), (2, '(Op)*'), (2, 'Atom'), (2, '(Closure | Literal)'), (2, 'Literal'), (2, 'Name'), (3, 'Trailer')]
LP <= LP [' ( ']

@AkimotoAkari

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024

但是你这个是Python血的 :trollface:

from cm-document.

thautwarm avatar thautwarm commented on June 28, 2024

@ice1000 马上就有C#版本了。只要一个语言有列表就好了(逃

from cm-document.

AkimotoAkari avatar AkimotoAkari commented on June 28, 2024

/- -/都是大大啊
是咋样丢弃的- -总之出现错误时对了就好

from cm-document.

ice1000 avatar ice1000 commented on June 28, 2024

在tokenize那一步就把字符位置存下来就是了,tan$π/2

from cm-document.

Related Issues (20)

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.