WebAssembly / spec

WebAssembly specification, reference interpreter, and test suite.
https://webassembly.github.io/spec/
Other
3.11k stars 439 forks source link

relax the var to allow utf8 encoding in the wat syntax #1618

Open bobzhang opened 1 year ago

bobzhang commented 1 year ago

According to the reference interpreter

let symbol =
  ['+''-''*''/''\\''^''~''=''<''>''!''?''@''#''$''%''&''|'':''`''.''\'']
let letter = ['a'-'z''A'-'Z']
let idchar = letter | digit | '_' | symbol
let name = idchar+
let id = '$' name

  | id as s { VAR s }

Currently I can only write ascii letters in the wat syntax, (local $var). It is a bit awkward to encode other utf8 letters in the wat syntax, so people can write (local $你好).

It is a bit worse in the current situation, since no escaping syntax supported so we have to do some magic encoding here

bobzhang commented 1 year ago

seems to be relevant to #617, the title is a bit misleading, it is not strange symbols though

rossberg commented 1 year ago

Yes, this is as spec'ed in the standard, and it is rather intentional that program text (outside strings and comments) is limited to plain ASCII. Unicode identifiers are a can of worms, as explained in the other issue.

The ability to annotate richer print names is part of the annotations proposal.