Added address literals
I don't know why someone would want to use a pointer literal in a script, but now you can because there's an opcode for it and fuck it.
This commit is contained in:
parent
05c8bce662
commit
e8c2b09105
3 changed files with 17 additions and 0 deletions
|
@ -52,6 +52,21 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class sunAddressLiteral : sunToken<uint>, sunTerm {
|
||||||
|
public sunAddressLiteral(sunSourceLocation location, string literal)
|
||||||
|
: base(location) {
|
||||||
|
Value = UInt32.Parse(literal.Substring(1), NumberStyles.AllowHexSpecifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Compile(sunCompiler compiler) {
|
||||||
|
compiler.Binary.WriteADR(Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
sunExpressionFlags sunTerm.GetExpressionFlags(sunContext context) {
|
||||||
|
return sunExpressionFlags.Literals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class sunStringLiteral : sunToken<string>, sunTerm {
|
class sunStringLiteral : sunToken<string>, sunTerm {
|
||||||
public sunStringLiteral(sunSourceLocation location, string literal)
|
public sunStringLiteral(sunSourceLocation location, string literal)
|
||||||
: base(location) {
|
: base(location) {
|
||||||
|
|
|
@ -93,6 +93,7 @@ namespace arookas {
|
||||||
case __sunConstants.INT_NUMBER: return new sunIntLiteral(location, token);
|
case __sunConstants.INT_NUMBER: return new sunIntLiteral(location, token);
|
||||||
case __sunConstants.HEX_NUMBER: return new sunHexLiteral(location, token);
|
case __sunConstants.HEX_NUMBER: return new sunHexLiteral(location, token);
|
||||||
case __sunConstants.DEC_NUMBER: return new sunFloatLiteral(location, token);
|
case __sunConstants.DEC_NUMBER: return new sunFloatLiteral(location, token);
|
||||||
|
case __sunConstants.ADR_NUMBER: return new sunAddressLiteral(location, token);
|
||||||
case __sunConstants.STRING: return new sunStringLiteral(location, token);
|
case __sunConstants.STRING: return new sunStringLiteral(location, token);
|
||||||
case __sunConstants.IDENTIFIER: return new sunIdentifier(location, token);
|
case __sunConstants.IDENTIFIER: return new sunIdentifier(location, token);
|
||||||
case __sunConstants.ELLIPSIS: return new sunEllipsis(location);
|
case __sunConstants.ELLIPSIS: return new sunEllipsis(location);
|
||||||
|
|
|
@ -94,6 +94,7 @@ IDENTIFIER = <<[_A-Za-z][_A-Za-z0-9]*>>
|
||||||
DEC_NUMBER = <<-?[0-9]+\.[0-9]+>>
|
DEC_NUMBER = <<-?[0-9]+\.[0-9]+>>
|
||||||
HEX_NUMBER = <<-?0x[0-9A-Fa-f]+>>
|
HEX_NUMBER = <<-?0x[0-9A-Fa-f]+>>
|
||||||
INT_NUMBER = <<-?[0-9]+>>
|
INT_NUMBER = <<-?[0-9]+>>
|
||||||
|
ADR_NUMBER = <<\$[0-9A-Fa-f]{8}>>
|
||||||
STRING = <<"(\\.|[^"])*">>
|
STRING = <<"(\\.|[^"])*">>
|
||||||
|
|
||||||
%productions%
|
%productions%
|
||||||
|
|
Loading…
Reference in a new issue