<commit_before>﻿using Irony.Parsing;
using Spready.Nodes;

namespace Spready.Grammar
{
    [Language("Spready", "0.1", "A grammar for a spreadsheet language.")]
    internal class SpreadyGrammar : Irony.Parsing.Grammar
    {
        public SpreadyGrammar()
            : base(caseSensitive: false)
        {
            LanguageFlags = LanguageFlags.CreateAst |
                            LanguageFlags.NewLineBeforeEOF;

            // Terminals
            var worksheetName = new RegexBasedTerminal("worksheet name", @"\b[A-Za-z0-9]\w*\b");
            worksheetName.AstConfig.NodeType = typeof (WorksheetNameNode);
            var cellValueNumber = new NumberLiteral("cell number", NumberOptions.None, typeof(CellNumberNode));
            var cellValueString = new StringLiteral("cell string", "\"", StringOptions.NoEscapes, typeof(CellStringNode));
            var cellName = new RegexBasedTerminal("cell name", @"((\$?[A-Za-z]{1,3})(\$?[0-9]{1,6}))"); // @"[A-Za-z]\w*[0-9]\w*", 
            cellName.AstConfig.NodeType = typeof (CellNameNode);

            // Non-termninals
            var lineComment = new CommentTerminal("line comment", "--", "\n", "\r\n");
            var blockComment = new CommentTerminal("block comment", "/*", "*/");
            NonGrammarTerminals.Add(lineComment);
            NonGrammarTerminals.Add(blockComment);
            var worksheet = new NonTerminal("worksheet", typeof(WorksheetNode));
            var worksheetList = new NonTerminal("worksheet list", typeof(SpreadyNode));
            var expression = new NonTerminal("expression", typeof(ExpressionNode));
            var simpleStatement = new NonTerminal("simple statement", typeof(SimpleStatementNode));
            var equalsStatement = new NonTerminal("equals statement", typeof(EqualsStatementNode));
            var expressionList = new NonTerminal("expression list", typeof(ExpressionNodeList));
            var cellReference = new NonTerminal("cell reference", typeof(CellReferenceNode));
            var cellValue = new NonTerminal("cell value", typeof(CellValueNode));
            var localSheetCellReference = new NonTerminal("internal sheet cell reference", typeof(LocalSheetCellReferenceNode));<commit_msg>Fixes the single line comment format.<commit_after>﻿using Irony.Parsing;
using Spready.Nodes;

namespace Spready.Grammar
{
    [Language("Spready", "0.1", "A grammar for a spreadsheet language.")]
    internal class SpreadyGrammar : Irony.Parsing.Grammar
    {
        public SpreadyGrammar()
            : base(caseSensitive: false)
        {
            LanguageFlags = LanguageFlags.CreateAst |
                            LanguageFlags.NewLineBeforeEOF;

            // Terminals
            var worksheetName = new RegexBasedTerminal("worksheet name", @"\b[A-Za-z0-9]\w*\b");
            worksheetName.AstConfig.NodeType = typeof (WorksheetNameNode);
            var cellValueNumber = new NumberLiteral("cell number", NumberOptions.None, typeof(CellNumberNode));
            var cellValueString = new StringLiteral("cell string", "\"", StringOptions.NoEscapes, typeof(CellStringNode));
            var cellName = new RegexBasedTerminal("cell name", @"((\$?[A-Za-z]{1,3})(\$?[0-9]{1,6}))"); // @"[A-Za-z]\w*[0-9]\w*", 
            cellName.AstConfig.NodeType = typeof (CellNameNode);

            // Non-termninals
            var lineComment = new CommentTerminal("line comment", "//", "\n", "\r\n");
            var blockComment = new CommentTerminal("block comment", "/*", "*/");
            NonGrammarTerminals.Add(lineComment);
            NonGrammarTerminals.Add(blockComment);
            var worksheet = new NonTerminal("worksheet", typeof(WorksheetNode));
            var worksheetList = new NonTerminal("worksheet list", typeof(SpreadyNode));
            var expression = new NonTerminal("expression", typeof(ExpressionNode));
            var simpleStatement = new NonTerminal("simple statement", typeof(SimpleStatementNode));
            var equalsStatement = new NonTerminal("equals statement", typeof(EqualsStatementNode));
            var expressionList = new NonTerminal("expression list", typeof(ExpressionNodeList));
            var cellReference = new NonTerminal("cell reference", typeof(CellReferenceNode));
            var cellValue = new NonTerminal("cell value", typeof(CellValueNode));
            var localSheetCellReference = new NonTerminal("internal sheet cell reference", typeof(LocalSheetCellReferenceNode));
{'fraction_non_alphanumeric': 0.1257847533632287, 'fraction_numerical': 0.0053811659192825115, 'mean_word_length': 3.0889092575618697, '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': '7475018', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1173, 'n_words': 260}