ExC v0.4.2 Reader View Source

Reads all the files the compiler needs.

Link to this section Summary

Functions

Cleans the source code as a string.

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 an XML file.

Reads the structure of the target language's valid tokens as a General Token List (GTL).

Link to this section Functions

Link to this function

clean_source_code_string(file_content)

View Source

Cleans the source code as a string.

Specs

file_content is the path to the file to be compiled.

Generates the following output:

  • Source Code String (SCS): String.

Examples

    iex> scs = Reader.clean_source_code_string(File.read!("examples/test_s2.c"))
    "int main(){
     return -7;
     }"
Link to this function

read_code_and_tokens(raw_source_code_string, tokens_path, verbose \\ false)

View Source

Reads the source code from a file path and a general token list from an XML file.

Specs

raw_source_code_string is source code without any format coming from File.read!(path) tokens_path is the path to an XML file containing the target language's valid token list. verbose a boolean value indicating if the compiler should output all of its steps.

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")
Link to this function

read_general_ast(grammar_prod_rules_path)

View Source

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)
Link to this function

read_general_token_list(tokens_path)

View Source

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")