private void PassExpr(String stop_chars = ";") { Token t = new Token(); int count_br = 0; do { try { t = scan.Read(); if (t.type == Token.Type.LBRACE) { count_br++; } else if (t.type == Token.Type.RBRACE) { count_br--; } } catch (Scaner.Exception e) { scan.Pass(); logger.Add(e); } }while (!(t.type == Token.Type.EOF || (t.GetStrVal().IndexOf(stop_chars) != -1 && !this.parse_args_declaraton) || (this.parse_block && (t.type == Token.Type.RBRACE || count_br <= 0)) || (this.parse_args_declaraton && (t.type == Token.Type.COMMA || scan.Peek().type == Token.Type.RPAREN)) )); }
private bool IsType(Token t) { switch (t.type) { case Token.Type.KW_STRUCT: case Token.Type.KW_ENUM: return(true); default: Symbols.Type tt = null; if (tstack.ContainsType(t.GetStrVal())) { tt = tstack.GetType(t.GetStrVal()); } return(tt != null && !(tt is Symbols.Func)); } }
private Syntax.Expression ParsePrimaryExpr() { Syntax.Expression res = null; switch (scan.Peek().type) { case Token.Type.CONST_CHAR: res = new Syntax.Const(scan.Read(), tstack.GetType("char")); break; case Token.Type.CONST_DOUBLE: res = new Syntax.Const(scan.Read(), tstack.GetType("double")); break; case Token.Type.CONST_INT: res = new Syntax.Const(scan.Read(), tstack.GetType("int")); break; case Token.Type.CONST_STRING: this.count_string++; Symbols.ARRAY strt = new Symbols.ARRAY(tstack.GetType("char")); Token str = scan.Read(); strt.SetSize(new Syntax.Const(str.GetStrVal().Length.ToString(), tstack.GetType("int"))); res = new Syntax.Const(str, strt); break; case Token.Type.IDENTIFICATOR: Token t = scan.Read(); Symbols.Var v = new Symbols.SuperVar(); try { v = tstack.GetVariable(t); } catch (Symbols.Exception e) { this.logger.Add(e); } res = new Syntax.Identifier(t, v); break; case Token.Type.LPAREN: scan.Read(); res = ParseExpression(); CheckToken(scan.Peek(), Token.Type.RPAREN, true); break; } return(res); }
private bool IsType(Token t) { switch (t.type) { case Token.Type.KW_STRUCT: case Token.Type.KW_ENUM: return true; default: Symbols.Type tt = null; if (tstack.ContainsType(t.GetStrVal())) { tt = tstack.GetType(t.GetStrVal()); } return tt != null && !(tt is Symbols.Func); } }
private void PassExpr(String stop_chars = ";") { Token t = new Token(); int count_br = 0; do { try { t = scan.Read(); if (t.type == Token.Type.LBRACE) { count_br++; } else if (t.type == Token.Type.RBRACE) { count_br--; } } catch (Scaner.Exception e) { scan.Pass(); logger.Add(e); } } while (!(t.type == Token.Type.EOF || (t.GetStrVal().IndexOf(stop_chars) != -1 && !this.parse_args_declaraton) || (this.parse_block && (t.type == Token.Type.RBRACE || count_br <= 0)) || (this.parse_args_declaraton && (t.type == Token.Type.COMMA || scan.Peek().type == Token.Type.RPAREN)) )); }