diff --git a/ssc/ast/nodes.literals.cs b/ssc/ast/nodes.literals.cs index 18fd63f..6517482 100644 --- a/ssc/ast/nodes.literals.cs +++ b/ssc/ast/nodes.literals.cs @@ -52,6 +52,21 @@ namespace arookas { } } + class sunAddressLiteral : sunToken, 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, sunTerm { public sunStringLiteral(sunSourceLocation location, string literal) : base(location) { diff --git a/ssc/parser.cs b/ssc/parser.cs index 2892fb9..1b50afd 100644 --- a/ssc/parser.cs +++ b/ssc/parser.cs @@ -93,6 +93,7 @@ namespace arookas { case __sunConstants.INT_NUMBER: return new sunIntLiteral(location, token); case __sunConstants.HEX_NUMBER: return new sunHexLiteral(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.IDENTIFIER: return new sunIdentifier(location, token); case __sunConstants.ELLIPSIS: return new sunEllipsis(location); diff --git a/ssc/sunscript.grammar b/ssc/sunscript.grammar index b4cfa15..bc42bc4 100644 --- a/ssc/sunscript.grammar +++ b/ssc/sunscript.grammar @@ -94,6 +94,7 @@ IDENTIFIER = <<[_A-Za-z][_A-Za-z0-9]*>> DEC_NUMBER = <<-?[0-9]+\.[0-9]+>> HEX_NUMBER = <<-?0x[0-9A-Fa-f]+>> INT_NUMBER = <<-?[0-9]+>> +ADR_NUMBER = <<\$[0-9A-Fa-f]{8}>> STRING = <<"(\\.|[^"])*">> %productions%