示例#1
0
        /// <summary> returns the lexer that's gonna parse any word.
        /// and convert the string to a TokenWord.
        /// A word starts with an alphametic character, followed by 0 or more alphanumeric characters.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexWord()
        {
            string name = "word";

            return(Lex(Scanners.Delimited(Scanners.IsPattern(name, Patterns.IsWord(), name)),
                       Tokenizers.ForWord).Rename(name));
        }
示例#2
0
        /// <summary> returns the lexer that's gonna parse a hex integer number (valid patterns are: 0x1, 0Xff, 0xFe1 jfun.yan.etc.),
        /// and convert the string to a Long token.
        /// an hex number has to start with either 0x or 0X.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexHexLong()
        {
            string name = "hex integer literal";

            return(Lex(Scanners.Delimited(Scanners.IsPattern(name, Patterns.IsHexInteger(), "hexInteger")),
                       Tokenizers.ForHexLong).Rename(name));
        }
示例#3
0
        /// <summary> returns the lexer that's gonna parse a octal integer number (valid patterns are: 0, 07, 017, 0371 jfun.yan.etc.),
        /// and convert the string to a Long token.
        /// an octal number has to start with 0.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexOctLong()
        {
            string name = "oct integer literal";

            return(Lex(Scanners.Delimited(Scanners.IsPattern(name, Patterns.IsOctInteger(), "octInteger")),
                       Tokenizers.ForOctLong).Rename(name));
        }
示例#4
0
        /// <summary> returns the lexer that's gonna parse a decimal integer number (valid patterns are: 1, 10, 123),
        /// and convert the string to a Long token.
        /// The difference between integer() and decInteger() is that decInteger does not allow a number starting with 0.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexDecimalLong()
        {
            string name = "decimal integer literal";

            return(Lex(Scanners.Delimited(Scanners.IsPattern(name, Patterns.IsDecInteger(), "decInteger")),
                       Tokenizers.ForLong));
        }
示例#5
0
        /// <summary> returns the lexer that's gonna parse a integer number (valid patterns are: 0, 00, 1, 10),
        /// and convert the string to a Long token.
        /// The difference between integer() and decInteger() is that decInteger does not allow a number starting with 0.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexInteger()
        {
            string name = "integer literal";

            return(Lex(Scanners.Delimited(Scanners.IsPattern("integer literal", Patterns.IsInteger(), "integer")),
                       Tokenizers.ForInteger).Rename(name));
        }
示例#6
0
        /// <summary> returns the lexer that's gonna parse a decimal number (valid patterns are: 1, 2.3, 000, 0., .23),
        /// and convert the string to a TokenDecimal.
        /// </summary>
        /// <returns> the lexer.
        /// </returns>
        public static Lexer LexDecimal()
        {
            string name = "decimal literal";

            return(Lex(Scanners.Delimited(
                           Scanners.IsPattern(name, Patterns.IsDecimal(), "decimal number")),
                       Tokenizers.ForDecimal).Rename(name));
        }