ExC v0.4.0 Reader View Source
Reads all the files the compiler needs.
Link to this section Summary
Functions
Reads the source code from a file path and a general token list from an XML file.
Reads the structure of the target language's grammar production rules from
Reads the structure of the target language's valid tokens as a General Token List (GTL).
Reads the source code as a string.
Link to this section Functions
read_code_and_tokens(source_code_path, tokens_path, verbose \\ false)
View SourceReads the source code from a file path and a general token list from an XML file.
Specs
source_code_path
is the path to the file to be compiled.tokens_path
is the path to an XML file containing the target language's
valid token list.
Generates the following output:
- Source Code String (SCS): source code contained in a string.
- General Token List (GTL): list of target language valid tokens.
Examples
iex> {scs, gtl} = Reader.read_code_and_tokens('examples/test.c',
"specification_files/c_tokens.xml")
Reads the structure of the target language's grammar production rules from
an XML file.
Specs
grammar_prod_rules_path
is the path to an XML file containing the
target language's grammar production rules.
Generates the following output:
- General Abstract Syntax Treee (GAST): list containing the target language grammar production rules.
Examples
# iex> gast = Reader.read_general_ast(grammar_prod_rules_path)
Reads the structure of the target language's valid tokens as a General Token List (GTL).
Specs
tokens_path
is the path to an XML file containing the target language's valid token list.
Generates the following output:
- General Token List (GTL): list of target language's valid tokens.
Examples
iex> gtl = Reader.read_general_token_list("specification_files/c_tokens.xml")
Reads the source code as a string.
Specs
source_code_path
is the path to the file to be compiled.
Generates the following output:
- Source Code String (SCS): String.
Examples
iex> scs = Reader.read_source_code_string("examples/test_s2.c")
"int main(){ return -7; }
"