diff --git a/example/xml/GetBean.gdl b/example/xml/GetBean.gdl index 87de2614..be479498 100644 --- a/example/xml/GetBean.gdl +++ b/example/xml/GetBean.gdl @@ -1,62 +1,6 @@ // script use coref::xml::* -schema BeanXmlElement extends XmlElement {} - -impl BeanXmlElement { - @data_constraint - pub fn __all__(db: XmlDB) -> *BeanXmlElement { - for (e in XmlElement(db)) { - let (path = e.getLocation().getFile().getRelativePath()) { - if (!path.contains("target") && e.getName() = "bean") { - yield BeanXmlElement { - id: e.id, - location_id: e.location_id, - parent_id: e.parent_id, - index_order: e.index_order - } - } - } - } - } -} - -schema EntryXmlElement extends XmlElement {} - -impl EntryXmlElement { - @data_constraint - fn __all__(db: XmlDB) -> *EntryXmlElement { - for (e in XmlElement(db)) { - if (e.getName() = "entry") { - yield EntryXmlElement { - id: e.id, - location_id: e.location_id, - parent_id: e.parent_id, - index_order: e.index_order - } - } - } - } -} - -schema PropertyXmlElement extends XmlElement {} - -impl PropertyXmlElement { - @data_constraint - fn __all__(db: XmlDB) -> *PropertyXmlElement { - for (e in XmlElement(db)) { - if (e.getName() = "property") { - yield PropertyXmlElement { - id: e.id, - location_id: e.location_id, - parent_id: e.parent_id, - index_order: e.index_order - } - } - } - } -} - fn default_db() -> XmlDB { return XmlDB::load("coref_xml_src.db") } diff --git a/example/xml/POM.gdl b/example/xml/POM.gdl index 9c7779a2..636258ed 100644 --- a/example/xml/POM.gdl +++ b/example/xml/POM.gdl @@ -73,23 +73,6 @@ impl ArtifactElement { } } -schema PomFile extends XmlFile {} - -impl PomFile { - @data_constraint - pub fn __all__(db: XmlDB) -> *PomFile { - for(f in XmlFile(db)) { - if (f.getFileName() = "pom.xml") { - yield PomFile { - id: f.id, - file_name: f.file_name, - relative_path: f.relative_path - } - } - } - } -} - // output relative path of the file, referenced jar name and version fn out(fileName: string, m1: string, m2: string, m3: string) -> bool { let (db = XmlDB::load("coref_xml_src.db")) { diff --git a/tool/aci/check_gdl.sh b/tool/aci/check_gdl.sh index fd7fc454..302fe99e 100644 --- a/tool/aci/check_gdl.sh +++ b/tool/aci/check_gdl.sh @@ -44,72 +44,13 @@ fi cd "$1" || exit 1 sparrow_godel_script="$HOME/sparrow-cli/sparrow-cli/godel-script/usr/bin/godel" -sparrow_lib_1_0="$HOME/sparrow-cli/sparrow-cli/lib-1.0" +sparrow_lib="$HOME/sparrow-cli/sparrow-cli/lib" # Define get_files function get_files() { find "$1" -type f \( -name "*$2" \) -print } -# Define rebuild_lib function -rebuild_lib() { - local lib_path="$1" - local lib="$2" - local gdl_list=() - local output_file - local tmp_out - local start_time - local end_time - local elapsed_time - - gdl_list+=($(get_files "$lib_path" ".gs")) - gdl_list+=($(get_files "$lib_path" ".gdl")) - - output_file=$(mktemp "tempfile.XXXXXX.gdl") - trap 'rm -f "$output_file"' EXIT - - echo "// script" > "$output_file" - for file_name in "${gdl_list[@]}"; do - cat "$file_name" >> "$output_file" - done - - tmp_out=$(mktemp "tempfile.XXXXXX.gdl") - trap 'rm -f "$tmp_out"' EXIT - - start_time=$(date +%s%3N) - if ! "$sparrow_godel_script" "$output_file" -o "$tmp_out"; then - echo "$lib_path lib compile error, please check it yourself" >&2 - exit 1 - fi - - mv "$tmp_out" "$sparrow_lib_1_0/coref.$lib.gdl" - - end_time=$(date +%s%3N) - elapsed_time=$((end_time - start_time)) - echo "$lib_path lib compile success time: ${elapsed_time} milliseconds" >&2 -} - -# Define get_language function -get_language() { - local dir="$1" - local dirname - local language - - dirname=$(dirname "$dir") - language=$(basename "$dirname") - echo "$language" -} - -# Get libs directories -directories=($(find "$PWD" -type d \( -path "$PWD/language/*/lib" -o -path "$PWD/language/*/libs" \) -print)) - -# Get libs -for dir in "${directories[@]}"; do - lang=$(get_language "$dir") - echo "Building lib for $lang ..." - rebuild_lib "$dir" "$lang" -done - # Define get_target_files function get_target_files() { find "$1" -type f \( -name "*.gs" -o -name "*.gdl" \) -not -name "tempfile.*.gdl" -not -path "$1/language/*/lib/*" @@ -119,20 +60,21 @@ files=$(get_target_files "$PWD") # Iterate over the files for file in $files; do - output=$(("$sparrow_godel_script" "$file" -p "$sparrow_lib_1_0" -o "${file%.*}_tmp.gdl") 2>&1) + output=$(("$sparrow_godel_script" "$file" -p "$sparrow_lib" --semantic-only) 2>&1) + result=$? - # Check if the output is not empty if [ -n "$output" ]; then - echo "The file $file produced the following output:" + echo "File $file produced the following output:" echo "$output" - echo "Please check if this file is a godel script (.gs) or a godel 1.0 script (.gdl)" + fi + + # Check if the output is not empty + if [ $result -ne 0 ]; then + echo "Build failed, please check this file" exit 1 else echo "$file build successful" fi - - # Remove temporary file - rm -f "${file%.*}_tmp.gdl" done exit 0 \ No newline at end of file