Skip to content

Commit

Permalink
Make reserved keywords file into a raw txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypher1 committed Apr 14, 2024
1 parent 848b8c1 commit fe4b529
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
4 changes: 2 additions & 2 deletions takolib/src/ast/string_interner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::location::IndexIntoFile;
use crate::parser::keywords::KEYWORDS;
use crate::parser::KEYWORDS;
use crate::primitives::typed_index::TypedIndex;
use num_traits::Bounded;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -42,7 +42,7 @@ impl Default for StringInterner {
n.pi = n.register_str("pi");
n.forall = n.register_str("forall");
n.exists = n.register_str("exists");
for key in KEYWORDS {
for key in KEYWORDS.iter() {
n.register_str(key);
}
n
Expand Down
27 changes: 0 additions & 27 deletions takolib/src/parser/keywords.rs

This file was deleted.

24 changes: 24 additions & 0 deletions takolib/src/parser/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
False
TRUE
True
any
construct
exists
false
forall
given
implies
in
lambda
module
pi
preserve
read
require
sigma
such
suchthat
that
true
where
write
8 changes: 7 additions & 1 deletion takolib/src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod keywords;
pub mod semantics;
pub mod tokens;
// use rand::Rng;
Expand All @@ -14,6 +13,13 @@ use std::path::Path;
use thiserror::Error;
use tokens::{assign_op, binding_mode_operation, is_assign, OpBinding, Symbol, Token, TokenType};

use lazy_static::lazy_static;

lazy_static! {
pub static ref KEYWORDS: Vec<String> = include_str!("keywords.txt").split("\n").map(|s| s.to_string()).collect();

}

#[derive(Debug, Error, PartialEq, Eq, Ord, PartialOrd, Clone, Hash)]
pub enum ParseError {
UnexpectedEof, // TODO: Add context.
Expand Down

0 comments on commit fe4b529

Please sign in to comment.