~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/eltopo/common/lexer.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef LEXER_H
2
 
#define LEXER_H
3
 
 
4
 
#include <iostream>
5
 
#include <string>
6
 
 
7
 
enum TokenType {TOKEN_EOF, TOKEN_ERROR, TOKEN_IDENTIFIER, TOKEN_NUMBER, TOKEN_STRING,
8
 
    TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN,
9
 
    TOKEN_LEFT_BRACKET, TOKEN_RIGHT_BRACKET};
10
 
 
11
 
struct Token
12
 
{
13
 
    TokenType type;
14
 
    // typically only one of the following has a meaningful value
15
 
    double number_value;
16
 
    std::string string_value;
17
 
    
18
 
    Token() : type(TOKEN_ERROR), number_value(1e+30), string_value("ERROR") {}
19
 
    ~Token() { clear(); }
20
 
    
21
 
    Token(const Token &source);
22
 
    Token &operator=(const Token &source);
23
 
    
24
 
    void set(TokenType type_);
25
 
    void set(TokenType type_, const std::string &value);
26
 
    void set(TokenType type_, double value);
27
 
    void clear(); // free up string storage after finished with a TOKEN_ERROR or TOKEN_IDENTIFIER
28
 
};
29
 
 
30
 
std::ostream& operator<<(std::ostream& out, const Token& t);
31
 
 
32
 
struct Lexer
33
 
{
34
 
    std::istream& input;
35
 
    
36
 
    Lexer(std::istream& input_) : input(input_) {}
37
 
    
38
 
    void read(Token &tok);
39
 
};
40
 
 
41
 
#endif