Skip to content

Commit

Permalink
Merge pull request #2499 from vszakats/xgramm
Browse files Browse the repository at this point in the history
add grammar for xbase and harbour languages
  • Loading branch information
arfon committed Jul 14, 2015
2 parents 9c0af2e + 4c81c0d commit 314b7f1
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,6 @@
[submodule "vendor/grammars/language-crystal"]
path = vendor/grammars/language-crystal
url = https://github.com/k2b6s9j/language-crystal
[submodule "vendor/grammars/language-xbase"]
path = vendor/grammars/language-xbase
url = https://github.com/hernad/atom-language-harbour
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ vendor/grammars/language-python:
vendor/grammars/language-shellscript:
- source.shell
- text.shell-session
vendor/grammars/language-xbase:
- source.harbour
vendor/grammars/language-yaml:
- source.yaml
vendor/grammars/latex.tmbundle:
Expand Down
5 changes: 3 additions & 2 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ Harbour:
color: "#0e60e3"
extensions:
- .hb
tm_scope: none
tm_scope: source.harbour
ace_mode: text

Haskell:
Expand Down Expand Up @@ -3783,5 +3783,6 @@ xBase:
color: "#403a40"
extensions:
- .prg
tm_scope: none
- .ch
tm_scope: source.harbour
ace_mode: text
167 changes: 167 additions & 0 deletions samples/xBase/sample.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#require "hbtest"

#pragma linenumber=on

#include "hbclass.ch"

#stdout "stdout"
#warning "warning"

#define MYCONST 100
#undef MYCONST

#ifdef __HARBOUR__
#else
#endif

#if defined( __HARBOUR__ ) .OR. .T.
#elif defined( __HARBOUR__ )
#endif

THREAD STATIC t_var := "thread"

REQUEST AllTrim
ANNOUNCE my_module

PROCEDURE Main()

MEMVAR p_var, m_var
FIELD fld

STATIC s_test := "static"
LOCAL o := TTest():New( "one", "two" ), tmp
LOCAL oError
LOCAL bBlock := {| tmp | QOut( tmp ) }
LOCAL hHash := { "name" => "value", "name2" => "value2", 2 => 1 }
PUBLIC p_var := "public"
PRIVATE m_var := "private"
PARAMETERS p1

Set( _SET_DATEFORMAT, "yyyy-mm-dd" )

CLS
@ 10, 10 SAY "Hello world!"

? hb_ValToExp( o )
? m->p1
? hHash[ "name" ], hHash[ 2 ]

FOR tmp := 1 TO 10 STEP 2
? tmp
NEXT

FOR EACH tmp IN { "a", "b" } DESCEND
? tmp
NEXT

? 10.01 + 2 - 3 / 4 * 5 ^ 6 ** 1
? 2 < 1, 2 > 1, 2 >= 1, 2 <= 1, 2 == 1, 2 = 1, 2 != 1, 2 <> 1, 2 # 1
? -( 1 + 2 ), "a" $ "ab", 10 % 2

tmp := 0
DO WHILE tmp < 2
? tmp++
ENDDO

tmp := 0
WHILE tmp < 2
? ++tmp
IF tmp >= 0xFF
LOOP
ENDIF
EXIT
ENDDO

--tmp
tmp--

IF tmp < -10.0
? NIL
ELSEIF .F.
? 0d19800101
ELSE
? "string"
ENDIF

DO CASE
CASE tmp == 1
? "A"
OTHERWISE
? "B"
ENDCASE

SWITCH tmp
CASE 1
? "A"
EXIT
OTHERWISE
? "B"
ENDSWITCH

BEGIN SEQUENCE WITH __BreakBlock()
BREAK
RECOVER USING oError
END /* SEQUENCE */

local_func( @hHash )

RETURN

INIT PROCEDURE init_proc()
RETURN

EXIT PROCEDURE exit_proc()
RETURN

PROCEDURE returning_nothing()
RETURN

FUNCTION pub_func()
RETURN .T.

STATIC FUNCTION local_func()
RETURN .F.

CREATE CLASS TTest INHERIT TParent
VAR One, Two
METHOD New( One )
METHOD Test() INLINE QOut( "Hello" )
METHOD MethProc()
ENDCLASS

METHOD PROCEDURE MethProc()
RETURN

METHOD New( One ) CLASS TTest

::super:New()
::One := One

RETURN Self

CREATE CLASS TParent
VAR One
METHOD New()
ENDCLASS

METHOD New() CLASS TParent
? "TParent:New()"
RETURN Self

// This is a comment
/* This is a comment */
/* This is
a comment */
* This is a comment
&& This is a comment
NOTE This is a comment
note This is a comment
NOTE

FUNCTION pub_func2()
? "hello world!"
? 'hello world!'
? "hello\world!"
? "\"
? "hello world!"
RETURN .T.
1 change: 1 addition & 0 deletions vendor/grammars/language-xbase
Submodule language-xbase added at 86f0c6

0 comments on commit 314b7f1

Please sign in to comment.