コード例 #1
0
 public bool Matches(Token t)
 {
     if (matchedTokenType != null)
         return t.Type == matchedTokenType;
     else
         return t.Lexeme == matchedString;
 }
コード例 #2
0
        // or from a nonterminal and a token, in which case we need to check
        // all the terminals for the given nonterminal and see if one matches the token
        public ISymbol[] Get(Nonterminal var, Token token)
        {
            Dictionary<Terminal, ISymbol[]> tableRow = table[var];

            foreach (Terminal term in tableRow.Keys)
                if (term.Matches(token))
                    return tableRow[term];

            return null;
        }
コード例 #3
0
 public ReadStmt(string identifier, Token token)
     : base(token)
 {
     this.identifier = identifier;
 }
コード例 #4
0
 public PrintStmt(Expression expr, Token token)
     : base(token)
 {
     this.expr = expr;
 }
コード例 #5
0
 public ForStmt(string identifier, Expression startVal, Expression endVal, IEnumerable<Statement> block, Token token)
     : base(token)
 {
     this.identifier = identifier;
     this.startVal = startVal;
     this.endVal = endVal;
     this.block = block;
 }
コード例 #6
0
 public LexicalError(Token t)
     : base(t)
 {
 }
コード例 #7
0
 public RuntimeError(Token t, string description)
     : base(t)
 {
     this.description = description;
 }
コード例 #8
0
 // recall the last valid token
 private Token TakeToken()
 {
     Token t = lastToken;
     lastToken = null;
     row = endRow;
     col = endCol;
     startRow = endRow;
     startCol = endCol;
     return t;
 }
コード例 #9
0
 public ValueExpr(Value value, Token token)
     : base(token)
 {
     this.value = value;
 }
コード例 #10
0
 public UnaryOp(char op, Expression expr, Token token)
     : base(token)
 {
     this.op = op; this.expr = expr;
 }
コード例 #11
0
 public IdentifierExpr(string identifier, Token token)
     : base(token)
 {
     this.identifier = identifier;
 }
コード例 #12
0
 // Every expression contains token to identify location in code
 Expression(Token token)
 {
     this.token = token;
 }
コード例 #13
0
 public BinaryOp(Expression lhs, char op, Expression rhs, Token token)
     : base(token)
 {
     this.op = op;
     this.lhs = lhs;
     this.rhs = rhs;
 }
コード例 #14
0
 public SyntaxError(Token t)
     : base(t)
 {
 }
コード例 #15
0
 // resets the automaton to its initial state
 public void Reset()
 {
     row = 0;
     col = 0;
     endRow = 0;
     endCol = 0;
     startRow = 0;
     startCol = 0;
     tokenBuffer = new Queue<Token>();
     lastToken = null;
     position = start;
 }
コード例 #16
0
 // remember the last valid token
 private void StoreToken(TokenType type)
 {
     lastToken = type.CreateToken(charBuffer, startRow, startCol);
     endRow = row;
     endCol = col;
 }
コード例 #17
0
 public AssignStmt(string identifier, Expression expr, Token token)
     : base(token)
 {
     this.identifier = identifier;
     this.expr = expr;
 }
コード例 #18
0
 // Every statement contains token to identify location in code
 Statement(Token token)
 {
     this.token = token;
 }
コード例 #19
0
 public DeclarationStmt(string identifier, ValueType type, Token token, Expression initialValue)
     : this(identifier, type, token)
 {
     this.initialValue = initialValue;
 }
コード例 #20
0
 // just checks if a token should be yielded by the generator
 private bool IsRelevant(Token t, bool EOFisRelevant)
 {
     return (t.Type.TokenPriority != TokenType.Priority.Whitespace && (t.Type != TokenType.EOF || EOFisRelevant));
 }
コード例 #21
0
 public DeclarationStmt(string identifier, ValueType type, Token token)
     : base(token)
 {
     this.identifier = identifier;
     this.type = type;
 }
コード例 #22
0
 public SemanticError(Token t, string description)
     : base(t)
 {
     this.description = description;
 }
コード例 #23
0
ファイル: Error.cs プロジェクト: psaikko/interpreter-project
 protected Error(Token t)
 {
     this.t = t;
 }