Commit cd9164c6 authored by Cool Fire's avatar Cool Fire
Browse files

Initial testing for lexer

parent f1b4f38f
#!/usr/bin/env ruby
# Encoding: utf-8
# frozen_string_literal: true
# Main PHP lexer class
class Lexer
require_relative 'LexerConstants.rb'
attr_accessor :input
def start
lex method :lex_text
end
def lex(state)
until state.nil?
state = state.call
end
end
def lex_text
puts 'lex_text'
method :lex_number
end
def lex_number
puts 'lex_number'
nil
end
end
l = Lexer.new
l.input = '<?php print("test\n"); ?>'
l.start
puts l.input
#!/usr/bin/env ruby
# Encoding: utf-8
# frozen_string_literal: true
# Helper file to hold constants for lexer tokens
DUMMY = 0
ERROR = 1
PHP_OPEN = 2
PHP_CLOSE = 3
VARIABLE = 4
CONSTANT = 5
BLOCK_OPEN = 6
BLOCK_CLOSE = 7
PARENT_OPEN = 8
PARENT_CLOSE = 9
CURLY_OPEN = 10
CURLY_CLOSE = 11
STRING_SINGLE = 12
STRING_DOUBLE = 13
STRING_BACKTICK = 14
NUMBER = 15
OPERATOR = 16
COMMA = 17
COMMENT_SINGLE = 18
COMMENT_MULTI = 19
TEXT = 20
EOF = 21
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment