Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Repository Guidelines

## Project Structure & Module Organization
- `src/java` holds the Java implementation (packages under `io.compgen.cgpipe`).
- `src/conf` and `src/scripts` contain runtime configuration and launcher assets.
- `src/test-scripts` contains language-level test fixtures (`*.mvp`, `*.mvpt`).
- `docs` includes user and language reference documentation.
- `lib` and `blib` hold third-party jars; `build`, `dist` are build outputs.

## Build, Test, and Development Commands
- `ant jar` builds the CLI artifacts into `dist/` (includes `cgpipe` and `cgsub`).
- `ant clean` removes `build/` and `dist/` output.
- `./test.sh` runs the language tests in `src/test-scripts` and compares against `.good` files.
- `./build_docs.sh` regenerates documentation (when needed).

## Coding Style & Naming Conventions
- Java code uses tabs for indentation; match the existing style in nearby files.
- Package naming follows `io.compgen.cgpipe.*`; classes use `PascalCase`, methods/vars use `camelCase`.
- Keep changes compatible with Java 11 (see `build.xml` compiler settings).
- No automated formatter is configured; avoid large, unrelated reformatting.

## Testing Guidelines
- Tests are script-based; each `*.mvp`/`*.mvpt` should have a matching `.good` output file.
- Add or update tests for language/runtime changes and verify with `./test.sh`.
- Use `./test.sh -v` (or `-vv/-vvv`) to see expected vs. actual output diffs.

## Commit & Pull Request Guidelines
- Git history shows short, direct subjects (e.g., “debug”, “missing comment”); follow this concise style.
- Use imperative, present-tense summaries and include context in the PR description.
- Include test results (`./test.sh`) and note any config or scheduler assumptions.

## Configuration & Runtime Notes
- CGPipe reads configuration from `.cgpiperc` files and environment (`CGPIPE_HOME`, `CGPIPE_ENV`).
- Scheduler templates live under `src/java/io/compgen/cgpipe/runner`; update templates with care.
4 changes: 3 additions & 1 deletion docs/03-Language_Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ Basic syntax:
do something...
done

for val
do something... # while-style loop; runs while val is true


## Build target definitions
Targets are the files that you want to create. They are defined on a single
Expand Down Expand Up @@ -475,4 +478,3 @@ a var:
will result in this being added to the body:

echo "target"

9 changes: 7 additions & 2 deletions src/java/io/compgen/cgpipe/parser/node/ASTNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ protected ASTNode parseTokens(TokenList tokens) throws ASTParseException {
return this.next;
}

int sliceDepth = 0;
for (Token tok: tokens) {
if (tok.isColon()) {
if (tok.isSliceOpen()) {
sliceDepth++;
} else if (tok.isSliceClose() && sliceDepth > 0) {
sliceDepth--;
} else if (tok.isColon() && sliceDepth == 0) {
this.next = new TargetNode(this, tokens);
return this.next;
}
Expand All @@ -71,6 +76,7 @@ public ASTNode exec(ExecContext context) throws ASTExecException {
// System.err.println("Eval: " + StringUtils.join(",", tokens));
VarValue val = Eval.evalTokenExpression(tokens, context);
if (val == VarNull.NULL) {
// context.getRoot().dump();
throw new ASTExecException("Null expression: " + tokens);
}
// System.err.println("<<< " + val.toString());
Expand Down Expand Up @@ -112,4 +118,3 @@ public ASTNode getParent() {
return parent;
}
}

1 change: 1 addition & 0 deletions src/java/io/compgen/cgpipe/parser/tokens/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static TokenList tokenize(NumberedLine line, boolean inTargetDef) throws
if (!inSlice) {
throw new ASTParseException("Missing opening [");
}
inSlice = false;
}
if (!inSlice && tok.isColon()) {
foundColon = true;
Expand Down
16 changes: 16 additions & 0 deletions src/test-scripts/varvar.mvpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
foo = "foobar"
bar = foo[3:]

print(foo)
print(bar)
print(foo[3:])

i=0

for foo == "foobar" && i < 2
print(foo)
foo2 = foo[1:]
foo = foo2
i = i + 1
print(foo)
done
5 changes: 5 additions & 0 deletions src/test-scripts/varvar.mvpt.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
foobar
bar
bar
foobar
oobar
1 change: 1 addition & 0 deletions src/test-scripts/while.mvpt.good
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
7
8
9
here
5 changes: 3 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ fi

if [ "$1" == "" ]; then
rm -f test/err
find src/test-scripts -name '*.mvp' -exec $0 $VERBOSE \{\} \;
find src/test-scripts -name '*.mvpt' -exec $0 $VERBOSE \{\} \;
# Skip remote-dependent tests during bulk runs.
find src/test-scripts -name '*.mvp' ! -name 'help.mvp' -exec $0 $VERBOSE \{\} \;
find src/test-scripts -name '*.mvpt' ! -name 'remote.mvpt' -exec $0 $VERBOSE \{\} \;

if [ -e test/err ]; then
rm test/err
Expand Down