<commit_before>/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

foam.CLASS({
  package: 'foam.swift.parse',
  name: 'StringPStream',
  implements: [
    'foam.swift.parse.PStream',
  ],
  properties: [
    {
      swiftType: 'Reference<String>',
      name: 'str',
      swiftAdapt: function() {/*
if let s = newValue as? String {
  return Reference(value: s)
}
return newValue as! Reference<String>
      */},
    },
    {
      name: 'value_',
    },
    {
      class: 'Int',
      name: 'pos',
    },
    {
      swiftType: 'StringPStream?',
      name: 'tail_',
    },
  ],
  methods: [
    {
      name: 'head',
      swiftCode: function() {/*
return str.value.char(at: pos)
      */},
    },
    {
      name: 'valid',
      swiftCode: function() {/*
return pos < str.value.characters.count
      */},
    },
    {
      name: 'tail',
      swiftCode: function() {/*
if tail_ == nil {
  tail_ = StringPStream([
    "str": str,
    "pos": pos + 1,
  ])
}
return tail_!
      */},
    },
    {
      name: 'substring',
      swiftCode: function() {/*
let startIndex = str.value.index(str.value.startIndex, offsetBy: pos)
let endIndex = str.value.index(str.value.startIndex, offsetBy: (end as! StringPStream).pos)
return String(str.value[startIndex..<endIndex])
      */},
    },
    {
      name: 'value',
      swiftReturns: 'Any?',
      swiftCode: function() {/*
return value_
      */},
    },
    {
      name: 'setValue',
      swiftCode: function() {/*
let ps = StringPStream([
  "str": str,
  "pos": pos,
  "value_": value,
])
return ps
      */},
    },
  ]
});
<commit_msg>Change StringPStream to use an array of characters rather than a string.<commit_after>/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

foam.CLASS({
  package: 'foam.swift.parse',
  name: 'StringPStream',
  implements: [
    'foam.swift.parse.PStream',
  ],
  properties: [
    {
      swiftType: '[Character]',
      name: 'str',
      swiftAdapt: function() {/*
if let s = newValue as? String {
  return Array(s)
}
return newValue as! [Character]
      */},
    },
    {
      name: 'value_',
    },
    {
      class: 'Int',
      name: 'pos',
    },
    {
      swiftType: 'StringPStream?',
      name: 'tail_',
    },
  ],
  methods: [
    {
      name: 'head',
      swiftCode: function() {/*
return str[pos]
      */},
    },
    {
      name: 'valid',
      swiftCode: function() {/*
return pos < str.count
      */},
    },
    {
      name: 'tail',
      swiftCode: function() {/*
if tail_ == nil {
  tail_ = StringPStream([
    "str": str,
    "pos": pos + 1,
  ])
}
return tail_!
      */},
    },
    {
      name: 'substring',
      swiftCode: function() {/*
let startIndex = pos
let endIndex = (end as! StringPStream).pos
return String(str[startIndex..<endIndex])
      */},
    },
    {
      name: 'value',
      swiftReturns: 'Any?',
      swiftCode: function() {/*
return value_
      */},
    },
    {
      name: 'setValue',
      swiftCode: function() {/*
let ps = StringPStream([
  "str": str,
  "pos": pos,
  "value_": value,
])
return ps
      */},
    },
  ]
});

{'fraction_non_alphanumeric': 0.14912694667295895, 'fraction_numerical': 0.004247286455875413, 'mean_word_length': 2.3966346153846154, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4108381', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1351, 'n_words': 397}