We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
The parser couldn't parse this rest.
[bool, checkEquals, ifElse, int, list, recursive, text] = use "Core" [parser] = use "Parser" decode csv := needs (text.is csv) recursive [Lines: (,), Fields: (,), FieldStartOffset: 0, P: parser.new csv] { recurse [lines, fields, fieldStartOffset, p] -> Parser (Cursor [source, Offset: oldOffset]) = p p | parser.next % Ok [Parser: p, character] -> Parser c = p Cursor [Offset: newOffset] = c character % "," -> recurse [ lines, Fields: fields | list.append (source | text.getRange fieldStartOffset oldOffset), FieldStartOffset: newOffset, p, ] " " -> fields = fields | list.append (source | text.getRange fieldStartOffset oldOffset) lines = lines | list.append fields ifElse (c | cursor.) recurse [ Lines: lines | list.append fields, Fields: (,), FieldStartOffset: newOffset, p, ] # TODO(JonasWanke): handle quoted field _ -> recurse [lines, fields, fieldStartOffset, p] Error Empty -> finalField = source | text.getRange fieldStartOffset oldOffset Ok ifElse finalField | text.isEmpty | bool.lazyAnd { fields | list.isEmpty } { lines } { lines | list.append (fields | list.append finalField) } } test = checkEquals (decode "") (Ok (,)) checkEquals (decode "{text.newline}") (Ok (,)) checkEquals (decode "aaa") (Ok (("aaa",),)) checkEquals (decode "aaa{text.newline}") (Ok (("aaa",),)) testRfcExamples = # From https://datatracker.ietf.org/doc/html/rfc4180#section-2 checkEquals (decode "aaa,bbb,ccc") (Ok (("aaa", "bbb", "ccc"),)) checkEquals decode "aaa,bbb,ccc{text.newline}zzz,yyy,xxx{text.newline}" Ok (("aaa", "bbb", "ccc"), ("zzz", "yyy", "xxx")) checkEquals decode " field_name,field_name,field_name{text.newline}aaa,bbb,ccc{text.newline}zzz,yyy,xxx{text.newline} " Ok (("field_name", "field_name", "field_name"), ("aaa", "bbb", "ccc"), ("zzz", "yyy", "xxx")) # TODO(JonasWanke): handle quoted field # checkEquals # decode '"aaa,"b{{text.newline}}bb",ccc{{text.newline}}zzz,yyy,xxx{{text.newline}}"' # Ok (("aaa", "b{text.newline}bb", "ccc"), ("zzz", "yyy", "xxx")) # checkEquals (decode '"aaa,"b""bb",ccc{{text.newline}}"') (Ok (("aaa", '"b"bb"', "ccc"),))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
The text was updated successfully, but these errors were encountered: