Skip to content

Commit

Permalink
Add current WIP code for a rebuild of the compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
acweathersby committed Jul 18, 2024
1 parent 8343410 commit faccbd5
Show file tree
Hide file tree
Showing 34 changed files with 5,991 additions and 779 deletions.
35 changes: 25 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "GDB64",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/target/debug/test_basic_grammar_llvm_bin",
"cwd": "${workspaceFolder}",
},
]
"version": "0.2.0",
"configurations": [
{
"name": "GDB64",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/target/debug/test_basic_grammar_llvm_bin",
"cwd": "${workspaceFolder}",
},
{
"type": "lldb",
"request": "launch",
"name": "Debug UI (Release)",
"program": "${workspaceFolder}/target/release-with-debug/radlr",
"args": [
"build",
"-o",
"test",
"-n",
"json",
"./grammars/radlr/2.0.0/grammar.sg"
],
"cwd": "${workspaceFolder}"
},
]
}
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands",
"cSpell.words": [
"chkp",
"codepoints",
"Scanless",
"unoptimized"
"chkp",
"codepoints",
"RADLR",
"Scanless",
"unoptimized"
],
}
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"./crates/radlr-formatter",
"./crates/radlr-ascript",
"./crates/radlr-frontend",
"./crates/radlr-ir-compiler",
"./crates/radlr-core-common",
]

Expand Down
2 changes: 1 addition & 1 deletion crates/radlr-core/compile/states/build_graph/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn handle_cst_actions(gb: &mut ConcurrentGraphBuilder, pred: &SharedGraphNode, c
}

/// Iterate over each item's closure and collect the terminal transition symbols
/// of each item. The item's are then catagorized by these nonterminal symbols.
/// of each item. The item's are then categorized by these nonterminal symbols.
/// Completed items are catagorized by the default symbol.
fn get_firsts(gb: &mut ConcurrentGraphBuilder, pred: &GraphNode, config: &ParserConfig) -> RadlrResult<GroupedFirsts> {
let mut oos_scan_completed_tokens = OrderedSet::<PrecedentDBTerm>::new();
Expand Down
3 changes: 2 additions & 1 deletion crates/radlr-core/compile/states/build_graph/flow/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ pub(crate) fn create_call<'a, T: TransitionPairRefIter<'a> + Clone>(
}

// We'll need to climb the closure graph to find the highest mutual non-terminal
// that is not left recursive. This is only allowed if the system allows LR
// that is not left recursive. This is only allowed if the system allows BU
// parsing
if !____allow_ra____ {
return None;
};
Expand Down
5 changes: 3 additions & 2 deletions crates/radlr-core/grammar/build_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,9 @@ fn extract_nterm_syms(
// We've already merged in the non-terminal's sub-nonterminals
}
},
SymbolId::NonTerminalToken { id, .. } => {
let name = o_to_r(nonterminals.get(&id.as_parse_prod()), "Non-terminal not found")?.guid_name;
SymbolId::NonTerminalToken { id } => {
let name =
o_to_r(nonterminals.get(&id.as_parse_prod()), format!("Non-terminal not found, {id:?}").as_str())?.guid_name;
let name = ("tk:".to_string() + &name.to_string(s_store)).intern(s_store);
insert_symbol(symbols, &sym, tok.clone());
token_names.insert(id.as_parse_prod().as_tok_sym(), name);
Expand Down
4 changes: 2 additions & 2 deletions crates/radlr-core/types/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::types::*;
pub type RadlrResult<T> = std::result::Result<T, RadlrError>;

/// Converts an Option to a RadlrResult
pub fn o_to_r<T>(result: Option<T>, error_msg: &'static str) -> RadlrResult<T> {
pub fn o_to_r<T>(result: Option<T>, error_msg: &str) -> RadlrResult<T> {
match result {
Some(r) => Ok(r),
None => Err(RadlrError::StaticText(error_msg)),
None => Err(RadlrError::Text(error_msg.to_string())),
}
}
Loading

0 comments on commit faccbd5

Please sign in to comment.