MCPcopy
hub / github.com/lmorg/murex / parseExpression

Method parseExpression

lang/expressions/parse_expression.go:10–478  ·  view source on GitHub ↗
(exec, incLogicalOps bool)

Source from the content-addressed store, hash-verified

8)
9
10func (tree *ParserT) parseExpression(exec, incLogicalOps bool) error {
11 for ; tree.charPos < len(tree.expression); tree.charPos++ {
12 r := tree.expression[tree.charPos]
13 switch r {
14 case '#':
15 tree.charPos--
16 return nil
17
18 case ' ', '\t', '\r':
19 // whitespace. do nothing
20
21 case '\n':
22 if len(tree.ast) == 0 {
23 // do nothing if just empty lines
24 tree.crLf()
25 continue
26 }
27 tree.charPos--
28 return nil
29
30 case ';':
31 // end expression
32 tree.charPos--
33 return nil
34
35 case '?':
36 switch tree.nextChar() {
37 case '?':
38 // null coalescing
39 tree.appendAst(symbols.NullCoalescing)
40 tree.charPos++
41 case ':':
42 // elvis
43 tree.appendAst(symbols.Elvis)
44 tree.charPos++
45 default:
46 // end expression
47 // (deprecated: :)
48 tree.charPos--
49 return nil
50 }
51
52 case '|':
53 if incLogicalOps && tree.nextChar() == '|' {
54 // logic or
55 tree.appendAst(symbols.LogicalOr)
56 tree.charPos++
57 } else {
58 // end expression
59 tree.charPos--
60 return nil
61 }
62
63 case '&':
64 if tree.nextChar() == '&' {
65 if incLogicalOps {
66 // logic and
67 tree.appendAst(symbols.LogicalAnd)

Callers 7

preParserMethod · 0.95
ExpressionParserFunction · 0.45
testParserSymbolFunction · 0.45
testParserObjectFunction · 0.45
testExpressionFunction · 0.45
parseSubExpressionMethod · 0.45
ExecuteExprFunction · 0.45

Calls 15

crLfMethod · 0.95
nextCharMethod · 0.95
appendAstMethod · 0.95
parseBarewordMethod · 0.95
parseFunctionMethod · 0.95
parseVarTildeMethod · 0.95
createArrayAstMethod · 0.95
createObjectAstMethod · 0.95
createStringAstMethod · 0.95
parseLambdaStatementMethod · 0.95
parseStringMethod · 0.95

Tested by 3

testParserSymbolFunction · 0.36
testParserObjectFunction · 0.36
testExpressionFunction · 0.36