<commit_before>package com.greenlaw110.rythm.internal.parser.build_in;

import com.greenlaw110.rythm.exception.DialectNotSupportException;
import com.greenlaw110.rythm.internal.TemplateParser;
import com.greenlaw110.rythm.internal.dialect.Rythm;
import com.greenlaw110.rythm.internal.dialect.SimpleRythm;
import com.greenlaw110.rythm.internal.parser.CodeToken;
import com.greenlaw110.rythm.internal.parser.ParserBase;
import com.greenlaw110.rythm.spi.IContext;
import com.greenlaw110.rythm.spi.IDialect;
import com.greenlaw110.rythm.spi.IParser;
import com.greenlaw110.rythm.utils.TextBuilder;
import com.stevesoft.pat.Regex;

/**
 * Single line expression parser
 *
 * @author luog
 */
public class ExpressionParser extends CaretParserFactoryBase {

    private static class ExpressionToken extends CodeToken {
        private static void assertSimple(String symbol, IContext context) {
            boolean isSimple = symbol.indexOf(".") == -1 && symbol.indexOf("[") == -1;
            if (!isSimple) throw new TemplateParser.NotSIMTemplate();
        }

        public ExpressionToken(String s, IContext context) {
            super(s, context);
            if (context.getDialect() instanceof SimpleRythm) {
                // simple rythm dialect support only simple expression
                int pos = s.indexOf("("); // find out the method name
                if (pos != -1) {
                    String methodName = s.substring(0, pos);
                    assertSimple(methodName, context);
                } else {
                    assertSimple(s, context);
                    context.getCodeBuilder().addRenderArgs("Object", s);
                }
            }
        }

        @Override
        public void output() {
            boolean isInlineTag = false;<commit_msg>fix #61<commit_after>package com.greenlaw110.rythm.internal.parser.build_in;

import com.greenlaw110.rythm.exception.DialectNotSupportException;
import com.greenlaw110.rythm.internal.TemplateParser;
import com.greenlaw110.rythm.internal.dialect.Rythm;
import com.greenlaw110.rythm.internal.dialect.SimpleRythm;
import com.greenlaw110.rythm.internal.parser.CodeToken;
import com.greenlaw110.rythm.internal.parser.ParserBase;
import com.greenlaw110.rythm.spi.IContext;
import com.greenlaw110.rythm.spi.IDialect;
import com.greenlaw110.rythm.spi.IParser;
import com.greenlaw110.rythm.utils.S;
import com.greenlaw110.rythm.utils.TextBuilder;
import com.stevesoft.pat.Regex;

/**
 * Single line expression parser
 *
 * @author luog
 */
public class ExpressionParser extends CaretParserFactoryBase {

    private static class ExpressionToken extends CodeToken {
        private static void assertSimple(String symbol, IContext context) {
            boolean isSimple = symbol.indexOf(".") == -1 && symbol.indexOf("[") == -1;
            if (!isSimple) throw new TemplateParser.NotSIMTemplate();
        }

        public ExpressionToken(String s, IContext context) {
            super(s, context);
            if (context.getDialect() instanceof SimpleRythm) {
                s = S.stripBrace(s);
                // simple rythm dialect support only simple expression
                int pos = s.indexOf("("); // find out the method name
                if (pos != -1) {
                    String methodName = s.substring(0, pos);
                    assertSimple(methodName, context);
                } else {
                    assertSimple(s, context);
                    context.getCodeBuilder().addRenderArgs("Object", s);
                }
            }
        }

        @Override
        public void output() {
            boolean isInlineTag = false;
{'fraction_non_alphanumeric': 0.10117905127502057, 'fraction_numerical': 0.02166163970386619, 'mean_word_length': 2.5764705882352943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3960293', 'n_tokens_mistral': 1068, 'n_tokens_neox': 990, 'n_words': 216}