             literal = n.body
         else
           if literal?
-            sequence.push Terminal(literal)
+            sequence.push makeLiteral(literal)
             literal = null
 
           sequence.push rx2rr n
 
       if literal?
-        sequence.push Terminal(literal)
+        sequence.push makeLiteral(literal)
 
       if sequence.length == 1
         sequence[0]


{Diagram, Sequence, Choice, Optional, OneOrMore, ZeroOrMore, Terminal,
 NonTerminal, Comment, Skip, Group } = require './railroad-diagrams'

rx2rr = (node, options) ->
  switch node.type

      charset = (x.text for x in node.body)

      if charset.length == 1
        char = charset[0]

        if char == " "
          char = "SP"

        if node.invert
          return NonTerminal("not #{charset[0]}")
        else
          return Terminal(charset[0])
      else
        list = charset[0...-1].join(", ")

        for x,i in list
          if x == " "
            list[i] = "SP"

        if node.invert
          return NonTerminal("not #{list} and #{charset[-1..]}")
        else
          return NonTerminal("#{list} or #{charset[-1..]}")

    when "hex", "octal", "unicode"
      Terminal(node.text)
