示例#1
0
 public P1bLexer(SpanReaderWithCharacterAndLineCounter sourceReader,
                 StackOfMultiTypeElements attributeStack, Stack <Int32> stateStack)
     : base(attributeStack, stateStack)
 {
     Source          = sourceReader.Source;
     inputClassifier = new P1cInputClassifier(sourceReader, attributeStack);
     LexerTextPos    = 0;
     Accepted        = true;
 }
示例#2
0
{ //GrammlatorInput<ClassifierResult> {
  // TODO use the Rune struct https://docs.microsoft.com/en-gb/dotnet/api/system.text.rune?view=netcore-3.1
  // and the EnumerateRunes Method
  // https://docs.microsoft.com/en-gb/dotnet/api/system.memoryextensions.enumeraterunes?view=netcore-3.1
  //  foreach (Rune r in s){}
  // or explicit call of iterators https://docs.microsoft.com/de-de/dotnet/csharp/iterators

    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="SourceReader">the reader provides "ReadOnlyMemory<Char> ReadLine()" and "int LineNumber", "int Position" "int EoLLength"</param>
    /// <param name="attributeStack">The <paramref name="attributeStack"/> is used to store the attributes of the recognized character</param>
    public P1cInputClassifier(
        SpanReaderWithCharacterAndLineCounter SourceReader,
        StackOfMultiTypeElements attributeStack)
    {
        this.SourceReader = SourceReader;
        this._a           = attributeStack;
        Accepted          = true;
        InputLine         = ReadOnlyMemory <Char> .Empty;
        CurrentColumn     = InputLine.Length + 1; // Alike end of line had been recognized and accepted
        StartOf1stGrammlatorGeneratedLine = -1;

        // Grammlator parameterization
        GrammarlineMarker       = GlobalSettings.CSharpGrammarLineMarker.Value; // = "//|"
        CSharpCommentlineMarker = GlobalSettings.CSharpCommentlineMarker.Value; // = "//"
        CSharpPragma            = GlobalSettings.CSharpPragmaMarker.Value;      // = "#pragma"

        for (int i = 0; i < ClassifierTable.Length; i++)
        {
            ClassifierTable[i] = GetResultFromChar((char)i);
        }
    }
#pragma warning restore IDE1006 // Benennungsstile

        /// <summary>
        /// Constructor of cGrammlatorInputApplication
        /// </summary>
        /// <param name="attributeStack">grammlator uses the attributeStack a) in grammlator generated code
        /// b) to return the attributes of output symbol (if any) and c) to get the attribute of input symbols
        /// </param>
        /// <param name="stateStack">the code generated by grammlator may need a state stack, which can be shared.
        /// </param>
        protected GrammlatorInputApplication(StackOfMultiTypeElements attributeStack, Stack <Int32> stateStack)
            : base(attributeStack) => _s = stateStack;
#pragma warning restore IDE1006 // Benennungsstile

        /// <summary>
        /// This constructor of GrammlatorApplication declares an attribute stack _a and a state stack _s
        /// </summary>
        /// <param name="initialSizeOfAttributeStack">grammlator uses the attributeStack a) in grammlator generated code
        /// b) to return the attributes of output symbol (if any) and c) to get the attribute of input symbols
        /// </param>
        /// <param name="initialSizeOfStateStack">the code generated by grammlator may need a state stack, which can be shared.
        /// </param>
        protected GrammlatorApplication(Int32 initialSizeOfAttributeStack = 10, Int32 initialSizeOfStateStack = 10)
        {
            _a = new StackOfMultiTypeElements(initialSizeOfAttributeStack);
            _s = new Stack <Int32>(initialSizeOfStateStack);
        }