File: runparser.h

package info (click to toggle)
qlogo 0.961-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,452 kB
  • sloc: cpp: 11,166; python: 159; sh: 107; ansic: 79; xml: 20; makefile: 4
file content (57 lines) | stat: -rw-r--r-- 1,763 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef RUNPARSER_H
#define RUNPARSER_H

//===-- qlogo/parser.h - Parser class definition -------*- C++ -*-===//
//
// Copyright 2017-2024 Jason Sikes
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the conditions specified in the
// license found in the LICENSE file in the project root.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the declaration of the Runparser class, which is
/// responsible for parsing text and generating a list of tokens.
///
/// for example, `[PRINT 2+2]`, a list of two words, will be parsed into a list of
/// four words, `[PRINT 2 + 2]`. In QLogo a token is a word, list, or array.
//===----------------------------------------------------------------------===//

#include "datum.h"
#include <QHash>

class Procedures;
class Kernel;
class TextStream;

class Runparser
{
    List *runparseRetval;
    QString::iterator runparseCIter;
    QString::iterator runparseCEnd;
    bool isRunparseSourceSpecial;
    void runparseSpecialchars(void);
    void runparseMinus(void);
    DatumPtr runparseNumber(void); // returns a number if successful
    void runparseQuotedWord();
    void runparseString();

    ListIterator listIter;

  public:
    /// @brief Parse a QLogo word or list into a list of tokens.
    /// @param src A QLogo word or list to parse.
    /// @returns A list of tokens.
    DatumPtr doRunparse(DatumPtr src);
};

/// @brief Parse a QLogo word or list into a list of tokens.
/// @param src A QLogo word or list to parse.
/// @returns A list of tokens.
///
/// @note This function is a wrapper around the `Runparser` class.
DatumPtr runparse(DatumPtr src);

#endif // RUNPARSER_H