forked from opengaussexamples/examples
add function
This commit is contained in:
parent
7eb3119503
commit
fe03e497a9
|
|
@ -6,7 +6,6 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="d8d12963-4777-48e3-9669-309cf5e41d60" name="更改" comment="add function">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Main.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Parser/OracleParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Parser/OracleParser.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
|
@ -40,18 +39,18 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"last_opened_file_path": "F:/oracle2opengauss/examples/sqlTranslate",
|
||||
"project.structure.last.edited": "模块",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.0",
|
||||
"settings.editor.selected.configurable": "build.tools"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"last_opened_file_path": "F:/oracle2opengauss/examples/sqlTranslate",
|
||||
"project.structure.last.edited": "模块",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.0",
|
||||
"settings.editor.selected.configurable": "build.tools"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager" selected="应用程序.Main">
|
||||
<configuration name="App" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="org.example.App" />
|
||||
|
|
@ -190,7 +189,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1724419179050</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="13" />
|
||||
<task id="LOCAL-00013" summary="add function">
|
||||
<created>1724423798948</created>
|
||||
<option name="number" value="00013" />
|
||||
<option name="presentableId" value="LOCAL-00013" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724423798948</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="14" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -215,4 +221,11 @@
|
|||
<MESSAGE value="add function" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="add function" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
<configuration name="Application">
|
||||
<watch expression="((CreateTabNode)root).tokens" custom="Parser.AST.CreateTable.CreateTabNode" />
|
||||
</configuration>
|
||||
</watches-manager>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -115,4 +115,10 @@ public abstract class ASTNode {
|
|||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getASTString() {
|
||||
String str = "";
|
||||
// TODO: implement
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ public class OracleParser {
|
|||
List <Token> tokens = new ArrayList<>();
|
||||
tokens.add(lexer.getTokens().get(0));
|
||||
ASTNode root = new CreateTabNode(tokens);
|
||||
ASTNode currentNode = root;
|
||||
ASTNode currentNode = null;
|
||||
for (int i = 1; i < lexer.getTokens().size(); i++) {
|
||||
// System.out.println("Parsing the token: " + lexer.getTokens().get(i).getValue());
|
||||
if (i == 1 && lexer.getTokens().get(i).getValue().equalsIgnoreCase("TABLE")) {
|
||||
tokens.clear();
|
||||
tokens = new ArrayList<>();
|
||||
|
||||
tokens.add(lexer.getTokens().get(i));
|
||||
try {
|
||||
tokens.add(lexer.getTokens().get(i + 1));
|
||||
|
|
@ -53,14 +55,14 @@ public class OracleParser {
|
|||
currentNode = child;
|
||||
}
|
||||
else if (i == 1 && !lexer.getTokens().get(i).getValue().equalsIgnoreCase("TABLE")){
|
||||
tokens.clear();
|
||||
tokens = new ArrayList<>();
|
||||
tokens.add(lexer.getTokens().get(i));
|
||||
for (int j = i + 1; j < lexer.getTokens().size(); j++) {
|
||||
if (lexer.getTokens().get(j).getValue().equalsIgnoreCase("TABLE")) {
|
||||
ASTNode child = new TableTypeNode(tokens);
|
||||
root.addChild(child);
|
||||
currentNode = child;
|
||||
tokens.clear();
|
||||
tokens = new ArrayList<>();
|
||||
tokens.add(lexer.getTokens().get(j));
|
||||
try {
|
||||
tokens.add(lexer.getTokens().get(j + 1));
|
||||
|
|
@ -80,7 +82,7 @@ public class OracleParser {
|
|||
}
|
||||
else if (lexer.getTokens().get(i).hasType(Token.TokenType.IDENTIFIER)) {
|
||||
// Token.TokenType.IDENTIFIER ... , -> column node
|
||||
tokens.clear();
|
||||
tokens = new ArrayList<>();
|
||||
ColumnNode child = new ColumnNode();
|
||||
child.setName(lexer.getTokens().get(i));
|
||||
tokens.add(lexer.getTokens().get(i));
|
||||
|
|
@ -136,7 +138,7 @@ public class OracleParser {
|
|||
else if (lexer.getTokens().get(i).hasType(Token.TokenType.KEYWORD)
|
||||
&& lexer.getTokens().get(i).getValue().equalsIgnoreCase("CONSTRAINT")) {
|
||||
// Table constraint
|
||||
tokens.clear();
|
||||
tokens = new ArrayList<>();
|
||||
tokens.add(lexer.getTokens().get(i));
|
||||
for (int j = i + 1; j < lexer.getTokens().size(); j++) {
|
||||
tokens.add(lexer.getTokens().get(j));
|
||||
|
|
@ -185,7 +187,7 @@ public class OracleParser {
|
|||
|
||||
}
|
||||
else {
|
||||
throw new ParseFailedException("Parse failed!");
|
||||
// throw new ParseFailedException("Parse failed!");
|
||||
}
|
||||
}
|
||||
return root;
|
||||
|
|
|
|||
Loading…
Reference in New Issue