<commit_before>module STL.Data.Parser
    (
    ) where

import Data.Attoparsec.Text 
import Data.Text as T
import STL.Data.Topology
import Control.Applicative
import Data.Char

-- | STL follows a very simple format.
-- solid name 
-- facet normal ni nj nk
--     outer loop
--         vertex v1x v1y v1z
--         vertex v2x v2y v2z
--         vertex v3x v3y v3z
--     endloop
-- end face
-- endsolid

solidKW = string $ T.pack "solid"

endSolidKW = string $ T.pack "endsolid"

spaceP = takeWhile1 isSpace

untillSpace = takeTill isSpace

defaultSpace = createSpace 0.001

defaultSolid = createSolid defaultSpace

solidP = skipSpace *> solidKW

solidNameP = do
  skipSpace
  many' letter
  takeTill isEndOfLine
  endOfLine

solidWithNameP = solidP *> solidNameP *> pure defaultSolid

<commit_msg>WIP: rewrite parser, now since I know how attoparsec consumes input<commit_after>{-# LANGUAGE OverloadedStrings #-}
module STL.Data.Parser
    (
    ) where

import Data.Attoparsec.Text 
import Data.Text as T
import STL.Data.Topology
import Control.Applicative
import Data.Char


defaultSolid = createSolid $ createSpace 0.001

-- | STL follows a very simple format.
-- solid name 
-- facet normal ni nj nk
--     outer loop
--         vertex v1x v1y v1z
--         vertex v2x v2y v2z
--         vertex v3x v3y v3z
--     endloop
-- end face
-- endsolid

beginSolid = string "solid"   *>
             blankOrSolidName *>
             pure defaultSolid
  where
    solidName = skipSpace    *>
                many1 letter *>
                return ()
                
    blankOrSolidName = skipSpace <|> solidName


beginFacet = string "facet" *> skipSpace *>
             string "normal"
{'fraction_non_alphanumeric': 0.08002371072910491, 'fraction_numerical': 0.016597510373443983, 'mean_word_length': 2.3692614770459084, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1974942', 'n_tokens_mistral': 576, 'n_tokens_neox': 551, 'n_words': 166}