lib/hilbert/parser.rb in hilbert-0.0.2700001 vs lib/hilbert/parser.rb in hilbert-0.0.2700100
- old
+ new
@@ -6,35 +6,56 @@
require 'hilbert/parser/list_parser'
require 'hilbert/parser/func_parser'
require 'hilbert/parser/integral_parser'
require 'hilbert/parser/limit_parser'
require 'hilbert/parser/sigma_parser'
+require 'hilbert/parser/world_parser'
require 'hilbert/parser/formula_parser'
+require 'hilbert/lexer/world_lexer'
module Hilbert
module Parser
include Lexer::Tokens
SYM = '\w+'
+
ONEHASH = "#{ANYSP}#{SYM}#{CLN}#{ANYSP}#{VARNUM}#{ANYSP}" # sdf: 234
def execute(lexed)
time = Time.now
until lexed.token_str =~ /\A:(NLIN|R)\d+\z/
fail "I'm so sorry, something wrong. Please feel free to report this." if Time.now > time + 10
case lexed.token_str
- when /:(vector)(\d+)/, /:(matrix)(\d+)/, /:(tmatrix)(\d+)/, /:(integral)(\d+)/, /:(def_func)(\d+)/, /:(differential)(\d+)/, /:(limit)(\d+)/, /:(sigma)(\d+)/
+ when /:(POST_ZFC)(\d+)/
+ Hilbert::Lexer::MainLexer.zfc_analysis!
+ lexed.parsed!('', $2)
+ when /:(DEFLOGIC)(\d+)/
+ value = lexed.get_value($1)
+ lexeds = Lexer::WorldLexer.execute(value)
+ Parser::WorldParser.execute(lexeds)
+ $world << eval(Parser::WorldParser.parsed_srt)
+ rslt = %|"Defined: #{value} is TRUE"|
+ lexed.parsed!(rslt, $2)
+
+ when /:(EVALOGIC)(\d+)/
+ value = lexed.get_value($1).delete('?')
+ lexeds = Lexer::WorldLexer.execute(value)
+ Parser::WorldParser.execute(lexeds)
+ rslt = $world.impl eval(Parser::WorldParser.parsed_srt), value
+ lexed.parsed!(rslt, $2)
+
+ when /:(VECTOR)(\d+)/, /:(MATRIX)(\d+)/, /:(TMATRIX)(\d+)/, /:(INTEGRAL)(\d+)/, /:(DEF_FUNC)(\d+)/, /:(DIFFERENTIAL)(\d+)/, /:(LIMIT)(\d+)/, /:(SIGMA)(\d+)/
token_els = lexed.get_els($2)
parsed = case $1
- when 'vector' then VectorParser.execute(token_els)
- when 'matrix' then MatrixParser.execute(token_els)
- when 'tmatrix' then MatrixParser.execute(token_els, trans: true)
- when 'limit' then LimitParser.execute(token_els)
- when 'integral' then IntegralParser.execute(token_els)
- when 'def_func' then FuncParser.execute(token_els)
- when 'sigma' then SigmaParser.execute(token_els)
- when 'differential'
+ when 'VECTOR' then VectorParser.execute(token_els)
+ when 'MATRIX' then MatrixParser.execute(token_els)
+ when 'TMATRIX' then MatrixParser.execute(token_els, trans: true)
+ when 'LIMIT' then LimitParser.execute(token_els)
+ when 'INTEGRAL' then IntegralParser.execute(token_els)
+ when 'DEF_FUNC' then FuncParser.execute(token_els)
+ when 'SIGMA' then SigmaParser.execute(token_els)
+ when 'DIFFERENTIAL'
del_var, formula = token_els
"d/d#{del_var}(#{FormulaParser.execute(formula)})"
end
lexed.parsed!(parsed, $2)