lib/hilbert/lexer/main_lexer.rb in hilbert-0.0.2700001 vs lib/hilbert/lexer/main_lexer.rb in hilbert-0.0.2700100

- old
+ new

@@ -1,34 +1,44 @@ -#!/bin/env ruby -# encoding: utf-8 - module Hilbert module Lexer class MainLexer < Base - rule(/(#{FUNCCV})#{ANYSP}#{EQL}#{ANYSP}(#{FORMULA})/) { :def_func } - rule(/#{ITGRLSYM}#{ANYSP}#{LPRN}(#{ANYSTR})#{RPRN}#{LBRCT}(#{ANYSTR})#{RBRCT}/) { :integral } - rule(/d\/d(#{VAR}) (#{FORMULA})/) { :differential } + # TODO: So far so good, but... + rule(/postulate zfc_analysis/) { :POST_ZFC } + rule(/#{EVALOGIC}/) { :EVALOGIC } + rule(/#{DEFLOGIC}/) { :DEFLOGIC } + rule(/[ \t\f]/) - rule(/lim#{LBRCT}(#{VAR})#{RSARW}(#{VARNUM})#{RBRCT} (#{FORMULA})/) { :limit } + rule(/(\r|\n)+/) { :NULL } - rule(/#{LPRN}(#{NUMS_BY_SP})#{RPRN}/) { :vector } - rule(/#{LPRN}(#{NUMS_BY_SP_BY_SCLN_OR_NELN})#{RPRN}t/m) { :tmatrix } - rule(/#{LPRN}(#{NUMS_BY_SP_BY_SCLN_OR_NELN})#{RPRN}/m) { :matrix } + rule(/[^\(\)\{\}(\n\n)]+/) { :CONT } + class << self + include Tokens + def zfc_analysis! + clear! + rule(/postulate zfc_analysis/) { :POST_ZFC } + rule(/#{EVALOGIC}/) { :EVALOGIC } + rule(/#{DEFLOGIC}/) { :DEFLOGIC } + rule(/(#{FUNCCV})#{ANYSP}#{EQL}#{ANYSP}(#{FORMULA})/) { :DEF_FUNC } + rule(/#{INTE_SYM}#{ANYSP}#{LPRN}(#{ANYSTR})#{RPRN}#{LBRCT}(#{ANYSTR})#{RBRCT}/) { :INTEGRAL } + rule(/#{DIFF_SYM}(#{VAR}) (#{FORMULA})/) { :DIFFERENTIAL } + rule(/#{LIM_SYM}#{LBRCT}(#{VAR})#{RSARW}(#{VARNUM})#{RBRCT} (#{FORMULA})/) { :LIMIT } + rule(/#{SGM_SYM}#{LBRCT}(#{VAR})#{EQL}(#{INT})#{CMA}#{ANYSP}(#{INT})#{RBRCT} (#{FORMULA})/) { :SIGMA } - rule(/∑#{LBRCT}(#{VAR})=(#{INT}),#{ANYSP}(#{INT})#{RBRCT} (#{FORMULA})/) { :sigma } - rule(/sigma#{LBRCT}(#{VAR})=(#{INT}),#{ANYSP}(#{INT})#{RBRCT} (#{FORMULA})/) { :sigma } + rule(/#{LPRN}(#{NUMS_BY_SP})#{RPRN}/) { :VECTOR } + rule(/#{LPRN}(#{NUMS_BY_SP_BY_SCLN_OR_NELN})#{RPRN}t/m) { :TMATRIX } + rule(/#{LPRN}(#{NUMS_BY_SP_BY_SCLN_OR_NELN})#{RPRN}/m) { :MATRIX } - rule(/#{FUNCCN}/) { :FUNCCN } + rule(/#{FUNCCN}/) { :FUNCCN } + rule(/#{LPRN}/) { :LPRN } + rule(/#{RPRN}/) { :RPRN } + rule(/#{LBRCS}/) { :LBRCS } + rule(/#{RBRCS}/) { :RBRCS } + rule(/[ \t\f]/) - rule(/#{LPRN}/) { :LPRN } - rule(/#{RPRN}/) { :RPRN } - rule(/#{LBRCS}/) { :LBRCS } - rule(/#{RBRCS}/) { :RBRCS } + rule(/(\r|\n)+/) { :NULL } - rule(/[ \t\f]/) - - rule(/(\r|\n)+/) { :NULL } - - rule(/[^\(\)\{\}(\n\n)]+/) { :CONT } + rule(/[^\(\)\{\}(\n\n)]+/) { :CONT } + end + end end end end