private void Identifiers2() {
AssertTokenizer t = NewAssertTokenizer();
// 'variable' non-terminal needs to set $<String>$ even for keywords,
// otherwise the content of previous token is stored in token value and is interpreted as string.
t.Load("//\ntrue")[Tokens.RegexpBegin][Tokens.RegexpEnd][Tokens.NewLine][Tokens.True].EOF();
t.Load("Σ = CΣ", (tok) => tok.AllowNonAsciiIdentifiers = true).
ReadSymbol(Tokens.Identifier, "Σ")[Tokens.Assignment].ReadSymbol(Tokens.ConstantIdentifier, "CΣ").EOF();
t.Load("Σ = CΣ")[Tokens.InvalidCharacter].Expect(Errors.InvalidCharacterInExpression);
t.Load("@Σ=@@Σ=$Σ", (tok) => tok.AllowNonAsciiIdentifiers = true)
[Tokens.InstanceVariable][Tokens.Assignment]
[Tokens.ClassVariable][Tokens.Assignment]
[Tokens.GlobalVariable].EOF();
t.Load("def Σ;end", (tok) => tok.AllowNonAsciiIdentifiers = true)
[Tokens.Def][Tokens.Identifier][Tokens.Semicolon][Tokens.End].EOF();
#if OBSOLETE // ???
// we should report a warning if -KU is used and treat BOM as whitespace (MRI 1.8 treats the BOM as identifier):
t.Load(new byte[] {
0xEF, 0xBB, 0xBF, (byte)'x'
}, (tok) => {
tok.Compatibility = RubyCompatibility.Ruby186;
tok.Encoding = RubyEncoding.KCodeUTF8;
tok.Verbatim = true;
})
[Tokens.Whitespace][Tokens.Identifier].Expect(Errors.ByteOrderMarkIgnored);
// we should report a warning if -KCODE is not used and treat BOM as whitespace (MRI 1.8 reports an error):
t.Load(new byte[] {
0xEF, 0xBB, 0xBF, (byte)'=', (byte)'1'
}, (tok) => {
tok.Compatibility = RubyCompatibility.Ruby186;
tok.AllowNonAsciiIdentifiers = false;
tok.Verbatim = true;
})
[Tokens.Whitespace][Tokens.Assignment][1].Expect(Errors.ByteOrderMarkIgnored);
#endif
t.Expect();
}