Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Comment Cause SyntaxError #162

Open
lushijie opened this issue Oct 21, 2018 · 3 comments
Open

Comment Cause SyntaxError #162

lushijie opened this issue Oct 21, 2018 · 3 comments

Comments

@lushijie
Copy link

// file content
struct PromotionRequest{
  1: optional string promotionId;
  2: optional string promotionName; // 名称 
}

// code
new Thriftrw({
    strict: false,
    entryPoint: path.resolve(filePath),
    allowOptionalArguments: true,
    defaultAsUndefined: false,
    allowIncludeAlias: true,
    allowFilesystemAccess: true,
}).toJSON();

// error output:  
SyntaxError: Expected "&", comment, end of line, identifier or whitespace but "'" found.
But if remove promotionName's comment, it will fine.
@lushijie
Copy link
Author

lushijie commented Oct 21, 2018

May be it's multiple byte cause error here, but I don't know how to fix it.

// thrift-idl.pegjs
SingleLineComment
  = '//' comment:(!LineTerminator sc:SourceCharacter { return sc; })* {
    return new ast.Comment(comment);
  }

@kriskowal
Copy link
Contributor

Thrift reads the entryPoint as ASCII, not UTF-8. We chose ASCII for inter-language compatibility. Apache Thrift for Python 2, for example, does not handle high glyphs.

I’m not sure we would even entertain changing the encoding of IDL, at least until a thorough review illustrates that all Thrift compliers, at least the ones we’re obliged to use, are all able to use UTF-8.

@lushijie
Copy link
Author

So by now, what can I do to resolve my problem? Change the entryPoint from UTF-8 to ASCII ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants