public string Visit(CharacterLiteral node) { var str = node.AnchorToken.Value; str = str.Substring(1, str.Length - 2); var character = ' '; if (str.Contains(@"\u")) { str = str.Replace(@"\u", ""); character = Convert.ToChar(Convert.ToInt32(str, 16)); } else if (codePoints.Keys.Contains(str)) { character = Convert.ToChar(codePoints[str]); } else { character = Char.Parse(str); } var unicode = (int)character; var result = "\t\tldc.i4 " + unicode + "\n"; return(result); }
public Node LitSimple() { Node simpleLiteral = null; switch (CurrentToken) { case TokenCategory.TRUE: simpleLiteral = new True() { AnchorToken = Expect(TokenCategory.TRUE) }; break; case TokenCategory.FALSE: simpleLiteral = new False() { AnchorToken = Expect(TokenCategory.FALSE) }; break; case TokenCategory.BASE_2_INT_LITERAL: simpleLiteral = new Base2IntegerLiteral() { AnchorToken = Expect(TokenCategory.BASE_2_INT_LITERAL) }; break; case TokenCategory.BASE_8_INT_LITERAL: simpleLiteral = new Base8IntegerLiteral() { AnchorToken = Expect(TokenCategory.BASE_8_INT_LITERAL) }; break; case TokenCategory.BASE_10_INT_LITERAL: simpleLiteral = new Base10IntegerLiteral() { AnchorToken = Expect(TokenCategory.BASE_10_INT_LITERAL) }; break; case TokenCategory.BASE_16_INT_LITERAL: simpleLiteral = new Base16IntegerLiteral() { AnchorToken = Expect(TokenCategory.BASE_16_INT_LITERAL) }; break; case TokenCategory.CHARACTER_LITERAL: simpleLiteral = new CharacterLiteral() { AnchorToken = Expect(TokenCategory.CHARACTER_LITERAL) }; break; default: throw new SyntaxError(simpleLiterals, tokenStream.Current); } return(simpleLiteral); }
public virtual void visit(CharacterLiteral literal) { if (CheckCharacter(literal.Character, baseInfer.ExpectedType)) { baseInfer.ResultType = baseInfer.ExpectedType; } }
public virtual bool VisitCharacterLiteral(CharacterLiteral stmt) { if (!VisitExpr(stmt)) { return(false); } return(true); }
public bool VisitCharacterLiteral(CharacterLiteral stmt) { throw new NotImplementedException(); }
public Void VisitCharacterLiteral(CharacterLiteral ast, Frame frame) { return(null); }
// Literals, Identifiers and Operators public TypeDenoter VisitCharacterLiteral(CharacterLiteral literal, Void arg) { return(StandardEnvironment.CharType); }
/// <summary> /// Parses the primary expression, and constructs an AST to represent its /// phrase structure. /// </summary> /// <returns> /// an <link>Triangle.SyntaxTrees.Expressions.Expression</link> /// </returns> /// <throws type="SyntaxError"> /// a syntactic error /// </throws> Expression ParsePrimaryExpression() { Compiler.WriteDebuggingInfo("Parsing Primary Expression"); Location startLocation = tokens.Current.Start; switch (tokens.Current.Kind) { case TokenKind.IntLiteral: { Compiler.WriteDebuggingInfo("Parsing Int Expression"); IntegerLiteral integer = ParseIntegerLiteral(); SourcePosition expressionPos = new SourcePosition(startLocation, tokens.Current.Finish); return(new IntegerExpression(integer, expressionPos)); } case TokenKind.CharLiteral: { Compiler.WriteDebuggingInfo("Parsing Char Expression"); CharacterLiteral charlit = ParseCharacterLiteral(); SourcePosition expressionPos = new SourcePosition(startLocation, tokens.Current.Finish); return(new CharacterExpression(charlit, expressionPos)); } case TokenKind.Identifier: { Compiler.WriteDebuggingInfo("Parsing Call Expression or Identifier Expression"); Identifier identifier = ParseIdentifier(); if (tokens.Current.Kind == TokenKind.LeftBracket) { Compiler.WriteDebuggingInfo("Parsing Call Expression"); AcceptIt(); ParameterSequence parameterSequence = ParseParameters(); Accept(TokenKind.RightBracket); SourcePosition expressionPos = new SourcePosition(startLocation, tokens.Current.Finish); return(new CallExpression(identifier, parameterSequence, expressionPos)); } else { Compiler.WriteDebuggingInfo("Parsing Identifier Expression"); SourcePosition expressionPos = new SourcePosition(startLocation, tokens.Current.Finish); return(new IdExpression(identifier, expressionPos)); } } case TokenKind.Operator: { Compiler.WriteDebuggingInfo("Parsing Unary Expression"); Operator operat = ParseOperator(); Expression expression = ParsePrimaryExpression(); SourcePosition expressionPos = new SourcePosition(startLocation, tokens.Current.Finish); return(new UnaryExpression(operat, expression, expressionPos)); } case TokenKind.LeftBracket: { Compiler.WriteDebuggingInfo("Parsing Bracket Expression"); AcceptIt(); Expression expression = ParseExpression(); Accept(TokenKind.RightBracket); return(expression); } default: { RaiseSyntacticError("\"%\" cannot start an expression", tokens.Current); return(null); } } }
public override object Visit(CharacterLiteral that, object value) { return new ImmediateStorage(((uint) that.Value).ToString()); }
public CharacterExpression(CharacterLiteral characterLiteral, SourcePosition position) : base(position) { Compiler.WriteDebuggingInfo($"Creating {this.GetType().Name}"); CharacterLiteral = characterLiteral; }
public override object Visit(CharacterLiteral that, object value = null) { return null; }
public CharacterExpression(CharacterLiteral characterLiteral, SourcePosition position) : base(position) { _characterLiteral = characterLiteral; }
public void Visit(CharacterLiteral node) { }
/// <summary> /// Visit operation called for character literals. /// /// <param name="lit">a character literal</param> /// </summary> public virtual void visit_character_literal(CharacterLiteral lit) { }
public AbstractValue Evaluate(CharacterLiteral expr) { return(STD_LOGIC_VALUE.CreateSTD_LOGIC_VALUE(expr.Character)); //return new CHARACTER_VALUE(expr.getCharacter()); }
public virtual object Visit(CharacterLiteral that, object value) { throw new System.NotImplementedException(); }