adjacency as an operator - can any lexer handle it?

前端 未结 3 771
眼角桃花
眼角桃花 2021-01-21 17:08

Say a language defines adjacency of two mathematical unicode alphanumerical symbols as an operator. Say,

3条回答
  •  猫巷女王i
    2021-01-21 18:00

    Unless tokens have a fixed length, you must separate adjacent tokens of the same type with some other token or whitespace. The Gosu programming language incorporates adjacency to implement "binding expressions" which support units:

    var length = 10m  // 10 meters
    
    var work = 5kg * 9.8 m/s/s * 10m
    print( work )  // prints 490 J
    
    var investment = 5000 EUR + 10000 USD
    
    var date = 1966-May-5 2:35:53:909 PM PST
    

提交回复
热议问题