Module: AsciiMath::AST
- Included in:
- Parser
- Defined in:
- lib/asciimath/ast.rb
Defined Under Namespace
Classes: BinaryOp, Color, Empty, Group, Identifier, InfixOp, InnerNode, Matrix, MatrixRow, Node, Number, Paren, Sequence, SubSup, Symbol, Text, UnaryOp, ValueNode
Instance Method Summary
collapse
-
#binary(operator, e1, e2) ⇒ Object
-
#color(r, g, b, text) ⇒ Object
-
#expression(*e) ⇒ Object
-
#group(lparen, e, rparen) ⇒ Object
-
#identifier(value) ⇒ Object
-
#infix(e1, operator, e2) ⇒ Object
-
#matrix(lparen, rows, rparen) ⇒ Object
-
#number(value) ⇒ Object
-
#paren(lparen, e, rparen) ⇒ Object
-
#sub(e, sub) ⇒ Object
-
#subsup(e, sub, sup) ⇒ Object
-
#sup(e, sup) ⇒ Object
-
#symbol(symbol, text) ⇒ Object
-
#text(value) ⇒ Object
-
#unary(operator, e) ⇒ Object
Instance Method Details
#binary(operator, e1, e2) ⇒ Object
38
39
40
|
# File 'lib/asciimath/ast.rb', line 38
def binary(operator, e1, e2)
BinaryOp.new(operator, e1, e2)
end
|
#color(r, g, b, text) ⇒ Object
66
67
68
|
# File 'lib/asciimath/ast.rb', line 66
def color(r, g, b, text)
Color.new(r, g, b, text)
end
|
#expression(*e) ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/asciimath/ast.rb', line 3
def expression(*e)
case e.length
when 0
nil
when 1
e[0]
else
Sequence.new(e)
end
end
|
#group(lparen, e, rparen) ⇒ Object
18
19
20
|
# File 'lib/asciimath/ast.rb', line 18
def group(lparen, e, rparen)
Group.new(lparen, e, rparen)
end
|
#identifier(value) ⇒ Object
58
59
60
|
# File 'lib/asciimath/ast.rb', line 58
def identifier(value)
Identifier.new(value)
end
|
#infix(e1, operator, e2) ⇒ Object
42
43
44
|
# File 'lib/asciimath/ast.rb', line 42
def infix(e1, operator, e2)
InfixOp.new(operator, e1, e2)
end
|
#matrix(lparen, rows, rparen) ⇒ Object
62
63
64
|
# File 'lib/asciimath/ast.rb', line 62
def matrix(lparen, rows, rparen)
Matrix.new(lparen, rows, rparen)
end
|
#number(value) ⇒ Object
50
51
52
|
# File 'lib/asciimath/ast.rb', line 50
def number(value)
Number.new(value)
end
|
#paren(lparen, e, rparen) ⇒ Object
14
15
16
|
# File 'lib/asciimath/ast.rb', line 14
def paren(lparen, e, rparen)
Paren.new(lparen, e, rparen)
end
|
#sub(e, sub) ⇒ Object
26
27
28
|
# File 'lib/asciimath/ast.rb', line 26
def sub(e, sub)
SubSup.new(e, sub, nil)
end
|
#subsup(e, sub, sup) ⇒ Object
22
23
24
|
# File 'lib/asciimath/ast.rb', line 22
def subsup(e, sub, sup)
SubSup.new(e, sub, sup)
end
|
#sup(e, sup) ⇒ Object
30
31
32
|
# File 'lib/asciimath/ast.rb', line 30
def sup(e, sup)
SubSup.new(e, nil, sup)
end
|
#symbol(symbol, text) ⇒ Object
54
55
56
|
# File 'lib/asciimath/ast.rb', line 54
def symbol(symbol, text)
Symbol.new(symbol, text)
end
|
#text(value) ⇒ Object
46
47
48
|
# File 'lib/asciimath/ast.rb', line 46
def text(value)
Text.new(value)
end
|
#unary(operator, e) ⇒ Object
34
35
36
|
# File 'lib/asciimath/ast.rb', line 34
def unary(operator, e)
UnaryOp.new(operator, e)
end
|