From bf29ac12eb8f0745392a94fa62528db79f23c589 Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Fri, 24 Apr 2009 02:53:59 +0000 Subject: [PATCH] Added single line comments that start with a ; git-svn-id: https://smali.googlecode.com/svn/trunk@10 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- .../antlr3/org/JesusFreke/smali/smaliLexer.g | 12 +++++++++--- src/test/resources/examples/HelloWorld2.smali | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g b/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g index 6c7f3ae8..8be9f6dd 100644 --- a/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g +++ b/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g @@ -1,13 +1,13 @@ /* - * The number, string and character constant lexical rules are derived from rules - * from the Java 1.6 grammar which can be found here: + * The comment, number, string and character constant lexical rules are + derived from rules from the Java 1.6 grammar which can be found here: * http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g * * Specifically, these rules: * * STRING_LITERAL, ESCAPE_SEQUENCE, HEX_DIGITS, HEX_DIGIT, INTEGER_LITERAL, * HEX_PREFIX, LONG_LITERAL, FLOATING_POINT_NUMBER, DECIMAL_EXPONENT, - * HEX_EXPONENT, FLOAT_LITERAL, DOUBLE_LITERAL, CHAR_LITERAL + * HEX_EXPONENT, FLOAT_LITERAL, DOUBLE_LITERAL, CHAR_LITERAL, LINE_COMMENT * * These rules were originally copyrighted by Terence Parr, and are used here in * accordance with the following license @@ -747,3 +747,9 @@ fragment WS WHITE_SPACE : (' '|'\t'|'\n'|'\r')+ {$channel = HIDDEN;}; + + +LINE_COMMENT + : (';' ~('\n'|'\r')* ('\r\n' | '\r' | '\n') + | ';' ~('\n'|'\r')*) + {$channel = HIDDEN;}; diff --git a/src/test/resources/examples/HelloWorld2.smali b/src/test/resources/examples/HelloWorld2.smali index 948ae8d0..18bf426a 100644 --- a/src/test/resources/examples/HelloWorld2.smali +++ b/src/test/resources/examples/HelloWorld2.smali @@ -6,11 +6,22 @@ .field private static helloWorldStatic2 Ljava/lang/String; = "Static Initializer Hello World!" -.method static constructor ()V + +;This class should display the following text to the screen: +; +;Hello World! +;Static Hello World! +;Static Initializer Hello World! +;org/JesusFreke/HelloWorld2/HelloWorld2 +;[Lorg/JesusFreke/HelloWorld2/HelloWorld2; +;[I + + +.method static constructor ()V ;test .registers 1 const-string v0, "Static Hello World!" - sput-object v0, org/JesusFreke/HelloWorld2/HelloWorld2/helloWorldStatic Ljava/lang/String; + sput-object v0, org/JesusFreke/HelloWorld2/HelloWorld2/helloWorldStatic Ljava/lang/String; ;test return-void .end method @@ -20,7 +31,7 @@ invoke-direct {v1}, android/app/Activity/()V const-string v0, "Hello World!" - iput-object v0, v1, org/JesusFreke/HelloWorld2/HelloWorld2/helloWorld Ljava/lang/String; + iput-object v0, v1, org/JesusFreke/HelloWorld2/HelloWorld2/helloWorld Ljava/lang/String;;test return-void .end method