Module: AsciiMath

Defined in:
lib/asciimath/parser.rb,
lib/asciimath/ast.rb,
lib/asciimath/cli.rb,
lib/asciimath/html.rb,
lib/asciimath/latex.rb,
lib/asciimath/markup.rb,
lib/asciimath/mathml.rb,
lib/asciimath/version.rb,
lib/asciimath/color_table.rb,
lib/asciimath/symbol_table.rb

Overview

Parser for ASCIIMath expressions.

The syntax for ASCIIMath in EBNF style notation is

expr = ( simp ( fraction | sub | super ) )+ simp = constant | paren_expr | unary_expr | binary_expr | text fraction = ‘/’ simp super = ‘^’ simp sub = ‘_’ simp super? paren_expr = lparen expr rparen lparen = ‘(’ | ‘[’ | ‘| ‘(:’ | ‘{:’ rparen = ‘)’ | ‘]’ | ‘’ | ‘:)’ | ‘:}’ unary_expr = unary_op simp unary_op = ‘sqrt’ | ‘text’ binary_expr = binary_op simp simp binary_op = ‘frac’ | ‘root’ | ‘stackrel’ text = ‘“’ [^”]* ‘“’ constant = number | symbol | identifier number = ‘-’? [0-9]+ ( ‘.’ [0-9]+ )? symbol = /* any string in the symbol table */ identifier = [A-z]

ASCIIMath is parsed left to right without any form of operator precedence. When parsing the ‘constant’ the parser will try to find the longest matching string in the symbol table starting at the current position of the parser. If no matching string can be found the character at the current position of the parser is interpreted as an identifier instead.

Defined Under Namespace

Modules: AST, CLI Classes: ColorTableBuilder, Expression, HTMLBuilder, LatexBuilder, MarkupBuilder, MathMLBuilder, Parser, SymbolTableBuilder, Tokenizer

Constant Summary collapse

VERSION =
"2.0.2"

Class Method Summary collapse

Class Method Details

.parse(asciimath, parser_symbol_table = ::AsciiMath::Parser::DEFAULT_PARSER_SYMBOL_TABLE, parser_color_table = ::AsciiMath::Parser::DEFAULT_COLOR_TABLE) ⇒ Object



774
775
776
# File 'lib/asciimath/parser.rb', line 774

def self.parse(asciimath, parser_symbol_table = ::AsciiMath::Parser::DEFAULT_PARSER_SYMBOL_TABLE, parser_color_table = ::AsciiMath::Parser::DEFAULT_COLOR_TABLE)
  Parser.new(parser_symbol_table, parser_color_table).parse(asciimath)
end