title: Writing a lexer for a new programming language in python
body: <p>I have no idea how/where to start. I'm supposed to be using python, and more specifically, the ply library. So far, all I've done in create a list of tokens that will be part of the language. That list is given below:</p>
  
  <pre class="lang-py prettyprint-override"><code>
  tokens = (
                                                           # OPERATORS #
      'PLUS' ,        # +
      'MINUS' ,       # -
      'MULTIPLY',     # *
      'DIVIDE',       # /
      'MODULO',       # %
  
  
      'NOT',          # ~
      'EQUALS',       # =
  
                                                           # COMPARATORS #
      'LT',           # &lt;
      'GT',           # &gt;
      'LTE',          # &lt;=
      'GTE',          # &gt;=
      'DOUBLEEQUAL',  # ==
      'NE',           # #
  
  
      'AND',          # &amp;
      'OR',           # |
                                                      # CONDITIONS AND LOOPS #    
  
      'IF',           # if
      'ELSE',         # else
      'ELSEIF',       # elseif
      'WHILE',        # while
      'FOR',          # for
  #   'DOWHILE',      # haven't thought about this yet
                                                            # BRACKETS #
  
      'LPAREN',       # (
      'RPAREN',       # )
      'LBRACE',       # [
      'RBRACE',       # ]
      'BLOCKSTART',   # {
      'BLOCKEND',     # }
                                                          # IDENTIFIERS #
  
      'INTEGER',      # int
      'DOUBLE',       # dbl
      'STRING',       # str
      'CHAR',         # char
  
      'SEMICOLON',    # ;
      'DOT',          # .
      'COMMA',        # ,
      'QUOTES',       # '
      'DOUBLEQUOTES', # "
      'COMMENTLINE',  # --
  
      'RETURN',       # return
  
  )
  
  </code></pre>
  
  <p>I've obviously got a long way to go, seeing as I also need to write a parser and an interpreter. </p>
  
  <p>I've got a few questions: </p>
  
  <ol>
  <li>How do I use the ply library? </li>
  <li>Is this a good start, and if so, what do I go from this? </li>
  <li>Are there any resources I can use to help me with this. </li>
  </ol>
  
  <p>I've tried googling stuff on writing new programming languages, but I haven't yet found anything satisfactory</p>