lib/qlang/parser.rb in qlang-0.0.27182110 vs lib/qlang/parser.rb in qlang-0.0.27182120
- old
+ new
@@ -4,10 +4,13 @@
require 'qlang/parser/matrix_parser'
require 'qlang/parser/vector_parser'
require 'qlang/parser/list_parser'
require 'qlang/parser/func_parser'
require 'qlang/parser/integral_parser'
+require 'qlang/parser/limit_parser'
+require 'qlang/parser/sigma_parser'
+
require 'qlang/parser/formula_parser'
module Qlang
module Parser
include Lexer::Tokens
@@ -17,38 +20,45 @@
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+)/
- token_els = lexed[$2][:els]
+ 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'
VectorParser.execute(token_els)
when 'matrix'
MatrixParser.execute(token_els)
when 'tmatrix'
MatrixParser.execute(token_els, trans: true)
+ when 'limit'
+ LimitParser.execute(token_els)
when 'integral'
IntegralParser.execute(token_els)
when 'def_func'
FuncParser.execute(token_els)
+ when 'sigma'
+ SigmaParser.execute(token_els)
when 'differential'
del_var, formula = token_els
"d/d#{del_var}(#{FormulaParser.execute(formula)})"
end
lexed.parsed!(parsed, $2)
when /:LPRN(\d+):CONT(\d+):RPRN(\d+)/
tokens_range = $1.to_i..$3.to_i
- token_val = lexed[$2][:CONT]
+ token_val =
- lexed.parsed!(token_val.parentheses, tokens_range)
+ lexed.parsed!(
+ lexed.get_value($2).parentheses,
+ tokens_range
+ )
when /:LBRCS(\d+):CONT(\d+):RBRCS(\d+)/
tokens_range = $1.to_i..$3.to_i
- token_val = lexed[$2][:CONT]
+ token_val = lexed.get_value($2)
cont = case token_val
when /#{ONEHASH}(#{CMA}#{ONEHASH})*/
ListParser.execute(token_val)
else