env-file-reader 0.3.0

functions for reading environment variables from a file
Documentation
use std::collections::HashMap;
use std::iter::FromIterator;

use crate::lexer::{ParseError, Token};

grammar;

extern {
  type Location = usize;
  type Error = ParseError;

  enum Token {
    "=" => Token::Eq,
    "export" => Token::Export,
    "ident" => Token::Ident(<String>),
    "qs" => Token::QuotedString(<String>),
    "\n" => Token::NewLine,
    "eof" => Token::Eof,
  }
}

pub EnvFile: HashMap<String, String> = {
  <Line*> => HashMap::from_iter(<>.into_iter().flatten()),
}

Line: Option<(String, String)> = {
  <k:Key> "=" <v:Value> => Some((k, v)),
  "\n" => None,
  "eof" => None,
};

Key: String = "export"? <k:"ident"> => k;

Value: String = {
  "ident" => <>,
  "qs" => <>,
  "\n" => String::new(),
  "eof" => String::new(),
};