Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
/ sexp-parse Public archive

S-expression parsing library (without base dependency)

License

Notifications You must be signed in to change notification settings

gpetiot/sexp-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

sexp-parse

S-expression parsing library without the base dependency.

Untyped s-expressions

Untyped s-expressions rely on the type definitions in the sexplib0 library.

Untyped.of_string
  {|((data "quoted data" 123 4.5)
     (data (!@# (4.5) "(more" "data)")))|}

will generate:

Ok
  Typed.[
    List [
      List [
        Atom "data";
        Atom {|"quoted data"|};
        Atom "123";
        Atom "4.5";
      ];
      List [
        Atom "data";
        List [
          Atom "!@#";
          List [ Atom "4.5" ];
          Atom {|"(more"|};
          Atom {|"data)"|};
        ]
      ]
    ]
  ]

Typed s-expressions

In typed s-expressions the atoms can be either of type string, int, float or symbol (unquoted string).

Typed.of_string
  {|((data "quoted data" 123 4.5)
     (data (!@# (4.5) "(more" "data)")))|}

will generate:

Ok
  Typed.[
    List [
      List [
        Atom (Symbol "data");
        Atom (String {|quoted data|});
        Atom (Int 123);
        Atom (Float 4.5);
      ];
      List [
        Atom (Symbol "data");
        List [
          Atom (Symbol "!@#");
          List [ Atom (Float 4.5) ];
          Atom (String "(more");
          Atom (String "data)");
        ]
      ]
    ]
  ]

About

S-expression parsing library (without base dependency)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages