Sha256: e2f85551560212d66c180c53fbcde303c4f5dd53e724d6024ecec7e28dfb3ab1
Contents?: true
Size: 717 Bytes
Versions: 2
Compression:
Stored size: 717 Bytes
Contents
# frozen_string_literal: true module Namarara class Lexer < Rly::Lex attr_reader :logger ignore "\t\n " # token :SPACE, /\s+/ token :L_PAR, /\(/ token :R_PAR, /\)/ token :NUMBER, /[0-9]+(\.[0-9]+)?/ token :STRING, /"([^"]*)"/ do |s| s.value.gsub!(/"(.*)"/, '\1') s end token :EQ_OP, /\=/ token :T_BOOL, /true/i token :F_BOOL, /false/i token :VAR, /[a-z][a-zA-Z0-9_]+/ token :AND_OP, /AND/ token :OR_OP, /OR/ token :NOT_OP, /NOT/ def initialize(logger = nil) @logger = logger super() end on_error do |t| t.lexer.logger&.error "Illegal character #{t.value}" t.lexer.pos += 1 nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
namarara-0.9.5 | lib/namarara/lexer.rb |
namarara-0.9.4 | lib/namarara/lexer.rb |