vala r1456 - in trunk: . vala
- From: jamiemcc svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1456 - in trunk: . vala
- Date: Tue, 27 May 2008 04:32:16 +0000 (UTC)
Author: jamiemcc
Date: Tue May 27 04:32:16 2008
New Revision: 1456
URL: http://svn.gnome.org/viewvc/vala?rev=1456&view=rev
Log:
2008-05-27 Jamie McCracken <jamiemcc gnome org>
* vala/valagenieparser.vala:
* vala/valageniescanner.vala:
Added optional indent attribute to allow spaces to be used in lieu of tabs for indents
Modified:
trunk/ChangeLog
trunk/vala/valagenieparser.vala
trunk/vala/valageniescanner.vala
Modified: trunk/vala/valagenieparser.vala
==============================================================================
--- trunk/vala/valagenieparser.vala (original)
+++ trunk/vala/valagenieparser.vala Tue May 27 04:32:16 2008
@@ -346,6 +346,21 @@
next ();
try {
+ var begin = get_location ();
+ /* see if there is an indent attribute */
+ if (accept (TokenType.OPEN_BRACKET)) {
+ var id = parse_identifier ();
+ if (id == "indent") {
+ expect (TokenType.ASSIGN);
+ expect (TokenType.INTEGER_LITERAL);
+ scanner.indent_spaces = get_last_string().to_int();
+ expect (TokenType.CLOSE_BRACKET);
+ expect (TokenType.EOL);
+ } else {
+ rollback (begin);
+ }
+ }
+
parse_using_directives ();
parse_declarations (context.root, true);
} catch (ParseError e) {
Modified: trunk/vala/valageniescanner.vala
==============================================================================
--- trunk/vala/valageniescanner.vala (original)
+++ trunk/vala/valageniescanner.vala Tue May 27 04:32:16 2008
@@ -30,6 +30,8 @@
public class Vala.Genie.Scanner : Object {
public SourceFile source_file { get; construct; }
+ public int indent_spaces { get;set;}
+
char* begin;
char* current;
char* end;
@@ -45,6 +47,8 @@
bool parse_started;
string _comment;
+
+
public Scanner (SourceFile source_file) {
this.source_file = source_file;
@@ -56,6 +60,7 @@
current = begin;
+ _indent_spaces = 0;
line = 1;
column = 1;
current_indent_level = 0;
@@ -423,9 +428,11 @@
}
- /* scrub whitespace (excluding newlines) and comments */
- space ();
-
+ if ((_indent_spaces == 0 ) || (last_token != TokenType.EOL)) {
+ /* scrub whitespace (excluding newlines) and comments */
+ space ();
+ }
+
/* handle line continuation */
while (current < end && current[0] == '\\' && current[1] == '\n') {
current += 2;
@@ -863,14 +870,27 @@
int count_tabs ()
{
+
int tab_count = 0;
- while (current < end && current[0] == '\t') {
- current++;
- column++;
- tab_count++;
- }
+ if (_indent_spaces == 0) {
+ while (current < end && current[0] == '\t') {
+ current++;
+ column++;
+ tab_count++;
+ }
+ } else {
+ int space_count = 0;
+ while (current < end && current[0] == ' ') {
+ current++;
+ column++;
+ space_count++;
+ }
+
+ tab_count = space_count / _indent_spaces;
+
+ }
/* ignore comments and whitspace and other lines that contain no code */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]