Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move non generic frontend-utils code into their respective frontends #275

Merged
merged 1 commit into from
Jan 19, 2022
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
6 changes: 0 additions & 6 deletions jplag.frontend-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@
<version>3.1.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.jplag;
package de.jplag.cpp;

import java.io.IOException;
import java.io.InputStream;
Expand Down
82 changes: 41 additions & 41 deletions jplag.frontend.cpp/src/main/javacc/CPP.jj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import de.jplag.NewlineStream;
import de.jplag.cpp.NewlineStream;

public class CPPScanner implements CPPTokenConstants {
private static Scanner scanner2;
Expand Down Expand Up @@ -317,15 +317,15 @@ void token(): {}
| ">="
| "<<"
| ">>"
| "+"
| "-"
| "*"
| "/"
| "%"
| "+"
| "-"
| "*"
| "/"
| "%"
| "++" { scanner2.add(C_ASSIGN,token); }
| "--" { scanner2.add(C_ASSIGN,token); }
| "~"
| "!"
| "~"
| "!"
| "auto" { scanner2.add(C_AUTO,token); }
| "break" { scanner2.add(C_BREAK,token); }
| "case" { scanner2.add(C_CASE,token); }
Expand Down Expand Up @@ -373,37 +373,37 @@ void token(): {}
| "volatile" { scanner2.add(C_VOLANTILE,token); }
| "while" { scanner2.add(C_WHILE,token); }
| "operator" { scanner2.add(C_OPERATOR,token); }
| "true"
| "false"
| "true"
| "false"
| "throw" { scanner2.add(C_THROW,token); }
| "NULL" { scanner2.add(C_NULL,token); }

| <OCTALINT>
| <OCTALLONG>
| <UNSIGNED_OCTALINT>
| <UNSIGNED_OCTALLONG>
| <DECIMALINT>
| <DECIMALLONG>
| <UNSIGNED_DECIMALINT>
| <UNSIGNED_DECIMALLONG>
| <OCTALINT>
| <OCTALLONG>
| <UNSIGNED_OCTALINT>
| <UNSIGNED_OCTALLONG>
| <DECIMALINT>
| <DECIMALLONG>
| <UNSIGNED_DECIMALINT>
| <UNSIGNED_DECIMALLONG>

| <HEXADECIMALINT>
| <HEXADECIMALLONG>
| <UNSIGNED_HEXADECIMALINT>
| <UNSIGNED_HEXADECIMALLONG>
| <HEXADECIMALINT>
| <HEXADECIMALLONG>
| <UNSIGNED_HEXADECIMALINT>
| <UNSIGNED_HEXADECIMALLONG>

| <FLOATONE>
| <FLOATTWO>
| <FLOATONE>
| <FLOATTWO>

| <CHARACTER>
| <STRING>
| <CHARACTER>
| <STRING>

| <BACKSLASH>

//| var() [LOOKAHEAD(2) "(" { scanner2.add(C_FUN,token); } ]
| "."
| "->"
| ".*"
| "->"
| ".*"
| "->*"
| <ID>
}
Expand Down Expand Up @@ -433,19 +433,19 @@ void var3(): {}
void index(): {}
{
var()
| <OCTALINT>
| <OCTALLONG>
| <UNSIGNED_OCTALINT>
| <UNSIGNED_OCTALLONG>
| <DECIMALINT>
| <DECIMALLONG>
| <UNSIGNED_DECIMALINT>
| <UNSIGNED_DECIMALLONG>

| <HEXADECIMALINT>
| <HEXADECIMALLONG>
| <UNSIGNED_HEXADECIMALINT>
| <UNSIGNED_HEXADECIMALLONG>
| <OCTALINT>
| <OCTALLONG>
| <UNSIGNED_OCTALINT>
| <UNSIGNED_OCTALLONG>
| <DECIMALINT>
| <DECIMALLONG>
| <UNSIGNED_DECIMALINT>
| <UNSIGNED_DECIMALLONG>

| <HEXADECIMALINT>
| <HEXADECIMALLONG>
| <UNSIGNED_HEXADECIMALINT>
| <UNSIGNED_HEXADECIMALLONG>

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import antlr.Token;
import de.jplag.AbstractParser;
import de.jplag.TokenList;
import de.jplag.UnicodeReader;
import de.jplag.csharp.grammar.CSharpLexer;
import de.jplag.csharp.grammar.CSharpParser;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Original pseudocode : Thomas Weidenfeller
* Implementation tweaked: Aki Nieminen
*
*
* http://www.unicode.org/unicode/faq/utf_bom.html
* BOMs:
* 00 00 FE FF = UTF-32, big-endian
* FF FE 00 00 = UTF-32, little-endian
* FE FF = UTF-16, big-endian
* FF FE = UTF-16, little-endian
* EF BB BF = UTF-8
*
*
* Win2k Notepad:
* Unicode format = UTF-16LE
*/

package de.jplag;
package de.jplag.csharp;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -28,7 +28,7 @@
* Generic unicode text reader, which will use BOM mark to identify the encoding to be used. If BOM is not found then
* use a given default encoding. UTF-8 is used if: BOM mark is not found and defaultEnc is NULL.
* Usage pattern:
*
*
* <pre>
* String defaultEnc = "UTF-16BE"; // or NULL to use system default
* FileInputStream fis = new FileInputStream(file);
Expand Down
8 changes: 4 additions & 4 deletions jplag.frontend.text/src/main/antlr/text.g
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ file : ( w:WORD { parser.add(w); } | PUNCTUATION | SPECIALS )* EOF ;
//----------------------------------------------------------------------------

{
import de.jplag.InputState;
import de.jplag.ParserToken;
import de.jplag.text.InputState;
import de.jplag.text.ParserToken;
}

class TextLexer extends Lexer;
Expand Down Expand Up @@ -72,7 +72,7 @@ options
}
}

WORD
WORD
options { paraphrase = "an identifier"; } :
(( '0'..'9') | ('A'..'Z') | ('a'..'z') |
('\300' .. '\326') | ('\330' .. '\366') | ('\370' .. '\377'))+ ;
Expand All @@ -84,7 +84,7 @@ PUNCTUATION : ( '!' | '"' | '\'' | '(' | ')' | ',' | '-' | '.' |
SPECIALS : ('#' | '$' | '%' | '&' | '+' | '<' | '=' | '*' |
'/' | '>' | '@' | '\\' | '^' | '_' | '|' | '~' |
('\241' .. '\252') | ('\254' .. '\263') | ('\265' .. '\272') |
('\274' .. '\276') | '\327' | '\367' | ('\200' .. '\237') ) ;
('\274' .. '\276') | '\327' | '\367' | ('\200' .. '\237') ) ;

// Whitespace -- ignored
SPACE : ( ' '
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.jplag;
package de.jplag.text;

import java.io.InputStream;
import java.io.Reader;
Expand Down
4 changes: 1 addition & 3 deletions jplag.frontend.text/src/main/java/de/jplag/text/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import antlr.Token;
import de.jplag.AbstractParser;
import de.jplag.InputState;
import de.jplag.ParserToken;
import de.jplag.TokenConstants;
import de.jplag.TokenList;

Expand Down Expand Up @@ -45,7 +43,7 @@ private boolean parseFile(File dir, String file) {
inputState = new InputState(inputStream);
TextLexer lexer = new TextLexer(inputState);
lexer.setFilename(file);
lexer.setTokenObjectClass("de.jplag.ParserToken");
lexer.setTokenObjectClass("de.jplag.text.ParserToken");

// Create a parser that reads from the scanner
TextParser parser = new TextParser(lexer);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.jplag;
package de.jplag.text;

import antlr.Token;

Expand Down