Symbol.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*************************************************************
  2. *
  3. * Copyright (c) 2017-2022 The MathJax Consortium
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /**
  18. * @fileoverview Symbol classes.
  19. *
  20. * @author v.sorge@mathjax.org (Volker Sorge)
  21. */
  22. import {Args, Attributes, ParseMethod} from './Types.js';
  23. /**
  24. * Symbol class
  25. */
  26. export class Symbol {
  27. /**
  28. * @constructor
  29. * @param {string} symbol The symbol parsed.
  30. * @param {string} char The corresponding translation.
  31. * @param {Attributes} attributes The attributes for the translation.
  32. */
  33. constructor(private _symbol: string, private _char: string,
  34. private _attributes: Attributes) {
  35. }
  36. public get symbol(): string {
  37. return this._symbol;
  38. }
  39. public get char(): string {
  40. return this._char;
  41. }
  42. public get attributes(): Attributes {
  43. return this._attributes;
  44. }
  45. }
  46. export class Macro {
  47. /**
  48. * @constructor
  49. * @param {string} symbol The symbol parsed
  50. * @param {ParseMethod} func The parsing function for that symbol.
  51. * @param {Args[]} args Additional arguments for the function.
  52. */
  53. constructor(private _symbol: string, private _func: ParseMethod,
  54. private _args: Args[] = []) {
  55. }
  56. public get symbol(): string {
  57. return this._symbol;
  58. }
  59. public get func(): ParseMethod {
  60. return this._func;
  61. }
  62. public get args(): Args[] {
  63. return this._args;
  64. }
  65. }